Dr_Cox1911 Posted July 25, 2013 Share Posted July 25, 2013 Greetings, can someone explain me how the distribution-files like "suburbdistribution.txt" work?Are the following assumptions correct? module SuburbsDistribution{imports {Base //What does this do?}validmaps{50_50, //What does this do?} containeritemdistribution //Defining the container-typ (like counters, shelfs,...)?{Room = shed, //Defining a special room (optional)?Containers = counter, //Refering to the container the following entries apply to?Hammer = 1, //Chance that the item will spawn (in percent)?Plank = 10,Nails = 12,} Link to comment Share on other sites More sharing options...
RoboMat Posted July 25, 2013 Share Posted July 25, 2013 Base imports the Base module so you can call the items defined in that module (e.g.: Base.Screwdriver).The 50_50 value defines for which map area it is valid (IIRC). If you want to spawn items I'd use the lua method:table.insert(SuburbsDistributions["Kitten"]["counter"].items, "NotEnoughBags.PaperBag");table.insert(SuburbsDistributions["Kitten"]["counter"].items, 5); Link to comment Share on other sites More sharing options...
Dr_Cox1911 Posted July 25, 2013 Author Share Posted July 25, 2013 Thanks for the explanation!I already can spawn items (with the methods you mentioned but want to understand the "inside" of PZ.For example what the number stands for (e.g. how PZ tosses the dice for lootspawn). Link to comment Share on other sites More sharing options...
RoboMat Posted July 25, 2013 Share Posted July 25, 2013 Thanks for the explanation!I already can spawn items (with the methods you mentioned but want to understand the "inside" of PZ.For example what the number stands for (e.g. how PZ tosses the dice for lootspawn). The inside of PZ is a scary and beautiful place Well the exact "math" for the filling is:ItemPicker.rollItem = function(containerDist, container) if containerDist ~= nil then -- we are looking for the zombie density in this area, more zombie density mean more loots local zombieDensity = 0; local chunk = getWorld():getMetaChunk((getPlayer():getX()/10), (getPlayer():getY()/10)); if chunk then zombieDensity = chunk:getLootZombieIntensity(); end local alt = false; local itemname = nil; for m = 0, containerDist.rolls do for i, k in ipairs(containerDist.items) do if not alt then -- first we take the name of the item itemname = k; --~ print (itemname); else -- next step is the random spawn part if ZombRand(10000) <= ((((k*100) * ZomboidGlobals.LootModifier) + (zombieDensity * 10))) then -- make an item in the container of that type. local item = container:AddItem(itemname); item:setAutoAge(); end end alt = not alt; end end endendI'd suggest you take a closer look at the ItemPicker.lua file As I said the validmaps value defines for which part of the whole world grid this distribution list works. The farmingdist for example has a valid_maps value of 49_48.EDIT: For completeness, there also is some distribution handling in the java source but I'm not sure if and to what extend it is (still) used. Link to comment Share on other sites More sharing options...
lemmy101 Posted July 25, 2013 Share Posted July 25, 2013 Greetings, can someone explain me how the distribution-files like "suburbdistribution.txt" work?Are the following assumptions correct? module SuburbsDistribution{imports {Base //What does this do?}validmaps{50_50, //What does this do?} containeritemdistribution //Defining the container-typ (like counters, shelfs,...)?{Room = shed, //Defining a special room (optional)?Containers = counter, //Refering to the container the following entries apply to?Hammer = 1, //Chance that the item will spawn (in percent)?Plank = 10,Nails = 12,} That file shouldn't be there. It's existence is a mistake. It's outdated and unused. Distributions are done in the lua files now as RoboMat explains Link to comment Share on other sites More sharing options...
RoboMat Posted July 26, 2013 Share Posted July 26, 2013 That file shouldn't be there. It's existence is a mistake. It's outdated and unused. Distributions are done in the lua files now as RoboMat explains Ah that's great to know, thanks lemmy On that note, may I ask if the script system will be oberhauled / kept for item creation or will it be totally replaced with lua? Link to comment Share on other sites More sharing options...
kinyoshi Posted July 26, 2013 Share Posted July 26, 2013 Ah that's great to know, thanks lemmy On that note, may I ask if the script system will be oberhauled / kept for item creation or will it be totally replaced with lua? Aww what's wrong with the way it works now? This would force me to learn lua, which would be good, but I like the scripting system. Link to comment Share on other sites More sharing options...
RoboMat Posted July 26, 2013 Share Posted July 26, 2013 I didn't say there was anything wrong with it Link to comment Share on other sites More sharing options...
kinyoshi Posted July 26, 2013 Share Posted July 26, 2013 I didn't say there was anything wrong with it So is there talk if it changing? If so, that's gonna suck, cuz I got stuff made already. I rally need to quit talking about learning lua and just learn it lol. Link to comment Share on other sites More sharing options...
RobertJohnson Posted July 26, 2013 Share Posted July 26, 2013 I don't think we're gonna change this system, it's working pretty well and easy to understand. Link to comment Share on other sites More sharing options...
Dr_Cox1911 Posted July 26, 2013 Author Share Posted July 26, 2013 Ah, thanks for the clarification lemmy andRoboMat! So the "SuburbsDistributions.lua" is the right place for spawnstuff. Link to comment Share on other sites More sharing options...
RoboMat Posted July 26, 2013 Share Posted July 26, 2013 I don't think we're gonna change this system, it's working pretty well and easy to understand. Thanks for the info RJ Ah, thanks for the clarification lemmy andRoboMat! So the "SuburbsDistributions.lua" is the right place for spawnstuff. That's correct. table.insert(SuburbsDistributions["Kitchen"]["counter"].items, "NotEnoughBags.PaperBag");table.insert(SuburbsDistributions["Kitchen"]["counter"].items, 5); The above code just inserts new values to the tables originally defined in the SuburbsDistributions.lua Link to comment Share on other sites More sharing options...
kinyoshi Posted July 26, 2013 Share Posted July 26, 2013 I don't think we're gonna change this system, it's working pretty well and easy to understand.Yay Link to comment Share on other sites More sharing options...
johndough Posted August 2, 2013 Share Posted August 2, 2013 Hmm, so when exactly do these two lines need to be called to change the spawn distribution? I suppose some of the early pre map loading events? Link to comment Share on other sites More sharing options...
RoboMat Posted August 2, 2013 Share Posted August 2, 2013 Hmm, so when exactly do these two lines need to be called to change the spawn distribution? I suppose some of the early pre map loading events?If I undertand your question correctly, you don't need any events for the table insertion. Just create a file called YourMod_Distribution and insert all the spawn stuff there. As an example here is my complete Distribution file from my Lockpicking mod:-- ================================================-- LOCKPICKING-- created by RoboMat-- ================================================table.insert(SuburbsDistributions["all"]["bin"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["bin"].items, 3);table.insert(SuburbsDistributions["all"]["counter"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["counter"].items, 5);table.insert(SuburbsDistributions["all"]["inventorymale"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["inventorymale"].items, 2);table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, 2);table.insert(SuburbsDistributions["all"]["desk"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["desk"].items, 10);table.insert(SuburbsDistributions["all"]["filingcabinet"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["filingcabinet"].items, 8);table.insert(SuburbsDistributions["all"]["officedrawers"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["officedrawers"].items, 10);table.insert(SuburbsDistributions["Kitten"]["counter"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["Kitten"]["counter"].items, 5);That's all it needs. P.S.: Just to be clear ... the file-name isn't mandatory for the Distribution to work, but it's nice to have an organized code Link to comment Share on other sites More sharing options...
kinyoshi Posted August 2, 2013 Share Posted August 2, 2013 If I undertand your question correctly, you don't need any events for the table insertion. Just create a file called YourMod_Distribution and insert all the spawn stuff there. As an example here is my complete Distribution file from my Lockpicking mod:-- ================================================-- LOCKPICKING-- created by RoboMat-- ================================================table.insert(SuburbsDistributions["all"]["bin"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["bin"].items, 3);table.insert(SuburbsDistributions["all"]["counter"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["counter"].items, 5);table.insert(SuburbsDistributions["all"]["inventorymale"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["inventorymale"].items, 2);table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, 2);table.insert(SuburbsDistributions["all"]["desk"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["desk"].items, 10);table.insert(SuburbsDistributions["all"]["filingcabinet"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["filingcabinet"].items, 8);table.insert(SuburbsDistributions["all"]["officedrawers"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["all"]["officedrawers"].items, 10);table.insert(SuburbsDistributions["Kitten"]["counter"].items, "Lockpicking.BobbyPin");table.insert(SuburbsDistributions["Kitten"]["counter"].items, 5);That's all it needs. P.S.: Just to be clear ... the file-name isn't mandatory for the Distribution to work, but it's nice to have an organized code Remember to change the "Kitten" to "k-i-t-c-h-e-n" without the -.... Don't want stuff to spawn inside of our kitty kats. Link to comment Share on other sites More sharing options...
johndough Posted August 2, 2013 Share Posted August 2, 2013 If I undertand your question correctly, you don't need any events for the table insertion. Just create a file called YourMod_Distribution and insert all the spawn stuff there. As an example here is my complete Distribution file from my Lockpicking mod:That's all it needs. P.S.: Just to be clear ... the file-name isn't mandatory for the Distribution to work, but it's nice to have an organized code Couldn't that be problematic if Suburbsdistribution.lua is not parsed first? What I don't quite understand is where and when the new spawn rules take effect. If I add table.insert(SuburbsDistributions["JohndoughsKitchen"]["fridge"].items, "JohndoughsMod.CanOfBeer");table.insert(SuburbsDistributions["JohndoughsKitchen"]["fridge"].items, 5);and then load up an old saved game where I am standing in a JohndoughsKitchen - do I then suddenly get a 5% chance of having a beer in my fridge? This is probably a stupid question, but anyway... Link to comment Share on other sites More sharing options...
RoboMat Posted August 2, 2013 Share Posted August 2, 2013 Well if you want to be sure you can add require 'Items/SuburbsDistributions' to the top. Do you have a JohndoughsKitchen in the game? It also will only work for containers that haven't been filled yet. Link to comment Share on other sites More sharing options...
johndough Posted August 2, 2013 Share Posted August 2, 2013 Do you have a JohndoughsKitchen in the game? No, unfortunately not yet, only Johndough beer. :cool: It also will only work for containers that haven't been filled yet. And which containers would that be, exactly? The ones that haven't yet been opened? Link to comment Share on other sites More sharing options...
RoboMat Posted August 2, 2013 Share Posted August 2, 2013 No, unfortunately not yet, only Johndough beer. :cool: And which containers would that be, exactly? The ones that haven't yet been opened? I'm not sure exactly but I think it fills the containers in the room you are currently in (might be wrong here). To be sure I'd simply move to the next house and try the containers there Link to comment Share on other sites More sharing options...
johndough Posted August 2, 2013 Share Posted August 2, 2013 I'm not sure exactly but I think it fills the containers in the room you are currently in (might be wrong here). To be sure I'd simply move to the next house and try the containers there Oh, that wouldn't work. I've been everywhere. And the few places I haven't been, I can't remember. I guess I need to do some testing. Asking questions usually saves a lot of time though Link to comment Share on other sites More sharing options...
johndough Posted August 2, 2013 Share Posted August 2, 2013 Looks like require 'Items/SuburbsDistributions' is required and that spawns are done the moment the container is opened. Link to comment Share on other sites More sharing options...
7Roses Posted August 2, 2013 Share Posted August 2, 2013 And which containers would that be, exactly? The ones that haven't yet been opened?well that depends.mostly the containers that you haven't ever been near and now are loaded into the game (screen is nearly the same as the loaded objects field) if the container isn't been loaded ever since the creation of the world it will use the distribution code that has the now new table additions(it goes without saying that the table only is changed when you restart the game and the scripts are ran.) best advice if your testing is to just create a new world. Link to comment Share on other sites More sharing options...
johndough Posted August 2, 2013 Share Posted August 2, 2013 I tested with both an old world and a new, with a 100% chance of spawning a new item. Without the require... none of my new items would spawn (possibly because my mod starts with C and is loaded before the Items directory). The items would not spawn in containers I had already opened. They would, however, spawn in containers inside rooms I had visited(without opening the container). Old or new world didn't matter. Link to comment Share on other sites More sharing options...
Shivster Posted August 7, 2013 Share Posted August 7, 2013 Im having issues with my new File it will not spawn anything at all. tried new game and old game nothing i know its a typo but i have looked at it for hours and cant find it. require "Items/SuburbsDistributions"; JerkyMod = {}JerkyMod.version = "1.0.1";JerkyMod.author = "Shivster";JerkyMod.modName = "Jerky Mod"; function Jerky.init()print("Mod Loaded: " .. JerkysMod.modName .. " by " .. JerkyMod.author .. " (v" .. JerkyMod.version ..")");end table.insert(SuburbsDistributions["Kitten"]["counter"].items, "Jerky.Salt");table.insert(SuburbsDistributions["Kitten"]["counter"].items, 10);table.insert(SuburbsDistributions["Kitten"]["counter"].items, "Jerky.Pepper");table.insert(SuburbsDistributions["Kitten"]["counter"].items, 10);table.insert(SuburbsDistributions["Kitten"]["counter"].items, "Jerky.Soysauce");table.insert(SuburbsDistributions["Kitten"]["counter"].items, 10);table.insert(SuburbsDistributions["Kitten"]["counter"].items, "Jerky.Worcestershire");table.insert(SuburbsDistributions["Kitten"]["counter"].items, 10);table.insert(SuburbsDistributions["Kitten"]["counter"].items, "Jerky.Liquidsmoke");table.insert(SuburbsDistributions["Kitten"]["counter"].items, 10);table.insert(SuburbsDistributions["Kitten"]["counter"].items, "Jerky.Garlicpowder");table.insert(SuburbsDistributions["Kitten"]["counter"].items, 10); Events.OnGameBoot.Add(JerkyMod.init); 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