Tou com esse erro aí ao iniciar o evento...
Vou deixar o rep+ caso alguém ajude ^^
Erro:
[Error - Action Interface]
data/actions/scripts/snakesys.lua:onUse
Description:
data/lib/snakesys.lua:69: attempt to index local 'p2' (a number value)
stack traceback:
data/lib/snakesys.lua:69: in function 'samepos'
data/lib/snakesys.lua:56: in function 'timer'
Script:
Spoiler
SNAKE ={
_VERSION="1.0",
itemid=1739,
freeglobalstorage=28103,
itemFood=6394,
controlpos={x=1024,y=1062,z=12},
exitpos ={x=1023,y=1053,z=13},
centerpos={x=1023,y=1061,z=13},
timer =function(cid,n,pos_,time)local pos_ = pos_ or{{SNAKE.centerpos}}
setGlobalStorageValue(SNAKE.freeglobalstorage,cid)ifnot isPlayer(cid)then
SNAKE.clean()returnendfor i,pos in pairs(pos_)do
SNAKE.find_and_delete(pos[1])if i ==1then
pos[2]= SNAKE.copypos(pos[1])
pos[1]= getPosByDir({x=pos[1].x,y=pos[1].y,z=pos[1].z,stackpos=255},getCreatureLookDir(cid))else
pos[2]= SNAKE.copypos(pos[1])
pos[1]= pos_[i-1][2]endlocal ret,p,walk = SNAKE.check(pos[1])if ret ==1or ret ==3then
addEvent(doTeleportThing,1000,cid,SNAKE.exitpos)
addEvent(doCreatureSay,1100,cid,'Points '..(#pos_-1)..'.')
SNAKE.clean()
setGlobalStorageValue(SNAKE.freeglobalstorage,0)returnendif ret ==2then
doRemoveItem(p.uid,-1)if p.itemid == SNAKE.itemFood then
pos_[#pos_+1]={pos[2],pos[2]}for i=1,5do
addEvent(doSendMagicEffect,100*i,pos[1],29)end
SNAKE.generateFood()endend
doCreateItem(SNAKE.itemid,1,pos[1])endlocal plpos = getCreaturePosition(cid)local generated ={}for i=0,3do
generated = getPosByDir({x=SNAKE.controlpos.x,y=SNAKE.controlpos.y,z=SNAKE.controlpos.z},i)endfor i,pos in pairs(generated)doif SNAKE.samepos(plpos,pos)then
doTeleportThing(cid,SNAKE.controlpos,false)end
addEvent(doSendMagicEffect,100,pos,56,cid)end
addEvent(SNAKE.timer,time,cid,n,pos_,time)end,
copypos =function(p)return{x=p.x,y=p.y,z=p.z,stackpos=p.stackpos}end,
samepos =function(p1,p2)if p1.x == p2.x and p1.y == p2.y thenreturntrueendreturnfalseend,
generateFood =function()local pp ={x=SNAKE.centerpos.x+math.random(-6,6),y=SNAKE.centerpos.y+math.random(-4,4),z=SNAKE.centerpos.z}for i=1,5do
addEvent(doSendMagicEffect,100*i,pp,30)end
doCreateItem(SNAKE.itemFood,1,pp)end,
clean =function()for y=-4,4dofor x=-6,6dolocal pp ={x=SNAKE.centerpos.x+x,y=SNAKE.centerpos.y+y,z=SNAKE.centerpos.z}for i=250,255do
pp.stackpos = i
local p = getThingFromPos(pp)if p.itemid ~=0then
doRemoveItem(p.uid,-1)
doSendMagicEffect(pp,15)endendendendend,
check =function(pos)for i=1,10do
pos.stackpos = i
local p = getThingFromPos(pos)if p.itemid == SNAKE.itemid thenreturn1,p,trueelseifnot SNAKE.isWalkable(pos)thenreturn3,p,falseelseif p.itemid ~=0thenreturn2,p
endendreturnfalseend,
find_and_delete =function(pos)for i=0,255do
pos.stackpos =255-i
local p = getThingFromPos(pos)if p.itemid == SNAKE.itemid thenreturn doRemoveItem(p.uid,1)endendend,
isWalkable =function(pos, creature, proj, pz)-- by Nordif getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos =0}).itemid ==0thenreturnfalseendif getTopCreature(pos).uid >0and creature thenreturnfalseendif getTileInfo(pos).protection and pz thenreturnfalse,trueendlocal n =not proj and3or2for i =0,255do
pos.stackpos = i
local tile = getTileThingByPos(pos)if tile.itemid ~=0andnot isCreature(tile.uid)thenif hasProperty(tile.uid, n)or hasProperty(tile.uid,7)thenreturnfalseendendendreturntrueend,}
Pergunta
Ayron5 40
Tou com esse erro aí ao iniciar o evento...
Vou deixar o rep+ caso alguém ajude ^^
Erro:
Script:
Alinha que está dando o erro é essa.
Link para o comentário
Compartilhar em outros sites
3 respostass a esta questão
Posts Recomendados