From 0237567c183f7a50305b2db47a2c0902a8eb3189 Mon Sep 17 00:00:00 2001 From: Tachytaenius Date: Mon, 4 Jul 2022 17:11:21 +0100 Subject: [PATCH] More modding guide --- docs/guides/modding-guide.rst | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/guides/modding-guide.rst b/docs/guides/modding-guide.rst index c6ae8ae15..b3b5c515b 100644 --- a/docs/guides/modding-guide.rst +++ b/docs/guides/modding-guide.rst @@ -86,17 +86,24 @@ Then, we pass the key, amount of time units between function calls, what the tim end end) -``eventful`` is slightly more involved. :: +``eventful`` is slightly more involved. First get the module: :: local eventful = require("plugins.eventful") - -- blah -Check the full list of Eventful events at https://docs.dfhack.org/en/stable/docs/Lua%20API.html#list-of-events. +``eventful`` contains a table for each event which you populate with functions. Each function in the table is then called with the appropriate arguments when the event occurs. So, for example, to print the position of a moving (item) projectile: :: + + eventful.onProjItemCheckMovement[modId] = function(projectile) + print(projectile.cur_pos.x, projectile.cur_pos.y, projectile.cur_pos.z) + end + +Check the full list of events at https://docs.dfhack.org/en/stable/docs/Lua%20API.html#list-of-events. Setting up an environment for a more advanced modular mod --------------------------------------------------------- -s +Now, you may have noticed that you won't be able to run multiple functions on tick/as event callbacks with that ``modId`` idea alone. To solve that we can just define all the functions we want and call them from a single function. + +TODO Your first whole mod --------------------