here, this moves moving objects on the map like this one (simple elevator going up-down):
<object id="testobject" model="3115" interior="0" dimension="0" posX="3446.6684570313" posY="-1914.6517333984" posZ="1.2000885009766" rotX="0" rotY="0" rotZ="0" moving="true" movTime="5000" movX="3446.6684570313" movY="-1914.6517333984" movZ="13.75008392334" />
function moveTo(obj, movX, movY, movZ, movTime, posX, posY, posZ)
local x, y, z = getElementPosition(obj)
if (tostring(z) ~= tostring(movZ)) or (tostring(y) ~= tostring(movY)) or (tostring(x) ~= tostring(movX)) then
moveObject(obj, movTime, movX, movY, movZ)
else
moveObject(obj, movTime, posX, posY, posZ)
end
end
addCommandHandler("movetest",
function ()
for key,obj in ipairs(getElementsByType("object")) do
if getElementData(obj, "moving") then
local posX = getElementData(obj, "posX")
local posY = getElementData(obj, "posY")
local posZ = getElementData(obj, "posZ")
local movX = getElementData(obj, "movX")
local movY = getElementData(obj, "movY")
local movZ = getElementData(obj, "movZ")
local movTime = getElementData(obj, "movTime")
moveTo(obj, movX, movY, movZ, movTime, posX, posY, posZ)
setTimer(moveTo, movTime+1000, 0, obj, movX, movY, movZ, movTime, posX, posY, posZ)
end
end
end
)
i had to put tostring() in moveTo function, cause for some reason Lua thinks 13.75008392334 never equal 13.75008392334, even if z and movZ are the same number
and i've tried tonumber() everything, still the same. ofc maybe i was just missing something there.