Skip to content

TurboWarp <key () pressed?> blocks may act differently to Scratch depending on names of Costumes and Sounds #93

Open
@Tacodiva

Description

@Tacodiva

When a constant number input is passed into the <key () pressed?> block like this:
image
In Scratch, this script always says false. In TurboWarp, this script says true if you are pressing the 'Z' key (ASCII 90). This incorrect behavior stops if you have a costume or sound named '90'.

This is because when runtime.ioDevices.keyboard.getKeyIsDown gets a number as an argument it looks up the number like it's an ASCII value, but when it receives a string it just looks for a key with that name. Both TurboWarp and Scratch detect the Z key with this script;

image

Because the + block turns the 90 into a number. TurboWarp's behavior depends on costume and sound names because this line:

return new TypedInput(`runtime.ioDevices.keyboard.getKeyIsDown(${this.descendInput(node.key).asSafe()})`, TYPE_BOOLEAN);

Seems to incorrectly assume that asSafe() means constants will act as strings always. This is only true when a costume or sprite exists with that name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions