Is there a way to dynamically add code lines into scripts, like from stored strings in JSON ??

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Inces

What I wish for is to have nodes that will gain completely unique behaviors in unique circumstances. I want them to reform their own functions or create new ones when those circumstances are met. I wish to keep these circumstances along with whole code lines in JSON. This is because I plan to have hundreds of various behaviours and I don’t think it is convenient to have single ready script with all of them being switched with booleans.

For example : when blue node collides with red node I want the nodes script to expand ( create new script dynamically based on originals script copy ) and add whole line of code from JSON containing whole new Input event() function in form of string.

Is this possible in Godot ??

I don’t think that adding code on runtime is a viable option imo, with what you are describing you are better off with a behavior tree.

Yaann | 2021-05-28 09:25

It is possible to do this as a node’s script can be set and changed during runtime so if a template is setup to receive JSON data then it can be created as needed.

The above mentioned is ill advised as it breaks proper coding conventions and makes your intentions look malicious in nature

Wakatta | 2021-06-10 10:00