[18/03/2010 23:22:45] [Error - Action Interface]
[18/03/2010 23:22:45] data/actions/scripts/demonOak.luanUse
[18/03/2010 23:22:45] Description:
[18/03/2010 23:22:45] data/lib/position.lua:2: attempt to index global 'pos' (a nil value)
[18/03/2010 23:22:45] stack traceback:
[18/03/2010 23:22:45] data/lib/position.lua:2: in function 'isInRange'
[18/03/2010 23:22:45] data/actions/scripts/demonOak.lua:54: in function <data/actions/scripts/demonOak.lua:1>
I try to fix position.lua, but it don't work.
Help me please!
go to data/lib/position.lua
and change "isInRange(pos, fromPosition, toPosition)" to "isInRange(position, fromPosition, toPosition)"
function isInRange(pos, fromPosition, toPosition)
return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
function getDistanceBetween(firstPosition, secondPosition)
local x, y = math.abs(firstPosition.x - secondPosition.x), math.abs(firstPosition.y - secondPosition.y)
local diff = math.max(x, y)
if(firstPosition.z ~= secondPosition.z) then
diff = diff + 9 + 6
end
return diff
end
function getDirectionTo(pos1, pos2)
local dir = NORTH
if(pos1.x > pos2.x) then
dir = WEST
if(pos1.y > pos2.y) then
dir = NORTHWEST
elseif(pos1.y < pos2.y) then
dir = SOUTHWEST
end
elseif(pos1.x < pos2.x) then
dir = EAST
if(pos1.y > pos2.y) then
dir = NORTHEAST
elseif(pos1.y < pos2.y) then
dir = SOUTHEAST
end
else
if(pos1.y > pos2.y) then
dir = NORTH
elseif(pos1.y < pos2.y) then
dir = SOUTH
end
end
return dir
end
function getCreatureLookPosition(cid)
return getPosByDir(getThingPos(cid), getCreatureLookDirection(cid))
end
function getPosByDir(fromPosition, direction, size)
local n = size or 1
local pos = fromPosition
if(direction == NORTH) then
pos.y = pos.y - n
elseif(direction == SOUTH) then
pos.y = pos.y + n
elseif(direction == WEST) then
pos.x = pos.x - n
elseif(direction == EAST) then
pos.x = pos.x + n
elseif(direction == NORTHWEST) then
pos.y = pos.y - n
pos.x = pos.x - n
elseif(direction == NORTHEAST) then
pos.y = pos.y - n
pos.x = pos.x + n
elseif(direction == SOUTHWEST) then
pos.y = pos.y + n
pos.x = pos.x - n
elseif(direction == SOUTHEAST) then
pos.y = pos.y + n
pos.x = pos.x + n
end
return pos
end
function doComparePositions(pos, posEx)
return pos.x == posEx.x and pos.y == posEx.y and pos.z == posEx.z
end
function getArea(pos, rangeX, rangeY)
local t = {}
for i = (pos.x - rangeX), (pos.x + rangeX) do
for j = (pos.y - rangeY), (pos.y + rangeY) do
table.insert(t, {x = i, y = j, z = pos.z})
end
end
return t
end
Where i replace it?
PHP:function isInRange(pos, fromPosition, toPosition) return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z) end function getDistanceBetween(firstPosition, secondPosition) local x, y = math.abs(firstPosition.x - secondPosition.x), math.abs(firstPosition.y - secondPosition.y) local diff = math.max(x, y) if(firstPosition.z ~= secondPosition.z) then diff = diff + 9 + 6 end return diff end function getDirectionTo(pos1, pos2) local dir = NORTH if(pos1.x > pos2.x) then dir = WEST if(pos1.y > pos2.y) then dir = NORTHWEST elseif(pos1.y < pos2.y) then dir = SOUTHWEST end elseif(pos1.x < pos2.x) then dir = EAST if(pos1.y > pos2.y) then dir = NORTHEAST elseif(pos1.y < pos2.y) then dir = SOUTHEAST end else if(pos1.y > pos2.y) then dir = NORTH elseif(pos1.y < pos2.y) then dir = SOUTH end end return dir end function getCreatureLookPosition(cid) return getPosByDir(getThingPos(cid), getCreatureLookDirection(cid)) end function getPosByDir(fromPosition, direction, size) local n = size or 1 local pos = fromPosition if(direction == NORTH) then pos.y = pos.y - n elseif(direction == SOUTH) then pos.y = pos.y + n elseif(direction == WEST) then pos.x = pos.x - n elseif(direction == EAST) then pos.x = pos.x + n elseif(direction == NORTHWEST) then pos.y = pos.y - n pos.x = pos.x - n elseif(direction == NORTHEAST) then pos.y = pos.y - n pos.x = pos.x + n elseif(direction == SOUTHWEST) then pos.y = pos.y + n pos.x = pos.x - n elseif(direction == SOUTHEAST) then pos.y = pos.y + n pos.x = pos.x + n end return pos end function doComparePositions(pos, posEx) return pos.x == posEx.x and pos.y == posEx.y and pos.z == posEx.z end function getArea(pos, rangeX, rangeY) local t = {} for i = (pos.x - rangeX), (pos.x + rangeX) do for j = (pos.y - rangeY), (pos.y + rangeY) do table.insert(t, {x = i, y = j, z = pos.z}) end end return t end
function isInRange(pos, fromPosition, toPosition)
return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
function isInRange(position, fromPosition, toPosition)
return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
take it out from a rl map distro, there are hundreds @ downloadseace:and map?
function onUse(cid, item, fromPosition, itemEx, toPosition)
local position = {x=xxxxx, y=xxxxx, z=x} -- reward room
if getPlayerStorageValue(cid, 35700) == 1 then
doTeleportThing(cid, position)
doSendMagicEffect(position, CONST_ME_TELEPORT)
else
return false
end
return true
end
:huh:huh? it was bugged? works fine for me the original onefixed grave stone.,.Code:function onUse(cid, item, fromPosition, itemEx, toPosition) local position = {x=xxxxx, y=xxxxx, z=x} -- reward room if getPlayerStorageValue(cid, 35700) == 1 then doTeleportThing(cid, position) doSendMagicEffect(position, CONST_ME_TELEPORT) else return false end return true end
When I use the axe on the tree, the tree dissapear :S