Hey, good to see everyone is getting on so well 
Big huge thanks goes out to Naomi for doing all the support that I should have been doing
Thanks!
If you want to avoid globals you should be able to load your boxes locally on each screen you want to access them from, just make sure to call save() before you change scenes or things will get lost.
For multiplayer, if you wanted to be extra fancy you can negate having lots of different player boxes by doing something like this:
local function createPlayer( index )
local playerBox = ice:loadBox( "player" )
local player = {}
player.name = "player" .. index
player.score = 0
player.hiScore = 0
player.medals = { 0, 0, 0 }
player.promotion = 0
player.rank = 1
player.bonus = 0
player.bullet = 1000
playerBox:store( player.name, player )
playerBox:save()
end
All this function does is initiate all the variables for the player and then store the player table in the singular box ( loaded locally ) under the property name of whatever the player name is.
Then have a second function for getting a player:
local function getPlayer( index )
local playerBox = ice:loadBox( "player" )
local playerName = "player" .. index
local player = playerBox:retrieve( playerName )
if player then
return player
else
-- error, no player found with this index
end
end
And a third for saving a player:
local function savePlayer( player )
local playerBox = ice:loadBox( "player" )
local playerName = player.name
playerBox:store( playerName, player )
playerBox:save()
end
You can then use it like so:
-- Create a couple of players
createPlayer( 1 )
createPlayer( 2 )
-- Retrieve one of them
local player1 = getPlayer( 1 )
-- Change the score ( or anything else )
player1.score = 40
-- Save it back out again
savePlayer( player1 )
[import]uid: 5833 topic_id: 16634 reply_id: 67334[/import]

