我的日志消息有问题,无法解决



所以我试图开发一个可以显示字符串和日志的消息,但奇怪的是,日志只显示最后一个字符串,而不显示1个消息中的事件。有人能帮忙吗?

function printToLog(string, log)
if logPage.fromMainMenu == false then             
popupPage = logPage 
else              
logPage.fromMainMenu = true
popupPage = logPage             
end

prepareMenuPage(popupPage)
local areYouSureText = getItemByName(logPage.items, "logText")
setFont(areYouSureText.font)
if log ~= true then
areYouSureText.logText = string
_G.table.insert(g_printLogList, string) -- insert string into log
print(string)
else
for i = 1, #g_printLogList do
areYouSureText.logText = g_printLogList[i]
end
end
end  

如果不看到表构造、输入值、预期内容,或者至少是解释,很难进行调试,但我会尝试的。

这让我很困惑

if logPage.fromMainMenu == false then
popupPage = logPage 
else                            --  if it isn't false...
logPage.fromMainMenu = true  --  then it's already true.  no need to set it true here
popupPage = logPage             
end

我想知道这是否意味着的评论

if logPage.fromMainMenu == false then             
popupPage = logPage 
else  --  logPage.fromMainMenu = true
popupPage = logPage             
end

但是,如果是这样的话,你就不需要如果……否则——他们也在做同样的事情。也许你是想把它的价值转换成另一个?

if logPage.fromMainMenu == false then          
logPage.fromMainMenu = true
end
popupPage = logPage 

无论哪种方式,我认为现在发生的情况是,每次循环时,您都areYouSureText.logText的整个内容替换为g_printLogList[i]的一个条目。实际上,您要做的是在每个循环中用g_printLogList[i]附加areYouSureText.logText

for i = 1, #g_printLogList do
areYouSureText.logText[ #areYouSureText.logText +1 ] = g_printLogList[i]
end

编辑:

相同的区别,只是用串联来附加文本。。

areYouSureText.logText = areYouSureText.logText ..'n' ..g_printLogList[i]

相关内容

最新更新