Hi,
Lua:
local maxSpeed = 100
local minSpeed = 1000
local creaturePos = {
{x=1048, y=1047, z=7},
{x=1048, y=1049, z=7},
{x=1048, y=1051, z=7},
{x=1048, y=1053, z=7}
}
function onUse(cid, item)
if getGlobalStorageValue(1212) < 1 then
setGlobalStorageValue(1212,1)
setGlobalStorageValue(1211,#creaturePos)
setGlobalStorageValue(12344,0)
for i,v in pairs(creaturePos) do
local c = doSummonCreature("Dog",v)
doPlayerSetNoMove(c, true)
doSendAnimatedText(v,"Let's GO!", math.random(255))
addEvent(moveCreature,math.random(maxSpeed,minSpeed),getCreaturePosition(c),item.actionid-1000)
end
else
doPlayerSendCancel(cid,"Wait until the current race finish.")
end
return false
end
function direcPos(pos,direc)
local p = {
[1] = {x=pos.x,y=(pos.y-1),z=pos.z},
[2] = {x=(pos.x+1),y=pos.y,z=pos.z},
[3] = {x=pos.x,y=(pos.y+1),z=pos.z},
[4] = {x=(pos.x-1),y=pos.y,z=pos.z}
}
return p[direc]
end
function moveCreature(pos,direc)
pos.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
local topos = direcPos(pos,direc)
local creature = getThingFromPos(pos).uid
if creature ~= 0 then
doTeleportThing(creature,topos,true,true)
addEvent(moveCreature,math.random(maxSpeed,minSpeed),topos,direc)
end
return true
end
Code:
[14:21:26.843] [Error - Action Interface]
[14:21:26.843] In a timer event called from:
[14:21:26.843] data/actions/scripts/race.lua:onUse
[14:21:26.843] Description:
[14:21:26.843] data/actions/scripts/race.lua:45: attempt to index local 'pos' (a
boolean value)
[14:21:26.843] stack traceback:
[14:21:26.843] data/actions/scripts/race.lua:45: in function <data/actions/scri
pts/race.lua:44>