Repository navigation
Basic API Usage part 2
Now that we have added our own custom cells, we obviously need to make it do something!
So, we have a function for update, but what other functions can our mod use and what are they used for and how?
First, lets talk a bit more about update. Update is called when a modded cell from any mod is updated. The update order is the order they were added in.
Update has 4 parameters, the cell ID of the updated cell, the cells x coordonate, the cells y coordonate, the rotation of the cell. If you prefer using the labels of your cells instead of storing their IDs in variables (addCell returns a number that is the cell ID), you can store the label in a variable by setting it to the result of another built-in function, getCellLabelById. All it needs is the ID of the cell. You can also use getCellLabel which just needs the x and y and gives you the label of the cell at that position.
Now, more on other functions. onEnemyDies - This function which you return in the return table (the table you return containing the functions of the mod) is called when a modded enemy from any mod dies (by dies we mean something fell into it and it obviously disappeared). It gets 6 arguments. The id of the modded enemy, the x of it, the y of it, a table containing all the properties of the cell that fell in, the x of what fell in, the y of what fell in. (The coordonates of what fell in are the ones it came from.) onTrashEats - This function gets the same arguments as onEnemyDies, but it is called when a modded trash cell eats something. tick - Called every in-game tick before all cells update, it has no arguments.
Modded enemies and modded trash cells can be made by simply putting the type of the cell in addCell to say "enemy" for the enemy and "trash" for the trash cell.