Page 1 of 1

[SOLVED] setWorldPosition: Can't Interact w/ Buttons ...

Posted: Mon Nov 03, 2014 1:32 am
by Lark
I'm writing a parameter-based script to place multiple buttons/levers on a wall and things were going well until I discovered that I can't interact with buttons or levers that have been placed with setWorldPosition on the north and east walls. The full script takes rotation into account, but here is a simple one to demonstrate my problem. It places four levers in the same square with the script all facing in and kicks the levers to the side with setWorldPosition. I can only flip levers on the south and west walls. Why? Is this broken for others too? Puts a kink in my scripts - the buttons/levers look nice, easy to place, but are useless. :( I searched the forums, but no luck so far. Thanks, -Lark

Code: Select all

for i = 0, 3 do
  ctl = spawn("lever", self.go.level, self.go.x, self.go.y, i, self.go.elevation, self.go.id .."_lever_"..i)
  pos = ctl:getWorldPosition()
  j = i % 2 * 2 + 1
  pos[j] = pos[j] + .4
  ctl:setWorldPosition(pos)
  end

Re: setWorldPosition: Can't Interact w/ Buttons & Levers?

Posted: Mon Nov 03, 2014 1:36 am
by Prozail
I had the problem when putting them next to an alcove. That is why i put them on the pillar in my dungeonshop-thingy

Re: setWorldPosition: Can't Interact w/ Buttons & Levers?

Posted: Mon Nov 03, 2014 1:51 am
by Blichew
I had the same problem when I moved stuff with setWorldPosition manually (levers and switches). Trick here was that 3rd param (or other one maybe ? Depends on the facing? I guess for me it always has been 3rd one) had to be lowered by 0.0001 or something. It's moved in front of the wall but the value is so small that the differenct is basically unnoticable.

Check if with console: print(entity:getWorldPosition()) and then experiment with setWorldPosition :)

Re: setWorldPosition: Can't Interact w/ Buttons & Levers?

Posted: Mon Nov 03, 2014 2:51 am
by Jackard
setWorldPosition parameters seem to be X, Z, Y, ?

You can only interact with one object at a time - I had a button behind a ladder, would not work until I moved it away from both the ladder and the wall.

Re: setWorldPosition: Can't Interact w/ Buttons & Leve

Posted: Mon Nov 03, 2014 5:43 am
by Lark
Blichew wrote:... had to be lowered by 0.0001 or something.
Thank you Blichew! That's exactly the hint I needed. Even if you get use getWorldPosition and immediately call setWorldPosition with the unaltered vector returned from the get, the buttons are slightly behind the walls. The adjustment did the trick, so I'm back on course. Thank you! -Lark