A weird bug when switching characters

Started by Blondbraid, Mon 02/05/2016 22:12:58

Previous topic - Next topic

Blondbraid

Hello!
I have already built my game, but there is still a few bugs. My problem is that the cursor doesn't work in one scene once the player changes character. I used the default two-click system, left mb for interaction, right for examining. My game starts with the player controlling one character, then switches to character two, then back to one and then two again.
It's the second time the script changes to character two that this bug occurs. What happens is that left mouse-button doesn't work, clicking on hotspots and inventory does nothing, until I press the right mouse-button. Nothing happens at first, but then
both the left and right button work normally again. ???

Not a game-breaking bug, but I'd like to fix it if I can. Has anyone had a similar problem or know what can cause it?


Kumpel

Sounds like a situtation, where the game is in hiatus until something specific is done. Is there a cutscene beetween before the character switch?

What do you mean by "but then..."? The left mouse click doesn't work immediately after "unlocking" it?

Maybe you should give us some "switchy switchy, the second time is itchy" code. (nod) (laugh)

Blondbraid

Quote from: Kumpel on Tue 03/05/2016 07:16:44
Sounds like a situtation, where the game is in hiatus until something specific is done. Is there a cutscene beetween before the character switch?

What do you mean by "but then..."? The left mouse click doesn't work immediately after "unlocking" it?

Maybe you should give us some "switchy switchy, the second time is itchy" code. (nod) (laugh)
What happens when I press the left mouse-button is that either nothing happens, or I get the default answer "I can't do that" etcetera instead of the scripted interaction. When I press the right mb the character is supposed to say a comment if the cursor is over a hotspot, but no such thing happens if i click on a hotspot or inventory item. But once I've pressed the right mb both buttons function normally = a scripted interaction happens when I click on a hotspot or inventory item.


Snarky

There is a bug in one of your scripts.

Blondbraid

Quote from: Snarky on Tue 03/05/2016 10:28:45
There is a bug in one of your scripts.
Yes, but how can I locate the bug? I have a lot of scripts to keep track of and I don't know what to look for. I've already looked over the parts where I switch characters, but I could not see anything out of place. I used the same commands as for the previous switch, and then they work as they should...


Snarky

You should post the bits that seem relevant here. There's no way for us to tell what the problem is without seeing the code.

Blondbraid

Quote from: Snarky on Tue 03/05/2016 10:59:18
You should post the bits that seem relevant here. There's no way for us to tell what the problem is without seeing the code.
Yes, the thing is that I wasn't sure which bits were relevant, but I just managed to solve this.
The thing is, that the second character had received two inventory items as part of a puzzle, and still had them by the time of the second switch. By removing the items when I changed back to character 1, and adding them back once I switched again to character 2, the bug disappeared. Still a pretty weird bug though, does this happen often when you leave things in inventory?


Snarky

It's almost certainly a side-effect of something else.

When you switch to character two again, is that in response to some inventory interaction? If the cursor is in inventory mode, it could possibly get confused by the switch (since suddenly the active inventory item isn't available any more). That would explain why it stops working until you right-click (since that's the action to deactivate inventory-item cursor mode). And the number of items in your inventory (i.e. whether the active inventory index is valid) could conceivably affect this behavior, which would explain why your "fix" worked. In that case, a better way would be to set the cursor mode to normal before you change characters. But again, without seeing the code this can only be a guess.

Quote from: Blondbraid on Tue 03/05/2016 11:07:31
Yes, the thing is that I wasn't sure which bits were relevant

Based on your description, the mouseclick handler, and the script where you change the characters would seem like the obvious places to start.

Blondbraid

QuoteWhen you switch to character two again, is that in response to some inventory interaction? If the cursor is in inventory mode, it could possibly get confused by the switch (since suddenly the active inventory item isn't available any more). That would explain why it stops working until you right-click (since that's the action to deactivate inventory-item cursor mode). And the number of items in your inventory (i.e. whether the active inventory index is valid) could conceivably affect this behavior, which would explain why your "fix" worked. In that case, a better way would be to set the cursor mode to normal before you change characters. But again, without seeing the code this can only be a guess.
For now everything seems to be working, but I'll definitely keep this in mind the next time I work on an inventory puzzle. Thank you so much for your help! ;-D


SMF spam blocked by CleanTalk