Crash when trying to prevent openfeint launching when game first launches

When I put the following code at the top of my main.lua file

  
local openfeint = require("openfeint")  
openfeint.init("XXX", "XXX", "XXX", "XXX")  
  

The first time my game is launched, the openfeint dashboard opens up immediately which I find quite annoying.

I therefore thought I could just initiate the init call if the user clicks an openfeint button that I have included. So at the top of main.lua I still include the

local openfeint = require("openfeint")  

If the user does not click on the openfeint button, and my game calls some openfeint code such as the following, my game crashes.

  
openfeint.unlockAchievement (771812)  
  

Does everyone just accept the fact the first time the game is launched the dashboard appears or does anyone have a solution to this?

Thanks

Paul [import]uid: 7863 topic_id: 7095 reply_id: 307095[/import]

I had the same issue. My idea for a solution, which I didn’t get around to trying was to assign a value to the openfeint button.

So:
value = 0

if touched openfeint button value = 1

later

when achievement unlocked check value
if value = 1
openfeint.unlockAchievement
else
nothing
end [import]uid: 10903 topic_id: 7095 reply_id: 25018[/import]

@crssmn

Thanks I have ended up doing something similar where I have a global variable that is set to false the first time the game is ever launched. Then if the user clicks on the openfeint button, I set this to true.

The important thing is to save this global variable to the device so the next time you launch the game, it remembers that you have called the init function.

This solution appears to work fine though I have not tested this rigorously. [import]uid: 7863 topic_id: 7095 reply_id: 25113[/import]

So if I am following this thread right, the “openfeint.init” needs to be called only once, ever, the very first time the game is launched (or with a button) if the player wants OF? Then you save some a preference which means you have already called “init”? Or does it need to be called each time the game starts (if the player is using OF), but just once? [import]uid: 8139 topic_id: 7095 reply_id: 44811[/import]

You need to use the init command only once before the user does anything with openfeint. You can save whether or not it has been initialized to a binary variable so that when the user posts a high score it will only do so if they have initialized OF. [import]uid: 10903 topic_id: 7095 reply_id: 44856[/import]

Great thank you so much!

OK so if they choose not to use OF, will the score/achievement still get posted to Game Center without calling any other OF functions? How does that work?

Thanks for the help. [import]uid: 8139 topic_id: 7095 reply_id: 44875[/import]