• 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!

GameMaker Is there a way to run code from a variable?

The Kevster

Member
I'm trying to add console commands to my game using GML. I'm using keyboard_string to get information and its being sent to a variable called "entry". Can I run the contents of this variable?
 

NightFrost

Member
Not directly. You'd have to write a parser that tries to make sense of the string and then execute something that implements the given directive. Altering variables should be pretty straightforward to do this way, with the exists / get / set commands.
 

Evanski

Raccoon Lord
Forum Staff
Moderator
I'm trying to add console commands to my game using GML. I'm using keyboard_string to get information and its being sent to a variable called "entry". Can I run the contents of this variable?
you would have to make a code interpreter for strings to gml
Ive actually been working on something like this for a while now {HERE}

@GMWolf Has a great stepping stone
I've since replaced that for my work

But TL;DR:
I put the code I want into a grid and compare it to the user input then it runs a script
 
Top