From 306822b1750084d0e7475915fa3f3ce960edaeeb Mon Sep 17 00:00:00 2001 From: Tachytaenius Date: Sun, 10 Jul 2022 18:05:16 +0100 Subject: [PATCH 1/3] Update changelog.txt --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 955298b47..2cbf253d4 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -57,6 +57,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - UX: You can now click on the hotkey hint text in many ``gui/`` script windows to activate the hotkey, like a button. Not all scripts have been updated to use the clickable widget yet, but you can try it in `gui/blueprint` or `gui/quickfort`. ## Documentation +- Made ``DFHACK_`` prefix in ``custom-raw-tokens``' documentation ``EXAMPLE_MOD_`` and explained why. ## API - Removed "egg" ("eggy") hook support (Linux only). The only remaining method of hooking into DF is by interposing SDL calls, which has been the method used by all binary releases of DFHack. From 155525b853edd377d7711aeaebc6fc677169625f Mon Sep 17 00:00:00 2001 From: Tachytaenius Date: Sun, 10 Jul 2022 18:10:40 +0100 Subject: [PATCH 2/3] Update Lua API.rst --- docs/Lua API.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/Lua API.rst b/docs/Lua API.rst index ebd7a1287..14770c16d 100644 --- a/docs/Lua API.rst +++ b/docs/Lua API.rst @@ -3348,24 +3348,27 @@ A module for reading custom tokens added to the raws by mods. The same as ``getToken(plantGrowthItem, token)`` but with a specified plant and growth, using growth name (e.g. "LEAVES") instead of number. +It is recommended to prefix custom raw tokens with the name of your mod to avoid duplicate behaviour where +two mods make callbacks that work on the same tag. + Examples: * Using an eventful onReactionComplete hook, something for disturbing dwarven science:: - if customRawTokens.getToken(reaction, "DFHACK_CAUSES_INSANITY") then + if customRawTokens.getToken(reaction, "EXAMPLE_MOD_CAUSES_INSTANITY") then -- make unit who performed reaction go insane * Using an eventful onProjItemCheckMovement hook, a fast or slow-firing crossbow:: -- check projectile distance flown is zero, get firer, etc... - local multiplier = tonumber(customRawTokens.getToken(bow, "DFHACK_FIRE_RATE_MULTIPLIER")) or 1 + local multiplier = tonumber(customRawTokens.getToken(bow, "EXAMPLE_MOD_FIRE_RATE_MULTIPLIER")) or 1 firer.counters.think_counter = firer.counters.think_counter * multiplier * Something for a script that prints help text about different types of units:: local unit = dfhack.gui.getSelectedUnit() if not unit then return end - local helpText = customRawTokens.getToken(unit, "DFHACK_HELP_TEXT") + local helpText = customRawTokens.getToken(unit, "EXAMPLE_MOD_HELP_TEXT") if helpText then print(helpText) end * Healing armour:: @@ -3374,7 +3377,7 @@ Examples: local healAmount = 0 for _, entry in ipairs(unit.inventory) do if entry.mode == 2 then -- Worn - healAmount = healAmount + tonumber((customRawTokens.getToken(entry.item, "DFHACK_HEAL_AMOUNT")) or 0) + healAmount = healAmount + tonumber((customRawTokens.getToken(entry.item, "EXAMPLE_MOD_HEAL_AMOUNT")) or 0) end end unit.body.blood_count = math.min(unit.body.blood_max, unit.body.blood_count + healAmount) From 0b6178f5d23f806fa10ac8165c7dd33f53a58374 Mon Sep 17 00:00:00 2001 From: Tachytaenius Date: Sat, 27 Aug 2022 15:24:22 +0100 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Myk --- docs/Lua API.rst | 2 +- docs/changelog.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/Lua API.rst b/docs/Lua API.rst index 14770c16d..b20377958 100644 --- a/docs/Lua API.rst +++ b/docs/Lua API.rst @@ -3355,7 +3355,7 @@ Examples: * Using an eventful onReactionComplete hook, something for disturbing dwarven science:: - if customRawTokens.getToken(reaction, "EXAMPLE_MOD_CAUSES_INSTANITY") then + if customRawTokens.getToken(reaction, "EXAMPLE_MOD_CAUSES_INSANITY") then -- make unit who performed reaction go insane * Using an eventful onProjItemCheckMovement hook, a fast or slow-firing crossbow:: diff --git a/docs/changelog.txt b/docs/changelog.txt index 2cbf253d4..955298b47 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -57,7 +57,6 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - UX: You can now click on the hotkey hint text in many ``gui/`` script windows to activate the hotkey, like a button. Not all scripts have been updated to use the clickable widget yet, but you can try it in `gui/blueprint` or `gui/quickfort`. ## Documentation -- Made ``DFHACK_`` prefix in ``custom-raw-tokens``' documentation ``EXAMPLE_MOD_`` and explained why. ## API - Removed "egg" ("eggy") hook support (Linux only). The only remaining method of hooking into DF is by interposing SDL calls, which has been the method used by all binary releases of DFHack.