lordixi Posted July 25, 2021 Share Posted July 25, 2021 (edited) In 41.51 many mods are broken due new distribution system. Here working distribution example for 41.52 for little mod "Siphoning Needs Hoses (build 41)". File media\lua\server\Items\RubberHose_Distributions.lua require "Items/Distributions" require "Items/ProceduralDistributions" require "Vehicles/VehicleDistributions" local i, j, d -- Distributions for ProceduralDistributions.lua local myDistTable = { "CrateMechanics", 100, "CrateTools", 100, "GarageTools", 100, "StoreShelfMechanics", 100, "MechanicShelfTools", 100, "MechanicShelfMisc", 100, "GigamartTools", 100, --"KitchenRandom", 100, --"GarageMechanic", 100, } for i = 1, #myDistTable, 2 do table.insert(ProceduralDistributions.list[myDistTable[i]].items, "Base.RubberHose") table.insert(ProceduralDistributions.list[myDistTable[i]].items, myDistTable[i+1]) end -- Distributions for Distributions.lua. May be broken in next updates due devs going to ProceduralDistributions myDistTable = nil myDistTable = { {"all",{ "metal_shelves",100, "crate",100, "bin",100, } }, {"armyhanger",{ "metal_shelves",100, "counter",100, "locker",100, } }, {"storageunit",{ "all",100, } }, {"toolstore",{ "shelves",100, "counter",100, } }, } for i, d in ipairs(myDistTable) do print(d[1]); for j = 1, #d[2], 2 do table.insert(Distributions[1][d[1]][d[2][j]].items, "Base.RubberHose") table.insert(Distributions[1][d[1]][d[2][j]].items, d[2][j+1]) print(d[1],d[2][j]); end end myDistTable = nil myDistTable = { "Bag_SurvivorBag",100, "Toolbox",100, "Bag_JanitorToolbox",100 } for i = 1, #myDistTable, 2 do table.insert(Distributions[1][myDistTable[i]].items, "Base.RubberHose") table.insert(Distributions[1][myDistTable[i]].items, myDistTable[i+1]) end -- Distributions for VehicleDistributions.lua. May be broken in next updates due devs going to ProceduralDistributions myDistTable = nil myDistTable = { "GloveBox", 100, "TrunkStandard", 100, "TrunkHeavy", 100, "TrunkSports", 100, "SurvivalistTruckBed", 100, "FossoilTruckBed", 100, } for i = 1, #myDistTable, 2 do table.insert(VehicleDistributions[myDistTable[i]].items, "Base.RubberHose") table.insert(VehicleDistributions[myDistTable[i]].items, myDistTable[i+1]) end myDistTable = nil Edited July 25, 2021 by lordixi Thuztor, Nebula and A Calm Dragon 1 2 Link to comment Share on other sites More sharing options...
A Calm Dragon Posted August 13, 2021 Share Posted August 13, 2021 Thank you! This helps me greatly, as I'm not that great of a programmer. I can get the idea of what the code does and how it works by looking at it, but writing it myself is not something I'm able to wrap my head around. Link to comment Share on other sites More sharing options...
Nebula Posted August 15, 2021 Share Posted August 15, 2021 How do you regulate the probability of an item appearing (if there are several different items) in this example? Link to comment Share on other sites More sharing options...
lordixi Posted August 25, 2021 Author Share Posted August 25, 2021 (edited) On 8/15/2021 at 7:37 PM, Nebula said: How do you regulate the probability of an item appearing (if there are several different items) in this example? Number past container name is probability. "metal_shelves",100, I set 100 in example just for test, to see that item 100% appear. Now in work code first table looks like: local myDistTable = { "CrateMechanics", 10, "CrateTools", 6, "CrateMetalwork", 6, "CrateFarming", 6, "GarageTools", 10, "GarageMetalwork", 10, "GarageMechanic", 10, "StoreShelfMechanics", 10, "GardenStoreTools", 8, "MechanicShelfTools", 8, "MechanicShelfMisc", 8, "GigamartTools", 4, "GigamartFarming", 6, } Edited August 25, 2021 by lordixi Link to comment Share on other sites More sharing options...
ddraigcymraeg Posted November 3, 2021 Share Posted November 3, 2021 Been a while since I looked at PZ, but I have a mod. You're joking right? There is no backwards compatibilty for code like this below? I see there is a SuburbsDistributions.lua still in PZ41, so hopefully not. This would break TONS of mods if not. require 'Items/SuburbsDistributions' table.insert(SuburbsDistributions["fossoil"]["shelvesmag"].items, "Base.BedfordMap"); table.insert(SuburbsDistributions["fossoil"]["shelvesmag"].items, 0.2); table.insert(SuburbsDistributions["all"]["shelvesmag"].items, "Base.BedfordMap"); table.insert(SuburbsDistributions["all"]["shelvesmag"].items, 0.1); Link to comment Share on other sites More sharing options...
Eggon Posted November 9, 2021 Share Posted November 9, 2021 @lordixiThis is just an example of how to add items to vanilla distribution procedures. Do you know how to properly register a custom procedure? 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