Jump to content

Search the Community

Showing results for tags 'modules'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News & Announcements
    • News
  • Project Zomboid
    • PZ Updates
    • General Discussions
    • Bug Reports
    • PZ Support
    • PZ Multiplayer
    • PZ Community & Creativity
    • PZ Suggestions
  • PZ Modding
    • Tutorials & Resources
    • Mods
    • Items
    • Mapping
    • Mod Ideas and Requests
  • General Games Development
    • Indie Scene
  • Other Discussions
    • General Discussion
    • Forum Games & Activities

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Twitter


Interests

Found 1 result

  1. 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...