ICE trouble

Hey all,

I have been using the Ice module by GrahamRanson and have run into a problem. At the end of the game, the score is saved. Then, in another menu, the lowest current score can be seen. Then only problem is that after a couple of hours of not playing the game, the values are set back to zero. Here is some of my code:

In the game I:
[lua]—Set up my Icebox—
require( “ice” )
local scores = ice:loadBox( “scores” )
—Saves the score—
scores:store( “best”, (scores:retrieve(“best”)))
scores:storeIfLower( “best”, (finalPTS))
scores:save()[/lua]
In the Scores menu I:
[lua]–load my Icebox
local scores = ice:loadBox( “scores” )
—Set up some vars—
if scores then
easyT = (scores:retrieve(“best”))
end
—Determine what the text should say—
if easyT == nil or easyT == 0 or easyT == 5000 then
easyTime.text = “—”
else
easyTime.text = (easyT)
end[/lua]
I have no idea what the problem could be. If you need more code I can probably dig it out… Any suggestions would be*

*Much appreciated,
J.K. [import]uid: 66117 topic_id: 18685 reply_id: 318685[/import]

Hi,

In ice.lua try replacing the IceBox:storeIfLower() function with this:

  
--- Saves a value in the icebox if it is lower than the one already in there.  
-- @param name The name of the value to add.  
-- @param value The value to save.  
-- @return The stored value.  
-- @return True if it was added, false if not.  
function IceBox:storeIfLower( name, value )  
  
 local added = false  
  
 if name then  
  
 local currentValue = self:retrieve( name ) or 0  
  
 if currentValue then  
  
 if value \< currentValue then  
 self.\_items[name] = value  
 added = true  
 self.\_header.modified = os.time()  
 end  
  
 else  
 self.\_items[name] = value  
 added = true  
 self.\_header.modified = os.time()  
 end  
  
 end  
  
 if self:isAutomaticSavingEnabled() then  
 self:save()  
 end  
  
 return added, value  
  
end  
  

See if that helps. [import]uid: 5833 topic_id: 18685 reply_id: 71863[/import]

Hey Graham,

Looks like that fixed it. Thanks!

Much appreciated,
J.K.
[import]uid: 66117 topic_id: 18685 reply_id: 72020[/import]

Awesome, glad it worked.

I have checked in the change to the repo now as well for other people. [import]uid: 5833 topic_id: 18685 reply_id: 72026[/import]

Hi Graham,

I am trying to use the ftp helper and it partially works. I am trying to upload an image and it creates the file name on my server but stops there with 0K as the file size. This is for Android. Any suggestions?

Thanks!!
Warren

Hi Graham,

I am trying to use the ftp helper and it partially works. I am trying to upload an image and it creates the file name on my server but stops there with 0K as the file size. This is for Android. Any suggestions?

Thanks!!
Warren