smajt Posted September 2, 2022 Share Posted September 2, 2022 require "Items/ProceduralDistributions" require "Items/SuburbsDistributions" for key, x in pairs(ProceduralDistributions.list) do if x == nil then return end for index, y in ipairs(x.items) do if y == nil then return end if y == "LouisvilleMap1" or y == "LouisvilleMap2" or y == "LouisvilleMap3" or y == "LouisvilleMap4" or y == "LouisvilleMap5" or y == "LouisvilleMap6" or y == "LouisvilleMap7" or y == "LouisvilleMap8" or y == "LouisvilleMap9" or y == "MuldraughMap" or y == "WestpointMap" or y == "MarchRidgeMap" or y == "RosewoodMap" or y == "RiversideMap" then table.remove(ProceduralDistributions.list[x].items, index) table.remove(ProceduralDistributions.list[x].items, + 1) end end end for index, x in ipairs(SuburbsDistributions["all"]["inventoryfemale"].items) do if y == nil then return end if y == "LouisvilleMap1" or y == "LouisvilleMap2" or y == "LouisvilleMap3" or y == "LouisvilleMap4" or y == "LouisvilleMap5" or y == "LouisvilleMap6" or y == "LouisvilleMap7" or y == "LouisvilleMap8" or y == "LouisvilleMap9" or y == "MuldraughMap" or y == "WestpointMap" or y == "MarchRidgeMap" or y == "RosewoodMap" or y == "RiversideMap" then table.remove(x.items, index) table.remove(x.items, index + 1) end end for index, x in ipairs(SuburbsDistributions["Bag_SurvivorBag"].items) do if y == nil then return end if y == "LouisvilleMap1" or y == "LouisvilleMap2" or y == "LouisvilleMap3" or y == "LouisvilleMap4" or y == "LouisvilleMap5" or y == "LouisvilleMap6" or y == "LouisvilleMap7" or y == "LouisvilleMap8" or y == "LouisvilleMap9" or y == "MuldraughMap" or y == "WestpointMap" or y == "MarchRidgeMap" or y == "RosewoodMap" or y == "RiversideMap" then table.remove(x.items, index) table.remove(x.items, index + 1) end end So im trying to remove all maps from loot tables. code that i shared is not working. if someone could write me an example or give me some links to forum posts or docs about it. Link to comment Share on other sites More sharing options...
Hugo Qwerty Posted September 2, 2022 Share Posted September 2, 2022 It looks like Lua is re-indexing the table after each remove, so you want to remove the same index twice (rather than removing index and then index + 1), the second time it will be a different entry as everythig will have moved 1 place after the first remove call. Link to comment Share on other sites More sharing options...
smajt Posted September 2, 2022 Author Share Posted September 2, 2022 56 minutes ago, Hugo Qwerty said: It looks like Lua is re-indexing the table after each remove, so you want to remove the same index twice (rather than removing index and then index + 1), the second time it will be a different entry as everythig will have moved 1 place after the first remove call. require "Items/ItemPicker" require "Items/SuburbsDistributions" require "Items/ProceduralDistributions" require "Vehicles/VehicleDistributions" local function RemoveLoot (name) local cache = {} local function patch(t) for i=#t,1,-1 do if t[i] == name then table.remove(t,i) table.remove(t,i) end end end for room,r in ipairs(SuburbsDistributions) do for container,c in pairs(r) do if c.items and not cache[c.items] then cache[c.items] = true patch(c.items) end end end for proc,p in ipairs(ProceduralDistributions.list) do if p.items and not cache[p.items] then cache[p.items] = true patch(p.items) end if p.junk and not cache[p.junk] then cache[p.junk] = true patch(p.junk) end end for vehicle,p in pairs(VehicleDistributions) do if p.items and not cache[p.items] then cache[p.items] = true patch(p.items) end if p.junk and not cache[p.junk] then cache[p.junk] = true patch(p.junk) end end end RemoveLoot('LouisvilleMap1') RemoveLoot('LouisvilleMap2') RemoveLoot('LouisvilleMap3') RemoveLoot('LouisvilleMap4') RemoveLoot('LouisvilleMap5') RemoveLoot('LouisvilleMap6') RemoveLoot('LouisvilleMap7') RemoveLoot('LouisvilleMap8') RemoveLoot('LouisvilleMap9') RemoveLoot('MuldraughMap') RemoveLoot('WestpointMap') RemoveLoot('MarchRidgeMap') RemoveLoot('RosewoodMap') RemoveLoot('RiversideMap') still not working Link to comment Share on other sites More sharing options...
Hugo Qwerty Posted October 1, 2022 Share Posted October 1, 2022 (edited) require "Items/Distributions" local function RemoveZombieLoot(name) local dist = Distributions[1]["all"]["inventoryfemale"]["items"] for i=#dist-1,1,-2 do if dist[i] == name then table.remove(dist,i) table.remove(dist,i) end end dist = Distributions[1]["all"]["inventorymale"]["items"] for i=#dist-1,1,-2 do if dist[i] == name then table.remove(dist,i) table.remove(dist,i) end end end RemoveZombieLoot("Pills") RemoveZombieLoot("PillsAntiDep") RemoveZombieLoot("PillsBeta") RemoveZombieLoot("PillsVitamins") Edit: now with code that actually works. Code goes in /server/ Edited October 2, 2022 by Hugo Qwerty Fixed code 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