Assemblies
Description
Assemblies are strings with a block of assembly code that can call in-game functions and more. Once it's assembled, the required memory is allocated and its symbols are registered.
Every assembly is defined in a separate file, has a unique name, and is located in the assemblies
directory.
The assemblies.lua
file contains a list of all assemblies and in which order they will be loaded (higher first). The latter is important in cases where one requires another.
Layout
The former file returns a string with assembly code and a table with its symbols.
The latter file returns a table with every assembly. The value of a table entry equals the filename of the assembly (e.g. getRandomNumber)
.
Usage
Generally, you will almost always only write code in Lua for your formula functions, helpers, etc. However, there are cases where you might want to use an existing game function instead.
Let's say you wanted to create a formula function that heals all party members and removes any of their negative status effects. To do this, you would have to go through all party members, set their current hp to their max hp (with bubble in mind), check which status effects are considered negative and then remove their state and timer. So it would actually require quite a lot of code.
Now instead of doing all of this manually with Lua, you can also just reuse a game function. To do this, you would of course first have to find out if such a function even exists, at which address it is, what arguments it requires, and so on, but let's assume we already know that as part of this example.
Once you do, you can set up your assembly code:
and then define it as a helper:
and finally call it in a formula function:
This is just a basic example. It will get more advanced if you have to pass arguments to the assembly code or return the result. I recommend looking through already existing assemblies to get an idea on how you can do those.
Expansion
You can modify existing assemblies created by me and add entirely new ones if you want. However, this is more on the advanced side of modding, so unless you really know what you are doing, I would avoid messing with it. The option is just there in case you need it.
Notes
Symbols should be unique as they are registered by the same Lua context. So if you add any new assemblies, you should also use your own prefix for your symbols. Do NOT use the tif_
prefix from this mod as that will result in your code potentially overwriting mine whenever I introduce new assemblies.
Last updated