JC Denton Posted January 19, 2023 Share Posted January 19, 2023 (edited) Hi, I've just started using lua to make some mods and have hit a roadblock. I'm trying to make containers re-roll their loot if they end up rolling empty. (the ultimate goal is to have them re-roll only once, so there is still a chance they could be empty, but the loot rate will still be a bit more consistent). It looks like the class "zombie.Lua.LuaManager" has the function "fillContainer()" but it seems I can't use "zombie.Lua.LuaManager" because it's not listed in "zombie.Lua.LuaManager.GlobalObject" which is the only outward-facing class for lua modding as I understand it. (sorry if this sentence doesn't make sense, please ignore it.) I've also tried using "zombie.inventory.ItemPickerJava" because it also has a "fillContainer()" function but I can't see how to get a "zombie.inventory" object because container.getInventory returns a "itemContainer" object rather than "inventory" object and I can't find any other ways to use the "zombie.inventory.ItemPickerJava" class. TLDR: The below code fails on the line: "fillContainer(itemContainer, player);" This is the only line of code that needs to be fixed. JCD_MLRSCCDA = JCD_MLRSCCDA JCD_MLRSCCDA_fill_container_iterator = 0 local function JCD_MLRSCCDA_onFillContainer(roomName, containerType, itemContainer) for playerIndex = 0, getNumActivePlayers()-1 do local player = getSpecificPlayer(playerIndex); if player ~= null then local items = itemContainer:getItems(); local itemsLength = items:size(); --print(roomName .. ": " .. containerType .. ": Num Items In Container: " .. itemsLength); if itemsLength == 0 and JCD_MLRSCCDA_fill_container_iterator < 100 then fillContainer(itemContainer, player); JCD_MLRSCCDA_fill_container_iterator = JCD_MLRSCCDA_fill_container_iterator+1; end end end end local function JCD_MLRSCCDA_resetFillContainerIteration() JCD_MLRSCCDA_fill_container_iterator = 0; end Events.OnFillContainer.Add(JCD_MLRSCCDA_onFillContainer) Events.EveryTenMinutes.Add(JCD_MLRSCCDA_resetFillContainerIteration) P.S. I play "CD DA" challenge a lot and noticed if you start with bad loot in the first house, you tend to get bad loot for the rest of the game. (and good loot at the start tends to garner good loot throughout the game). e.g. low amount of medicine in the bathroom cabinets and low amount of books in the living room shelves almost always tends to mean lower amounts of tools, weapons, books, food, medicine etc. in containers for the rest of the game (and I think I may have also noticed less loot on the floor and less scripted houses e.g. houses with a lot of toilet paper or cops/robbers etc.) Is there a seed that gets generated at the start of each game which effects the loot rate for the rest of the game? It's always the same settings and starting location because it's always the CD DA challenge and I always use the "lucky" perk these days but I also noticed this happening without the lucky perk. Edited January 19, 2023 by JC Denton 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