Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics


Livecoding for GameMaker: Studio / GameMaker Studio 2 · By YellowAfterlife

[Fixed in 1.0.59+] switch/case not reached after reloading script with GMLive

A topic by chutneyio created Mar 24, 2022 Views: 305 Replies: 6
Viewing posts 1 to 5
(1 edit)

Hello, today i'm facing a strange issue with switch/case statement stopped working after reloading script with GMLive, here is the code to reproduce:

Everything worked as expected after launching the game. I can see Right, Up, Left, Down printed to the Output when pressing the arrow key. But after GMLive reload my script, i can not reach case 0 by pressing right arrow key anymore (Up, Left and Down still working). I can fix that by changing it to case floor(0) but i found it very weird.

Is it a bug or i'm missing something, thanks!


If you email me a small sample project, I can take a look.

It is just a simple obj_player object with step event and nothing more. I'm on MacOS btw.

Developer (1 edit)

This wasn’t what I thought it would be:

In GMLive, I form a ds_map for switch-cases that have a constant (number, string) expression for a value for faster lookup.

However, point_direction(0, 0, 1, 0) isn’t 0. It’s -0, which is technically a different value:

I’ll think of what to do with this, but using floor, round, or int64(dir) will indeed work for a workaround - it’s pretty hard to get a -0 outside of math functions.

(3 edits)

First time i ever heard of -0 lmao

I have used  floor(dir) but it failed to going to the right. The only code that work is

switch(floor(dir) { case floor(0): ...}

Apparently floor(-0) is still -0 (??), but round or int64 work.

Yes it worked! I will use it as a workaround for now.