YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

Using script_execute or script_execute_ext on methods doesn't throw an error #7920

Open tabularelf opened 4 days ago

tabularelf commented 4 days ago

Description

On LTS (and LTSr3), trying to use script_execute or script_execute_ext would attempt to call a built in function (camera_create). However at some point in Monthly and even on Beta, this behaviour was changed to get the method index but without the scope.

You end up in a very strange situation where you're calling a method, but without the current scope. Resulting in a very strange scenario.

Method scopes are ignored, and the current self is used in place.

Arguably, these should throw an exception for calling a method with script_execute or script_execute_ext as the script function.

Steps To Reproduce

  1. Run the project
  2. Find "Direct method call: " and look at every other result. Note: calling a method and method_call is the correct way.

Which version of GameMaker are you reporting this issue for?

IDE v2024.1100.0.634 Runtime v2024.1100.0.658

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

Windows 10.0.19045.0

Which platform(s) are you seeing the problem on?

Windows

8afd4ae2-7090-428a-b086-70f14eb09d00

tabularelf commented 4 days ago

Code in question used in project:

function print(value) {
    show_debug_message(value);
    return self;
}

var scope = {foo: "bar"};
var func = method(scope, print);

show_debug_message($"Direct method call: {func(42)}");
show_debug_message($"method_call: {method_call(func, [42])}");
show_debug_message($"script_execute: {script_execute(func, 42)}");
show_debug_message($"script_execute_ext: {script_execute_ext(func, [42])}");
tabularelf commented 4 days ago

From a short discussion on Discord, turns out that this was a fix from https://github.com/YoYoGames/GameMaker-Bugs/issues/1667. However, the manual still doesn't reflect those changes. https://manual.gamemaker.io/beta/en/GameMaker_Language/GML_Reference/Asset_Management/Scripts/script_execute.htm

2024-10-07_02-59-57

(On a side note, that "second" use case is somewhat wrong? method_call is more like script_execute_ext.)

YYBartT commented 1 day ago

Listed method as a supported data type on the function reference pages, along with other changes. Also clarified the link between method_call() and the script_execute* functions and removed text in the manual that referred to script_execute* as "legacy".