Jump to content

Help with removing items from loot tables.


smajt

Recommended Posts

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

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

  • 4 weeks later...
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. :D

Code goes in /server/

Edited by Hugo Qwerty
Fixed code
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...