Game Development Reference
In-Depth Information
model = "iPhone5",
apps = {},
}
With this, the name, device, and model cannot be changed; however, the apps table can be altered
using the various functions.
print(myRO.name)
RO.name = "Something Else"
print(myRO.name)
If for some particular reason you want to overwrite a value in the read-only table, there is a way (but
metatable functions of __newindex and set the value directly, as follows:
rawset(theTable, theKey, theValue)
push them onto the
pop them from the stack). The usage scenarios for a stack can
you collected on a stack, and then at the end of the level, you can award points based on what was
collected, while removing the items from the stack. To try out this example, place this code into a file
called stacks.lua .
local _stack = {}
-- Create a table with stack functions
function _stack:create()
local theStack = {}
theStack._entries = {}
-- push a value onto the stack
function theStack:push(...)
if ... then
local tArgs = {...}
-- add these values
for i,v in pairs(tArgs) do
table.insert(self._entries, v)
end
end
end
-- pop a number of values from the stack
function theStack:pop(num)
 
Search WWH ::




Custom Search