Jump to content

TheodoreLogan

Member
  • Posts

    4
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

TheodoreLogan's Achievements

  1. Firstly, thanks for answering tet! and thanks for testing require, it's nice to know I'm not going mad =) My main concern with this method is that it becomes the responsibility of each module to load itself into the parent (MyMod) rather than the other way around. Also it would bug me to have something like "aaa.lua" just to make sure it loads first. I've been looking through Kahlua2 which PZ uses to load its lua, and I think I am going to set up my own test project to see if the require implementation displays the same behaviour I'm seeing in PZ. If it does I'll put a request in on Github to try and fix it. If I find any answers I'll update this post =)
  2. Yup AFAIK this is preferred; it means you are not overwriting the SuburbsDistributions.lua file. The only other way would be to write your own item spawning algorithms, but I've only seen mods do this when they need fine grain control over the spawns. Afraid I can't comment on the backpack question, but someone else might.
  3. Hey JonSyn, I don't believe there is an event that fires on a players death yet, or damage. However, I do know there is an OnPlayerUpdate event. Although it's not ideal, you could use this to check a players health like so: function foo(player) if player:getHealth() <= 0 then print('dead'); --or call your own onPlayerDead() function. endendEvents.OnPlayerUpdate.Add(foo);Be aware that this event is fired a lot, so keep any logic nice and simple! Does that help at all?
  4. Hello, I'm new to modding Project Zomboid and, if someone has a moment, I'm having a few difficulties. My questions revolve around an issue I'm having where I'm not able to use 'require' to get my other modules like I normally would. Here is what I would like to do in a bare bones example: --File: media/lua/server/MyMod/MyMod.lua MyMod = {} print('Setting up...'); MyMod.module1 = require 'MyMod/Module1.lua'; print('Loaded module: '..MyMod.module1.foo()); --File: media/lua/server/MyMod/Module1.lua local M = {} function M.foo() return 'I\'m Module1!'; end return M; When I load the mod I get an exception telling me MyMod.module1 is null, when I expect to get my returned Module1 table, or an exception that it could not find the file. --Output: Loading: ../media/lua/server/MyMod/MyMod.lua Setting up... ----------------------------------------- attempted index: foo of non-table: null ----------------------------------------- So, if you bare with me I have three related questions: 1. Does PZ stop me from using require to load other lua files? why? (or am I doing it wrong?) 2. Why does PZ load every .lua file in my mod. I normally expect a single point of entry, such as loading the file "MyMod/MyMod.lua" which would then allow me to decide what modules the mod loads. Is there a reason it doesn't have a single point of entry and how should I be using this to my advantage? 3. Other mods declare their modules using their mod name as a prefix to avoid possible conflicts; I was hoping I could avoid pollution of the global scope and just have everything under one roof, i.e inside MyMod, instead of MyMod;MyModModule1;MyModModule2;etc. Is there any way to do this? Thanks for reading, Any questions/clarifications please ask! Logan. Update: I'm guessing my issue with require() has something to do with the differences between Kahlua2 and Lua 5.1? (only because my example works fine using Lua 5.1)
×
×
  • Create New...