Skip to content

Commit df3d514

Browse files
committed
refactor(npc): move heal helper to shared npclib
Move registerHealKeyword from the global datapack functions into the shared NPC custom modules loaded by npclib, so NPC scripts from either supported datapack can reuse it. Remove the datapack-specific load entry and delete the obsolete helper file without changing the existing NPC call sites or healing behavior. Validation: confirmed 83 NPC helper calls and one shared definition, confirmed no addHealKeyword pattern remains, checked staged Lua syntax and StyLua for the relocated library and load file, ran the staged whitespace check, and exercised the helper behavior from the staged shared module.
1 parent c6a6a5d commit df3d514

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
dofile(DATA_DIRECTORY .. "/lib/functions/players.lua")
2-
dofile(DATA_DIRECTORY .. "/lib/functions/npcs.lua")

data-otservbr-global/lib/functions/npcs.lua

Lines changed: 0 additions & 15 deletions
This file was deleted.

data/npclib/npc_system/custom_modules.lua

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
-- Custom Modules, created to help us in this datapack
1+
-- Custom modules used by the NPC system
2+
function registerHealKeyword(keywordHandler, npcHandler, text, condition, effect, minimumHealth)
3+
keywordHandler:addKeyword({ "heal" }, StdModule.say, { npcHandler = npcHandler, text = text }, function(player)
4+
return player:getCondition(condition) ~= nil
5+
end, function(player)
6+
if minimumHealth then
7+
local health = player:getHealth()
8+
if health < minimumHealth then
9+
player:addHealth(minimumHealth - health)
10+
end
11+
end
12+
13+
player:removeCondition(condition)
14+
player:getPosition():sendMagicEffect(effect)
15+
end)
16+
end
17+
218
local travelDiscounts = {
319
["postman"] = { price = 10, storage = Storage.Quest.ExampleQuest, value = 1 },
420
}

0 commit comments

Comments
 (0)