Code

From LuaSTG Wiki
Jump to navigation Jump to search
Code
Code.png
Code Icon
Location General Tab

This function allow users to insert a piece of custom Lua code. Things in LuaSTG that can be done with editor nodes are generally doable through raw Lua code as well, so this offers another option to write some parts of script in raw code, as well as implementing things that can not be done with editor nodes.

Usage[edit | edit source]

First create a code node where you want to put Lua code. After that, click on the node and then the "..." on the left panel to edit the content of the node. Write code into the new window that pops up. Be careful, if you click cancel or the x on top right the content will be lost without being saved.

What happens if a syntax error or an exception occurs in the code block?[edit | edit source]

The editor can report uncompilable codes and prevent running, but it will not check exceptions since they happens at runtime.

Tip[edit | edit source]

Use right click -> view code on all kinds of nodes to see how they can be written in Lua code. This may help a lot for writing Lua code on your own. Also it's generally good to learn basic syntax on how to write code in Lua.