bandus Posted November 2, 2015 Share Posted November 2, 2015 Greetings! Working on adding a bit to my "Seed Bag" mod. In particular, I would like to make it so that the seed bag has a chance of spawning in certain locations such as the shelves of convenience stores, grocery storage, and in multiple places in grocers. I have reviewed some threads on here as well as tried to glean how other mods have done this and I would like to verify my understanding. Basically, for my own mod, I need to add a .lua file to \seedbag\media\lua\server\ and call it something like "SeedBagDist.lua." Then, within that file, have code like this: -- *************************-- * Seed Bag Distribution *-- ************************* require"Items/SuburbsDistributions"; SeedBag = {}SeedBag.version = "1.1";SeedBag.author = "Bandus";SeedBag.modname = "Seed Bag"; -- *************-- * Functions *-- ************* -- Prints mod info function SeedBag.init()print("Mod Loaded: " .. SeedBag.modName .. " by " .. SeedBag.author .. " (v" .. SeedBag.version ..")");end -- *************************-- * Seed Bag Distribution *-- ************************* table.insert(SuburbsDistributions["conveniencestore"]["shelves"].items, "SeedBag.SeedBag");table.insert(SuburbsDistributions["conveniencestore"]["shelves"].items, 3);table.insert(SuburbsDistributions["grocerystorage"]["all"].items, "SeedBag.SeedBag");table.insert(SuburbsDistributions["grocerystorage"]["all"].items, 5);table.insert(SuburbsDistributions["grocery"]["grocerstand"].items, "SeedBag.SeedBag");table.insert(SuburbsDistributions["grocery"]["grocerstand"].items, 5);table.insert(SuburbsDistributions["grocers"]["smallcrate"].items, "SeedBag.SeedBag");table.insert(SuburbsDistributions["grocers"]["smallcrate"].items, 5);table.insert(SuburbsDistributions["grocers"]["smallbox"].items, "SeedBag.SeedBag");table.insert(SuburbsDistributions["grocers"]["smallbox"].items, 5); -- *********-- * Hooks * -- *********Events.OnGameBoot.Add(SeedBag.init);print("SeedBag: SuburbsDistributions added. "); My questions specifically are: 1. Line 18 and line 46 seem to have issues. I am new to lua, but, it is my understanding that on line 18 I am declaring a function called SeedBag.init. However, Zomboid gets exceptions when loading these lines so I've clearly done something wrong. 2a. For the table itself, is it built properly with the proper formatting? I am pretty confident it is, but again, I would like to verify.2b. In lines 29, 31, 33, 35, and 37, the number after items, governs the chance that an item will spawn. Would the values I have used make the spawn chance rare? I think that value can be 1-100 but I am not completely sure. Thank you! Link to comment Share on other sites More sharing options...
fluffe9911 Posted November 3, 2015 Share Posted November 3, 2015 Best thing I can recommend is to dig into some of the newer mods spawn tables like the littering mod on my tablet so can't give a example atmEditAfter looking at it a bit I can tell you this everything but the require and the distribution itself code wise is unneeded and as far as I know does nothing so the Functions and the Hooks are not needed nor wanted.Also the lower the number the rarer you can also use 0.1-0.9 for spawn Link to comment Share on other sites More sharing options...
kinyoshi Posted November 20, 2015 Share Posted November 20, 2015 it looks like how my file looks.. except for the require"Items/SuburbsDistributions"; part.. there should be a space.. require "Items/SuburbsDistributions"; this should fix your problem.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now