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.
[BUG] Object.Pos or .Or is changed but image doesn't
Moderator: NBJeff
Re: [BUG] Object.Pos or .Or is changed but image doesn't
Setting only Or.x or Or.y isn't enough sometimes, I think you need to combine them like this...
...works fine in my basketball script, but perhaps you found some exotic situations where this won't work? Got any examples?
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
...works 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
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.
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.
Who is online
Users browsing this forum: No registered users and 16 guests