2
不知道有人曾经遇到过这种问题。这里是我的代码lua:将参数传递给其他功能问题
在main.lua:
local highScore = require("highScore")
local username = "myName"
local finishedTime = 12345
highScore:InsertHighScore(userName, finishedTime)
在highScore.lua
function InsertHighScore(name,time)
print(name)
print(time)
-- other code
end
它看起来简单,不应该是错的,但在我的控制台出来把它显示:
table: 0x19e6340
myName
经过一天的测试,我发现在我通过的2个参数之前,它实际上将另一个表传递给我,所以,这些变化对highScore.lua:
function InsertHighScore(table,name,time)
print(table)
print(name)
print(time)
-- other code
end
所以现在我的“其他代码”可以很好地工作,但为什么我的参数之前传给我的表?
确定...所以现在我看到的问题,所以点并不意味着它的访问类的参数,而不是调用函数? – FunFair
无论如何,thx为您的快速而干净的回复duskwuff,真的很感谢您的帮助,谢谢=) – FunFair
实际上,访问参数和调用函数是*相同的东西*。 'highScore.InsertHighScore'获得函数作为参数,添加括号调用它。 – duskwuff