Execute GdScript from string or so

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GovanifY
:warning: Old Version Published before Godot 3 was released.

Hey,

I might sound pretty stupid with this question but I’d like to store GdScript in a string and then be able to run it by using as a reference the node containing the screen.

For exemple let’s take a debug node that we use in game, the user could have an in-game interpreter a la Skyrim or Don’t Starve to be able to poke some nodes, change some properties(exemple HP of one enemy or, and this is where scripting is fun, of all enemy using for loops) or trigger some events to make testing easier. This way we won’t have to hardcode a lot of debug functions to do the stuff and a tester, given the inside knowledge of the game, could be able to be way more efficient in his job.

I might have missed this in the job but I didn’t seen any execute or parse commands from GdScript, so I’m asking here.

:bust_in_silhouette: Reply From: timoschwarzer

See this question https://forum.godotengine.org/339/does-gdscript-have-method-to-execute-string-code-exec-python

Thanks! Strangely didn’t get it by searching in the Q&A first. Oh well problem solved anyways

GovanifY | 2016-07-23 12:00