YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
22 stars 8 forks source link

Feather: Need to reflect new global function scoping rules #7680

Open zreedy opened 2 weeks ago

zreedy commented 2 weeks ago

Description

A change in the behavior of named function scoping has recently been made in 2024.10. The details of which are in https://github.com/YoYoGames/GameMaker-Bugs/issues/7125. Feather needs to be updated to reflect this change in behavior.

/// oPlayer : Create
global.player = id;
function speak() {
    show_debug_message("wow");
}

/// oPlayer : Key Pressed <Space>
speak(); // Good!

/// oMob : Key Pressed <Space>
oPlayer.speak(); // Good! This is the relevant change
global.player.speak(); // Good!

This is a linked ticket for tracking purposes.

Expected Change

No response

Steps To Reproduce

The repro sets are detailed above, and in further detail in the linked ticket.

How reliably can you recreate this issue using your steps above?

Always

Which version of GameMaker are you reporting this issue for?

2024.8.0 (Monthly)

Which operating system(s) are you seeing the problem on?

Windows 10

Are you running GameMaker from inside your Steam library?

None

Sample Package Attached?

Sample Project Added?

gnysek commented 6 days ago

From what I understand:

/// oMob : Key Pressed <Space>
oPlayer.speak(); // Good! This is the relevant change
global.player.speak(); // Good!

can be executed only if at least one instance of oPlayer exists, and as such it could be warning too, as it might crash game in some situations...

Another example:

/// oPlayer : Create
global.player = id;
function speak() {
    show_debug_message("wow");
}
global.player_speak = speak; // handle

/// wherever
global.player_speak.speak(); // Good!

Seems to be valid too (but again - only after oPlayer was created at least once).