Page 1 of 1

[BUG] Object.Pos or .Or is changed but image doesn't

Posted: Tue Nov 01, 2016 7:24 am
by grandsong
Priority: Middle

I am working on moving and rotating objects by lua script.

`Object.Pos` and `.Or` works well when the object is an entity like Guard, Prisoner.

But when it is a fixture like Toilet, Bed, Cooker, sometimes a bug occurs.

At certain positions, after I change `Object.Pos` and `.Or`, the image (display) of that object will stay unchanged while I am 100% sure that the new Pos or Or are valid.

This bothers me greatly and I have tried hard to find workarounds.

Yes, I succeeded, mostly, but when the remaining bug happens, it is really frustrating to a player.

I hope this bug can be fixed.


In case someone wants to know about my workarounds.

I spawn a new object after moving the target one. The new one is set with the same .Pos, .Or, .OpenDir, .Door (for Servo).

The new one is always correct in display.

But the connections (like Servo, Cctv), loading other objects (like Table, DogCrate), etc will be lost for I don't see APIs to get/set these.

About rotating, I can keep the target object and make it face the right direction of south or north if I set Or.y as 2 or -2 instead of 1 or -1.

Very tricky. And still have problems sometimes.

Re: [BUG] Object.Pos or .Or is changed but image doesn't

Posted: Thu Dec 08, 2016 12:57 pm
by murgh
Setting only Or.x or Or.y isn't enough sometimes, I think you need to combine them like this...

Code: Select all

      if this.Or.x==0 and this.Or.y==1 then   -- placed down

      elseif this.Or.x==-1 and this.Or.y==0 then   -- rotated once

      elseif this.Or.x==0 and this.Or.y==-1 then   -- rotated twice

      elseif this.Or.x==1 and this.Or.y==0 then   -- rotated three times fine in my basketball script, but perhaps you found some exotic situations where this won't work? Got any examples?

Re: [BUG] Object.Pos or .Or is changed but image doesn't

Posted: Sat Dec 31, 2016 3:32 pm
by grandsong
Sorry for my reply so late. I had given up hope for this forum.

Yes, it was your basket ball mod from which I learnt a lot, including orientations.

I always set both x and y. And they work well for most objects in most positions (tiles). But there are weird bugs as I described.

Recently, I managed to minimize the chance of these bugs to occur. No longer a big deal.

But I hope dev team read this and fix the bug thoroughly in their C codes.