スコアを Facebook に投稿しようとすると、次のエラーが表示されます。
ランタイム エラー ...\main.lua:22: グローバル 'score' (数値) スタック トレースバックを呼び出そうとしています: [C]: 関数 'score' 内
そして、なぜそれが機能しないのか、私にはよくわかりません。完全なコードは次のとおりです。
local facebook = require ("facebook")
local json = require ("json")
keeping_score = true
score = 1000
keeping_score = true
local scoreText = display.newText( "Score: " .. score, 20, 20,nil, 20)
scoreText:setTextColor(255,255,255)
print("" .. score)
--Facebook function
local faceListener = function (event)
local faceMessage = {
name = "Name",
link = "http://www.site.com",
message = "I just achieved ".. score" playing Name.... download for FREE iPhone & Android at www.site",
caption = "Can you beat my score? ".. score,
description = "Name Full description here, download for FREE iPhone & Android at www.site",
picture = "http://cdn01.androidauthority.com/wp-content/uploads/2011/03/Google-Logo.jpg",
actions = json.encode( { name = "Name", link = "http://www.site.com" } )
}
--Checks for a login and if everything is good then it calls to post the faceMessage.
if event.type == "session" then
if event.phase == "login" then
facebook.request( "me/feed", "POST", faceMessage )
end
end
end
local faceFunc = function ()
facebook.login("appID", faceListener {"publish_stream"} )
end
--Button to activate the post to facebook
local facebutton = display.newRect (0, 0, 50, 50)
facebutton.x = display.contentWidth/2; facebutton.y = display.contentHeight/2
facebutton:addEventListener("tap", faceFunc)
解決策はありますか?