Object state getting changed without my intervention

Started by Laura Hunt, Fri 22/11/2019 12:29:11

Previous topic - Next topic

Laura Hunt

Hey, here I am with another headscratcher. I'm aware that there's probably no other way to see what's happening here other than looking at my code, but I will try to explain my issue in painstaking detail to see if there's anything I might be missing.

I have the following room in my game: (don't click the tags if you're interested in playing it when it comes out and don't want to be spoiled!)

Spoiler
[imgzoom]https://s.put.re/hg462Gss.png[/imgzoom]
[close]

Spoiler
[imgzoom]https://s.put.re/zgEiLVae.png[/imgzoom]
[close]

And there's also a sort of day/night cycle (seen here without any items because it's the only shot I have at hand).

Spoiler
[imgzoom]https://s.put.re/fU1LEdWY.png[/imgzoom]
[close]

Instead of letting AGS manage the scrolling, the viewport is fixed. When the player crosses over from one half of the room to the other, the backgrounds crossfade and the viewport tweens over to reposition itself. Objects that were active fade into their "shadow" or inactive versions, and inactive objects are swapped for their active versions. (For reference, see this thread.)

This works perfectly in all cases: I can go from the left side to the right side of the room and viceversa, and all objects will fade in and out and become clickable or disabled as expected. I can click on the door to the right to go to room 4 (bedroom) and come back, and everything keeps working. I can go downstairs to room 6 (parlour) and back, no problem. I can go into the bedroom again, switch from night to day, and everything still works.

BUT if I switch from night to day in room 6 downstairs and then come back up here, those three statues have disappeared and their inactive/shadow versions are showing instead.

The first thing I did was figure out what exactly "disappearing" meant here: whether the statues were being set to invisible, or if the sprite was being "unassigned", or what. Turns out, what's happening is that the active statues are being set to 100 transparency and set as non-clickable. In other words, it's exactly what happens if you cross from the left side of the room to the right.

But this doesn't make sense because:

- I exited the room through the stairs on the left in order to get to room 6. This means the statues were active when I exited the room. As far as I know, if an object is clickable when I leave the room, it should still be clickable when I go back. It's as if these objects were losing their last saved state for some reason.

- "So are you setting these statues to clickable/unclickable on room_Load or what?". Nope. The ONLY code in my whole game that sets these statues to non-clickable and transparent is contained in the region_WalksOn functions that control the crossfade between both halves of the room. There is literally no other call to oStatue1., oStatue2. or oStatue3.Transparency in the whole game.


The only clue I have been able to come up with is that room 6 has a region 14 and region 15, and these regions are also the ones that trigger the crossfade in room 5 when the player walks over them. So maybe it was a bug and regions being triggered in a room were also affecting stuff in another rooms? Also no. I removed regions 14 and 15 from room 6 and the issue is still there.

My other working hypothesis right now is that AGS can sometimes have issues when you have multiple entities with long similar/almost identical names that differ in e.g., a number. I had some trouble in the past with invisiblecharacter1 and invisiblecharacter2 which went away when I renamed the latter to dummychar1, so maybe something weird is going on here between oStatue1, oStatue1Covered, oStatue1GreyedOut and oStatue1CoveredGreyed? Is AGS getting confused? Senile? Does this even make sense?

I have managed to work around this issue by simply setting the objects' clickability, transparency, etc at room load, but having no idea what might be causing this is extremely frustrating because it means it could happen again anytime. I'm at my wits' end here. Any help or ideas where I could poke around next would be greatly appreciated.


Laura Hunt

Figured it out.

I was going from left to right during daytime, thus disabling the statues. Then I would switch to night in the bedroom, cross the corridor in the "night" state and go downstairs, so the statues never got a chance to be restored. Thus, when I switched to day downstairs and came back up again, the statues were still disabled from the previous "day" loop.

I'm kind of mad at myself for not figuring it out before dumping this incomprehensible mess here, but I like to think that putting it into words, writing it down and having to explain it actually helped me find the answer, so hopefully this post hasn't been a waste of everybody's time :P

eri0o

Ah, I do that all the time, write a long munch of text and later figure out while writing. Sometimes I do this by talking to random people about a problem. The need to explain often helps to ... Explain the problem. Which requires understanding better. It's cool you figured out. I like the screenshots :)

Laura Hunt

Quote from: eri0o on Fri 22/11/2019 15:37:20
Ah, I do that all the time, write a long munch of text and later figure out while writing. Sometimes I do this by talking to random people about a problem. The need to explain often helps to ... Explain the problem. Which requires understanding better. It's cool you figured out.

Yes, definitely! It also happens while I'm writing work emails sometimes... I'll start writing something like "Hey I'm sorry but I can't help you. I think the problem might be that X is not configured properly and then ah wait hold on but that means that Y... hmmm" and I'll end up rewriting the whole email as I go through all the steps in my head. Something that starts with a "no idea, shrug" draft could end up with a final version saying "yeah sure, fixed" :-D

Quote from: eri0o on Fri 22/11/2019 15:37:20
I like the screenshots :)

Thank you! ;-D They're a bit spoilery though, so I'm going to hide them under a few tags!


SMF spam blocked by CleanTalk