carefully place items

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

carefully place items

Post by THOM »

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?
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
Phitt
Posts: 442
Joined: Tue Aug 14, 2012 9:43 am

Re: carefully place items

Post by Phitt »

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.
Batty
Posts: 509
Joined: Sun Apr 15, 2012 7:04 pm

Re: carefully place items

Post by Batty »

Here's a simple script to adjust world position of objects:

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
Calling the function:

Code: Select all

move('rock_1', 0.3, 0, -.08)
Here's a guide to positioning, I think it's correct...
Image
Post Reply