Ok, so I initiazlied in the main.lua all the open feint stuff I need. And then in the menu system I did what I had to do.
However, when the player wins the game, and gets the winLose function. I want to unlock the achievement.
I’m not requiring OpenFeint so far, and only have this little bit of code. Is this gonna suffice?
Or do I have to do, Local require openfeint = (“openfeint”)
and then put the coding in the winLose function?
Let me know. Take a look at this coding, and let me know what you think.
local function winLose(condition)
if(condition == "win") then
display\_txt.text = "WIN!";
win.isVisible = true
win.isBodyActive = true
openfeint.unlockAchievement ( 842812 )
[import]uid: 19768 topic_id: 7230 reply_id: 307230[/import]
Also, that’s just the little piece of coding that the winLose function has regarding the openfeint function. So that’s not all of it. That’s just the win part. [import]uid: 19768 topic_id: 7230 reply_id: 25411[/import]
do I have to do, Local require openfeint = (“openfeint”)
Yes you have to require() openfeint before using it in your code. Put the require() statement at the top, not inside your function. Also that is incorrect syntax; it should be
local openfeint = require("openfeint")
[import]uid: 12108 topic_id: 7230 reply_id: 25420[/import]
Ok great thanks for the answer JHocking. Good thing I asked about that in the early levels. I would’ve had to go back and update all 100 of them. But now I only have to do the first 5, since that’s where I stopped to ask the question. Thanks for the answer
[import]uid: 19768 topic_id: 7230 reply_id: 25438[/import]
I would refactor your code so that the winLose() function is shared by all of your levels. You shouldn’t have a separate function for each level since presumably they are all doing the same thing; write the function once and then use it in all of your levels. [import]uid: 12108 topic_id: 7230 reply_id: 25440[/import]
Yea that’s what I’m doing. I just have to change the variable of the OpenFeint Achievement ID Number. That’s the only different thing for each level. [import]uid: 19768 topic_id: 7230 reply_id: 25446[/import]