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

Discussion about Mods for Prison Architect

Moderator: NBJeff

grandsong
level0
Posts: 7
Joined: Sun Oct 09, 2016 10:02 am

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

Postby grandsong » Tue Nov 01, 2016 7:24 am

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.
murgh
level2
level2
Posts: 228
Joined: Sat Jan 30, 2016 11:52 am

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

Postby murgh » Thu Dec 08, 2016 12:57 pm

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

...works fine in my basketball script, but perhaps you found some exotic situations where this won't work? Got any examples?
grandsong
level0
Posts: 7
Joined: Sun Oct 09, 2016 10:02 am

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

Postby grandsong » Sat Dec 31, 2016 3:32 pm

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.

Return to “Modding”

Who is online

Users browsing this forum: No registered users and 3 guests