Riot_ Posted January 18, 2022 Share Posted January 18, 2022 (edited) This mod 394470072 or "Additional set pieces" used to work just fine until recently it is crashing my game. I got help from someone to help narrow it down but i now need to fix it because it is preventing me from joining my 100 day + world. Here is the file it corrupts and the server log for master caves seems to be ok colourful_mushroom_farm.lua server_log_2022-01-18-14-18-49.txt Edited January 18, 2022 by Riot_ I would appreciate if anyone would help me debug it Link to comment https://forums.kleientertainment.com/forums/topic/136974-mod-394470072-broken-my-game/ Share on other sites More sharing options...
Monti18 Posted January 19, 2022 Share Posted January 19, 2022 Try replacing the OnLoad function with this one: Spoiler -- This function is called when the scenario is created. local function OnLoad(inst, scenariorunner) SetTrapOnEntities(inst, scenariorunner) for i = 1, 5 do local poop = GetPoop(inst) if poop and next(poop) ~= nil then local v = poop[math.random(#poop)] local x, y, z = v.Transform:GetWorldPosition() v.scene_putininventoryfn = function(inst) OnTriggerTrap(inst, scenariorunner, x, y, z) end v:ListenForEvent("onpickup", v.scene_putininventoryfn) end end end This kind of error can happen if your list is empty, as the lenght is 0 in this case and math.random(x) == math.random(1,x), which would be in this case math.random(1,0) which causes an error. By checking next(poop), you check if the table has a least 1 entry. 1 Link to comment https://forums.kleientertainment.com/forums/topic/136974-mod-394470072-broken-my-game/#findComment-1533643 Share on other sites More sharing options...
Riot_ Posted January 19, 2022 Author Share Posted January 19, 2022 10 hours ago, Monti18 said: Try replacing the OnLoad function with this one: Hide contents -- This function is called when the scenario is created. local function OnLoad(inst, scenariorunner) SetTrapOnEntities(inst, scenariorunner) for i = 1, 5 do local poop = GetPoop(inst) if poop and next(poop) ~= nil then local v = poop[math.random(#poop)] local x, y, z = v.Transform:GetWorldPosition() v.scene_putininventoryfn = function(inst) OnTriggerTrap(inst, scenariorunner, x, y, z) end v:ListenForEvent("onpickup", v.scene_putininventoryfn) end end end This kind of error can happen if your list is empty, as the lenght is 0 in this case and math.random(x) == math.random(1,x), which would be in this case math.random(1,0) which causes an error. By checking next(poop), you check if the table has a least 1 entry. OMG THAT FIX IT THE WORLD WORKS AGAIN THANK YOU SO MUCH YOU SAVED ME SO MUCH TIME AND EFFORT Link to comment https://forums.kleientertainment.com/forums/topic/136974-mod-394470072-broken-my-game/#findComment-1533772 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