2013-02-25 53 views
0

当我尝试发布比分至Facebook,我得到这个错误:比分后向Facebook运行时错误

运行时错误... \ main.lua:22:试图调用全球“分数”(一个数字值) 栈回溯: [C]:在函数“分数”

而且我真的不明白为什么它不工作。 完整的代码是:

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) 

任何解决方案?

置后 score
+0

这是你的'main.lua'吗?如果是的话,会出现问题,因为第22行没有任何名为'score'的变量。该行是'actions = json.encode({name =“Name”,link =“http://www.site.com”})' – hjpotter92 2013-02-25 21:01:12

回答

0

消息= “我只是实现了” .. ..比分 “玩名称....免费下载iPhone &的Android在www.site”,

3
message = "I just achieved ".. score" playing Name.... download for FREE iPhone & Android at www.site", 

错过