• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

variables holding programs

Pfap

Member
[SOLVED]

Hello, is it possible for variables to hold programs? I'm trying to use the choose function like this:

choose( control1, control2, control3)

in the create event I set up the variables:

control1 = { if keyboard_check(vk_up){ y -= 3}

(rest of keyboard inputs)

}

control2 =

It's not working, so I believe I'm using variables wrong or missing something.

I'm racking my brain trying to find a solution, I want the players controls to be switched if they have a collision with an object.
 
Last edited:

Binsk

Member
You cannot create lambda functions in GameMaker *yet*.

You should place the code you want into a script instead of setting it directly into the variable. Then you can set the variable to the script name instead. When you want to execute the code then you would do something like:

script_execute(control1);

This should give you the result you are going for. Or, instead of storing the script names in variables, just put the names directly into the choose function.
 

Pfap

Member
Didn't even know what a lambda function was, I guess you learn something everyday. That solution worked along with some alarms, I used instance_create with the choose function to change my object.

Thanks :)
 
Top