Monti18 Posted May 14, 2021 Share Posted May 14, 2021 Hi everyone, I'm getting a crash when I'm trying to change the effectiveness of a tool. I made my own component do to this, the strange thing is that for tools with only the action chopping there is no crash, for everything else it crashes (see crashlog in spoiler). function Mod_Modifier:AddModifierTool() local mod = string.upper(tostring(self.modifier)) if self.inst.components.tool then if self.inst.components.tool:CanDoAction(ACTIONS.CHOP) then local old_eff = self.inst.components.tool.actions[ACTIONS.CHOP] if old_eff then self.inst.components.tool:SetAction(ACTIONS.CHOP, old_eff * TUNING_MELANIE.MODIFIERS[mod]["TOOL"]["CHOP"]* 1.5) end end if self.inst.components.tool:CanDoAction(ACTIONS.NET) then local old_eff = self.inst.components.tool.actions[ACTIONS.NET] if old_eff then self.inst.components.tool:SetAction(ACTIONS.NET, old_eff * TUNING_MELANIE.MODIFIERS[mod]["TOOL"]["NET"]* 1.5) <--------here is the crash end end end end I also tried it by changing the effectiveness directly like this, but the same thing: self.inst.components.tool.actions[ACTIONS.NET] = old_eff * TUNING_MELANIE.MODIFIERS[mod]["TOOL"]["NET"] If someone has an idea of what I could try or why it doens't work, please let me know. Thanks in advance, Monti Spoiler [00:08:28]: [string "../mods/Melanie/scripts/components/mod_modi..."]:259: attempt to perform arithmetic on field 'NET' (a nil value) LUA ERROR stack traceback: ../mods/Melanie/scripts/components/mod_modifier.lua:259 in (method) AddModifierTool (Lua) <209-268> self = number = 4 inst = 118397 - bugnet(LIMBO) (valid:true) modifier = broken nameset = false equipment = tool hasmod = false mod = BROKEN old_eff = 1 ../mods/Melanie/scripts/components/mod_modifier.lua:136 in (method) AddModifier (Lua) <106-144> self = number = 4 inst = 118397 - bugnet(LIMBO) (valid:true) modifier = broken nameset = false equipment = tool hasmod = false ../mods/Melanie/scripts/components/mod_modifier.lua:103 in (method) ChooseEquipment (Lua) <73-104> self = number = 4 inst = 118397 - bugnet(LIMBO) (valid:true) modifier = broken nameset = false equipment = tool hasmod = false ../mods/Melanie/modmain.lua:2205 in (field) fn (Lua) <2203-2207> inst = 118397 - bugnet(LIMBO) (valid:true) scripts/scheduler.lua:177 in (method) OnTick (Lua) <155-207> self = running = table: 10CE7F00 waitingfortick = table: 10CE81F8 tasks = table: 10CE82C0 waking = table: 37CC6700 attime = table: 10CE8298 hibernating = table: 10CE7E10 tick = 600 k = PERIODIC 118397: 0.100000 v = true already_dead = false scripts/scheduler.lua:371 in (global) RunScheduler (Lua) <369-377> tick = 600 scripts/update.lua:185 in () ? (Lua) <164-243> dt = 0.033333335071802 tick = 600 i = 600 [00:08:28]: [string "../mods/Melanie/scripts/components/mod_modi..."]:259: attempt to perform arithmetic on field 'NET' (a nil value) LUA ERROR stack traceback: ../mods/Melanie/scripts/components/mod_modifier.lua:259 in (method) AddModifierTool (Lua) <209-268> ../mods/Melanie/scripts/components/mod_modifier.lua:136 in (method) AddModifier (Lua) <106-144> ../mods/Melanie/scripts/components/mod_modifier.lua:103 in (method) ChooseEquipment (Lua) <73-104> ../mods/Melanie/modmain.lua:2205 in (field) fn (Lua) <2203-2207> scripts/scheduler.lua:177 in (method) OnTick (Lua) <155-207> scripts/scheduler.lua:371 in (global) RunScheduler (Lua) <369-377> scripts/update.lua:185 in () ? (Lua) <164-243> [00:08:28]: Warning: Widget:SetFocusFromChild is happening on a widget outside of the screen/widget hierachy. This will cause focus moves to fail. Is ScriptErrorWidget not a screen? [00:08:28]: stack traceback: scripts/widgets/widget.lua:604 in (method) SetFocusFromChild (Lua) <601-626> scripts/widgets/widget.lua:623 in (method) SetFocusFromChild (Lua) <601-626> scripts/widgets/widget.lua:623 in (method) SetFocusFromChild (Lua) <601-626> scripts/widgets/widget.lua:648 in (method) SetFocus (Lua) <628-657> scripts/widgets/menu.lua:83 in (method) SetFocus (Lua) <74-85> scripts/widgets/scripterrorwidget.lua:109 in (method) OnUpdate (Lua) <102-119> scripts/update.lua:95 in () ? (Lua) <33-134> [00:08:28]: replica:table: 0B10D298 [00:08:28]: modifier:forceful 1 Link to comment Share on other sites More sharing options...
Gleenus Posted May 14, 2021 Share Posted May 14, 2021 [00:08:28]: [string "../mods/Melanie/scripts/components/mod_modi..."]:259: attempt to perform arithmetic on field 'NET' (a nil value) This mean that when the game tries to access ".NET" from something, it was not declared So TUNING_MELANIE.MODIFIERS[mod]["TOOL"]["NET"] This is not declared If you try to print it you will see it its "nil" 1 Link to comment Share on other sites More sharing options...
Monti18 Posted May 15, 2021 Author Share Posted May 15, 2021 THANK YOU SO MUCH! I was really frustrated as I couldn't find the error, I didn't even think of checking my tunings! I was so focused on thinking that it had problems to find the ACTIONS.NET that I didn't thought of my other NET variable... Lesson learned! 1 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