Logic & Scripting Prototype Working
this was so difficult
basically a TON of things needed to be changed for this to work. i had to rework the entire scripting system. i had to also think about how the system is going to work
the system i landed on, basically is you can create nodes in the state machine editor, and attach scripts on those states. instead of scripts, im calling the whole package of state machine + scripts a “Logic”. i havent reflected the name everywhere else yet though, and that is probably going to take a really long time as its a major architectural shift that i didn’t plan for beforehand.
i made custom nodes in the editor as you can see, a start, end and the script node. there is now a nice dropdown to select the script (a searchbar will be added later) and you can create new scripts. i fixed the code editor to actually load/save code properly.
i had to redo how it saved data, so i could communicate the scripts, nodes, connections, etc all to the ScriptingSystem, which starts off at the “Start” node and steps the state once, going into the first node. This part of the code is an absolute MESS.
i had a ton of bugs to fix, including state and Svelte firing state over and over again for some reason, Lua issues, dealing with coroutines, dealing with external functions which would change the state and exit the code, etc
To add the script, there is now a “Add component” button which you can select the script and select the logic.
The state machine handles direct to end, looping nodes, multiple handles, infinite loops going into other nodes, etc.
At the end of the video, you can see that i created two states and the second state had two outputs, and the path is a 50/50 random decided by the Lua code to loop back into the first state or exit.
Overall, this was really tiring and I’m glad it’s done. The amount of time thinking and debugging isn’t included in the time tracked so yeah :(