尝试索引本地(数字值)

时间:2018-06-30 17:31:22

标签: lua pico-8

抱歉,这个问题很愚蠢,但是我是编程新手。
在运行此代码时,我收到错误消息:attempt to index local (a number value)
这部分代码!

function simple_haunt_ai(mon,m) --constructor
    if m.typ=="walker" then
        for m in all(mon) do
            if m.y>97 then m.y-=m.spd*2
            else
                if pl.x>m.x then m.x+=m.spd;m.f=false end 
                if pl.x<m.x then m.x-=m.spd;m.f=true end
            end
        end
    elseif m.typ=="jumper" then
        for m in all(mon) do
            if m.y>97 then m.y-=m.spd*4
            else
                if pl.x<m.x then
                    if m.grav then
                        m.ang=0.4
                        m.x-=m.spd*3
                        m.y+=sin(m.ang)+m.spd
                        if m.y<92 then m.grav=false end
                    elseif not m.grav then
                        m.y-=sin(m.ang)+m.spd       
                        if m.y>97 then m.grav=true end
                    end
                end
                if pl.x>m.x then
                    if m.grav then
                        m.ang=0.1
                        m.x+=m.spd*3
                        m.y+=sin(m.ang)+m.spd
                        if (m.y<92) m.grav=false
                    elseif not m.grav then
                        m.y-=sin(m.ang)+m.spd       
                        if (m.y>97) m.grav=true
                    end
                end 
            end
        end
    end
end

致电

simple_haunt_ai(slimes,s)

slimes-所有对象史莱姆表

slimes={}

s-参数

s={x=rnd(124),y=104,ang=0,f=0,
spd=0.25,t=0,sprt=16,atk=1,type="walker",
hp=1,box={x1=1,y1=5,x2=6,y2=7}}

0 个答案:

没有答案
相关问题