I’m using a slightly modified version of the safeopenfeint.lua module:
[lua]–[[
Name: safeopenfeint.lua
Author: Stuart Carnie, Manomio
Description: Safely wraps the openfeint module, which currently does not work on Corona Sim, Android and iPhone Simulator, preventing crashes or hanging apps
Change log:
20100815 - Initial release
–]]
module(…, package.seeall)
local isiPhoneSim = system.getInfo(“name”) == “iPhone Simulator”
local isiOS = system.getInfo(“platformName”) == “iPhone OS”
local isCorona = system.getInfo(“environment”) == “simulator”
local isOFSupported = not isiPhoneSim and isiOS and not isCorona
if isOFSupported then
local openfeint = require “openfeint”
end
function isSupported()
return isOFSupported
end
function init(productKey, productSecret, displayName)
if not isOFSupported then return end
openfeint.init(productKey, productSecret, displayName)
end
function launchDashboard()
if not isOFSupported then return end
openfeint.launchDashboard(“leaderboards”)
end
function launchDashboardWithAchievements()
if not isOFSupported then return end
openfeint.launchDashboard(“achievements”)
end
function setHighScore( lbID, points )
if not isOFSupported then return end
local id = lbID
local scr = points
openfeint.setHighScore( { leaderboardID=id, score=scr } )
end
function unlockAchievement( achievementId )
if not isOFSupported then return end
local aID = achievementId
openfeint.unlockAchievement( aID )
end[/lua]
And the following calls in button functions or score checks for achievements:
[lua] safeopenfeint.launchDashboard()
–and
safeopenfeint.launchDashboardWithAchievements()
–and
safeopenfeint.setHighScore( lbID, points )
– and
safeopenfeint.unlockAchievement( “xxxxxx” )
— and early in the main file
safeopenfeint.init(“secretxxx”, “secretyyy”, “appName”)
local lbID = “xxxxxx”[/lua] [import]uid: 1560 topic_id: 3642 reply_id: 11184[/import]