Jump to content

tet

Member
  • Posts

    3
  • Joined

  • Last visited

Everything posted by tet

  1. I should clarify that I was using require in the way you wanted to use it, on in-mod Lua -- files that get required by the mod loader. Many mods require files from ProjectZomboid/media/lua/*
  2. tet

    LuaHookManager

    I have not found any comprehensive reference to this class on the forums, so here's my rundown on a very in-progress, interesting feature. PZ offers "Hooks", through Lua accessor Hook as a sort of mutable counterpart to Events. While Events are purely informational, Hooks themselves have direct consequence. When you Hook one of the compatible functions, you're actually superceding its original logic, and vowing to implement something meaningful in its place. Out of the 6 Hooks laid out by LuaHookManager, only 3 are called by game code with the correct name. Several are called with a name that disagrees with the name registered by LuaHookManager (e.g "UseItem" vs. "HookUseItem"). There may be some conceivable pure-Lua sleight of hand to get these mistyped Hooks calling -- but I doubt it. However, Attack CalculateStatsWeaponSwingare correctly wired and usable in game. Here's an example showing how to use these features semantically: function weaponswing(owner, weapon) print("USE ITEM")endfunction calculatestats(character) print("CALCSTATS")endfunction attack(character, floatChargeDelta) print("ATTACK")endHook.WeaponSwing.Add(weaponswing)Hook.Attack.Add(attack)Hook.CalculateStats.Add(calculatestats)Note that a bare CalculateStats hook causes several exceptions that prevents the game from starting. Remarks I'm interested in where the developers are going with this. Blocking the original code is handy, but a more robust system would allow modders to conditionally block, allow, or even change the arguments to each call. Per-object-instance hooking is a more complicated, but highly powerful direction to move in.
  3. 1. After a quick test I'm not getting require() to cause any action either, but this is logical as you mention the files are already required 2. This is a little weird but not too crazy in a language in which everything is global unless it's not. The biggest problem is dependency in an environment where you cannot programatically control the loading of resources; however PZ's mass script loader seems to consistently load files in alphabetical order. 3. Declare "MyMod = {}" near the top of the load chain and have your modules insert their features Edit: There is also a "Require" key of mod.info, that force-loads another mod. It's used by http://pz-mods.net/other/ModUtilities/
×
×
  • Create New...