1

I would like to dynamically change the script that is executed when a index in an array is called.

The following is valid syntax:

actions[0] = script_do_something
...
actions[n] = script_do_something_else

How do I execute the scripts stored in the array? If I cant, then how else could I replicate a function pointer in GMS?

Unfortunately this doesn't work:

actions[0]()

I would like to avoid if statements as I feel they will get too long and messy.

Morgoth
  • 4,935
  • 8
  • 40
  • 66

1 Answers1

1

you should use script_execute function.

script_execute(actions[0]);

also you may pass arguments:

script_execute(actions[0], arg1, arg2);
Dmi7ry
  • 1,777
  • 1
  • 13
  • 25