chrismaltby / gb-studio

A quick and easy to use drag and drop retro game creator for your favourite handheld video game system
https://www.gbstudio.dev
MIT License
8.48k stars 469 forks source link

Variable Set Via Scene Init Not Correct? #365

Closed SetsuneW closed 4 years ago

SetsuneW commented 4 years ago

Describe the bug A strange bug I ran into while coding an elevator. During a room's init, I set the "Current Floor" to make sure it would know if it actually changed floors or not in a separate scene. However, I was getting an unexpected value that made no sense. I tried multiple solutions, but it seemed like the only fix, unless it was user error, was to move the Variable setting from the Initialization of the scene, to the trigger that switched to the Elevator scene. Same single line of code, everything worked fine.

To Reproduce I streamed me struggling with (and solving) the process, it's the first 25 minutes of this video: https://picarto.tv/videopopout/Setsune_2019.12.21.09.20.33_nsfw.flv Or go to https://picarto.tv/setsune , click on Videos, and choose the 2019-12-21 video. There is some mild suggestive graffiti on the elevator doors, to warn you, but no other graphic content.

Expected behavior On initialization (loading into the room), I expected it to set the Current Floor to 1. But instead it was consistently setting it to an improper value. I really did think it was User Error until I fixed it with the small change, and it might still have been.

Screenshots See Video Link Above

Platform (please complete the following information):

Additional context This MAY relate to processing Switch statement values out of numerical order (I originally started with 6-1-2-3-4-5 due to the floor ordering, with "0" being used to cancel out of the elevator), but the bug did not correct itself when I changed this to 1-2-3-4-5-6, only when I changed the variable to be set on Trigger, not Scene Initiation did it suddenly start working.

RichardULZ commented 4 years ago

Tried my best but can't reproduce this, I don't think i can test this without a known broken example project zip.

It did look like, as you say, setting your variable in the scene Initialization was different to setting it on a trigger in the same room, but that seems specific to your setup.

When trying to find a problem with variables, I usually draw text with $20$ or the variable to test in places where something may be going wrong. For faster debugging, the P key will change your start position to anywhere on any map, unless you have variables to set up.

For Gameplay, i'd recommend adding a last option with cancel, just in case people don't know about B.

In future streams, i'd turn down the game audio, and turn up your voice, those crash noises are loud...

chrismaltby commented 4 years ago

I've pieced together an image of the full script used from screenshots of the stream, nothing jumps out as being obviously wrong, but I'm going to try recreating this in a project and see if I can reproduce the issue.

elevator_script

RichardULZ commented 4 years ago

AHAAAA! 23 minutes dead, the trigger was always setting the current floor to 5, then you change it to 1 and it starts working, the poor scene init was always over written by the elevator trigger. Problem solved, it was 3am brain. ;)

image

SetsuneW commented 4 years ago

That's weird, I thought I didn't add that trigger until later on... urgh, user error, of course. Sorry for the trouble. And noted about the mic issue, Windows had reset my recording levels.