I try to place an item very precice in my mod.
I've seen, that the Devs used for the same trick in the Library a command, that I am unfamiliar with:
torch_1:setWorldPosition(vec(53.00, 0.9, 44.5))
But I cannot figure out, what the numbers mean. Maybe (x, hight, y) But they seem to place my torch just in bigger steps - and I couldn't get it up.
Any help?
carefully place items
Re: carefully place items
Apparently setWorldPosition uses the position in game units starting from the lower left corner (x 0, y 31). And it uses the standard coordinate system, x, height, y. Each tile is 3x3 units/metres. To get the exact position of your object you can use getWorldPosition and print the values to the console.
Re: carefully place items
Here's a simple script to adjust world position of objects:
Calling the function:
Here's a guide to positioning, I think it's correct...

Code: Select all
function move(entity, x, y, z)
if findEntity(entity) then
local coord = findEntity(entity):getWorldPosition()
if x then coord[1] = coord[1] + x end
if y then coord[2] = coord[2] + y end
if z then coord[3] = coord[3] + z end
findEntity(entity):setWorldPosition(coord)
print(findEntity(entity).name..' '..entity..' moved: '..iff(not x, 0, x)..', '..iff(not y, 0, y)..', '..iff(not z, 0, z))
else
print('no such entity: '..entity)
end
end
Code: Select all
move('rock_1', 0.3, 0, -.08)
