Lua TIC-80有问题吗
嗨!我试图做一个简单的TIC-80(基本上是lüa)脚本,但我得到了一个错误 添加LastFace()函数后开始出现错误。老实说,我知道我做错了什么 代码如下:Lua TIC-80有问题吗,lua,Lua,嗨!我试图做一个简单的TIC-80(基本上是lüa)脚本,但我得到了一个错误 添加LastFace()函数后开始出现错误。老实说,我知道我做错了什么 代码如下: --width and height vars w=240 h=136 -- Last faced var lf='r' --Player X and Y, W, H, ID vars p = { id=0, x=w/2, y=h/2, w=16, h=16, draw = function() spr(p.id, p.x,
--width and height vars
w=240
h=136
-- Last faced var
lf='r'
--Player X and Y, W, H, ID vars
p = {
id=0,
x=w/2,
y=h/2,
w=16,
h=16,
draw = function()
spr(p.id, p.x, p.y, 1, 1)
end
}
--movement function here
function lastfaced()
if btn(2) then
lf='l'
elseif btn(3) then
lf='r'
elseif lf="l" then
p.id=4
elseif lf="r" then
p.id=0
end
end
function TIC()
cls(12)
move()
p.draw()
lastfaced()
end
下面是错误:
[string "..."]:49: 'then' expected near '='
有人能帮忙吗?Ehm,当你想比较时,你必须使用==使其工作,一个=将不工作
function lastfaced()
if btn(2) then
lf='l'
elseif btn(3) then
lf='r'
elseif lf="l" then
p.id==4
elseif lf=="r" then
p.id=0
end
end
哦,对了。谢谢
如果lf==“l”,那么p.id=4
此时不要使用secondelseif
,屏幕需要额外的游戏循环才能更新。