Nottinghster
Tibia World RPG Developer
- Joined
- Oct 24, 2007
- Messages
- 1,570
- Solutions
- 6
- Reaction score
- 437
- Location
- Brazil - Rio de Janeiro
- GitHub
- Nottinghster
Hello OTLanders!
I need a little help, since I'm not so familiar with TFS 1.x (first time using) and I always used OTServ_SVN 0.6.4.
Can someone help me converting those functions to TFS 1.3? @Nekiro @Evil Puncker @celohere @M0ustafa @Znote
Thanks a lot!
I need a little help, since I'm not so familiar with TFS 1.x (first time using) and I always used OTServ_SVN 0.6.4.
Can someone help me converting those functions to TFS 1.3? @Nekiro @Evil Puncker @celohere @M0ustafa @Znote
Thanks a lot!
Lua:
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
Lua:
function isPosition(pos)
local validPositionKeys = {"x", "y", "z", "stackpos"}
local keyAmount = 0
if (type(pos) == "table") then
for key, val in pairs(pos) do
if(not table.find(validPositionKeys, key) or not isNumber(val)) then
return false
end
keyAmount = keyAmount + 1
end
if (keyAmount ~= 3 and keyAmount ~= 4) then
return false
end
return true
end
return false
end
Lua:
function doTeleportPlayersFromArea(fromPos, toPos, newPos)
if(not (isPosition(fromPos) and isPosition(toPos))) then
return false, error("luaDoTeleportPlayersFromArea: Invalid position!", 2)
end
for _, cid in ipairs(getOnlinePlayers()) do
local pos = getCreaturePosition(cid)
if(isInRange(pos, fromPos, toPos)) then
doTeleportThing(cid, newPos)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
end
end
return true
end
Lua:
function tileArea(fromPos, toPos, stack)
local pos = {x=fromPos.x, y=fromPos.y-1, z=fromPos.z}
return function()
if (pos.y < toPos.y) then
pos.y = pos.y+1
elseif (pos.x <= toPos.x) then
pos.y = fromPos.y
pos.x = pos.x+1
else
pos.x = fromPos.x
pos.y = fromPos.y
pos.z = pos.z+1
end
if (pos.x <= toPos.x and pos.y <= toPos.y or pos.z < toPos.z) then
if (stack == nil) then
return pos
else
pos.stackpos = stack
return pos, getTileThingByPos(pos)
end
end
end
end
Lua:
function doCleanFields(frompos, topos)
for pos, thing in tileArea(frompos, topos, 0) do
if thing.uid ~= 0 then
pos.stackpos = STACKPOS_TOP_FIELD
while getThingfromPos(pos).itemid > 0 do
doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
doRemoveItem(getThingfromPos(pos).uid, 1)
end
end
end
end
Last edited: