Jump to content

Wickerbottom's Tech bonus on custom techs?


Recommended Posts

Hey everyone, I'm back at modding and want to start off by fixing my previous mods. One of my mods, Cave Content Surfaced, makes a new prototype machine, recipe tab, and science level.

The mod works pretty well as far as I can tell, except for one error, that if you play as Wickerbottom it crashes the game. From what I can tell, the problem occurs because the game tries to apply Wickerbottom's science bonus onto my "CAVESCIENCE", but I don't have some sort of variable set for her bonus and it crashes the game. 

Here is the error in the crash log;

Spoiler

[00:12:28]: [string "scripts/components/builder.lua"]:497: attempt to compare number with nil
LUA ERROR stack traceback:
scripts/components/builder.lua:497 in () ? (Lua) <489-507>
   self =
      exclude_tags = table: 68AD3C38
      buffered_builds = table: 68AD3A30
      recipes = table: 68AD3210
      station_recipes = table: 68AD3788
      bonus_tech_level = 0
      accessible_tech_trees = table: 68AD38A0
      inst = 110516 - wickerbottom (valid:true)
      _ = table: 68AD2F90
   recname = wall_wood_item
   recipe = table: 201DCF48
   has_tech = true
   i = 9
   v = CAVESCIENCE
=(tail call):-1 in ()  (tail) <-1--1>
scripts/widgets/crafting.lua:184 in (method) UpdateRecipes (Lua) <176-219>
   self =
      but_h = 127
      callbacks = table: 19520580
      upconnector = Image - images/hud.xml:craft_sep_h.tex
      valid_recipes = table: 188CC9A0
      scrolldir = true
      inst = 110917 -  (valid:true)
      focus = false
      idx = -1
      but_w = 127
      children = table: 19520800
      max_slots = 10
      focus_flow_args = table: 195205A8
      focus_target = false
      current_slots = 10
      downendcapbg = Image - images/hud.xml:craft_sep.tex
      upbutton = BUTTON
      owner = 110516 - wickerbottom (valid:true)
      downbutton = BUTTON
      can_fade_alpha = true
      upendcapbg = Image - images/hud.xml:craft_sep.tex
      downconnector = Image - images/hud.xml:craft_sep_h.tex
      name = Crafting
      enabled = true
      focus_flow = table: 19520648
      craftslots = CraftSlots
      shown = true
      bg = TileBG
   k = wall_wood_item
   v = table: 201DCF48
scripts/widgets/crafting.lua:47 in (field) _ctor (Lua) <13-48>
   self =
      but_h = 127
      callbacks = table: 19520580
      upconnector = Image - images/hud.xml:craft_sep_h.tex
      valid_recipes = table: 188CC9A0
      scrolldir = true
      inst = 110917 -  (valid:true)
      focus = false
      idx = -1
      but_w = 127
      children = table: 19520800
      max_slots = 10
      focus_flow_args = table: 195205A8
      focus_target = false
      current_slots = 10
      downendcapbg = Image - images/hud.xml:craft_sep.tex
      upbutton = BUTTON
      owner = 110516 - wickerbottom (valid:true)
      downbutton = BUTTON
      can_fade_alpha = true
      upendcapbg = Image - images/hud.xml:craft_sep.tex
      downconnector = Image - images/hud.xml:craft_sep_h.tex
      name = Crafting
      enabled = true
      focus_flow = table: 19520648
      craftslots = CraftSlots
      shown = true
      bg = TileBG
   owner = 110516 - wickerbottom (valid:true)
   num_slots = 10
   but_w = 127
   but_h = 127
scripts/widgets/controllercrafting.lua:19 in (field) _ctor (Lua) <18-52>
   self =
      but_h = 127
      callbacks = table: 19520580
      upconnector = Image - images/hud.xml:craft_sep_h.tex
      valid_recipes = table: 188CC9A0
      scrolldir = true
      inst = 110917 -  (valid:true)
      focus = false
      idx = -1
      but_w = 127
      children = table: 19520800
      max_slots = 10
      focus_flow_args = table: 195205A8
      focus_target = false
      current_slots = 10
      downendcapbg = Image - images/hud.xml:craft_sep.tex
      upbutton = BUTTON
      owner = 110516 - wickerbottom (valid:true)
      downbutton = BUTTON
      can_fade_alpha = true
      upendcapbg = Image - images/hud.xml:craft_sep.tex
      downconnector = Image - images/hud.xml:craft_sep_h.tex
      name = Crafting
      enabled = true
      focus_flow = table: 19520648
      craftslots = CraftSlots
      shown = true
      bg = TileBG
   owner = 110516 - wickerbottom (valid:true)
scripts/class.lua:181 in (upvalue) ControllerCrafting (Lua) <171-184>
   class_tbl = table: 18E35CD0
   arg = nil
   obj = Crafting
scripts/widgets/crafttabs.lua:62 in (field) _ctor (Lua) <44-223>
   self =
      enabled = true
      focus_target = false
      craft_idx_by_tab = table: 19520788
      shown = true
      owner = 110516 - wickerbottom (valid:true)
      can_fade_alpha = true
      focus_flow_args = table: 195203C8
      inst = 110916 -  (valid:true)
      focus 
[00:12:28]: [string "scripts/components/builder.lua"]:497: attempt to compare number with nil
LUA ERROR stack traceback:
    scripts/components/builder.lua:497 in () ? (Lua) <489-507>
    =(tail call):-1 in ()  (tail) <-1--1>
    scripts/widgets/crafting.lua:184 in (method) UpdateRecipes (Lua) <176-219>
    scripts/widgets/crafting.lua:47 in (field) _ctor (Lua) <13-48>
    scripts/widgets/controllercrafting.lua:19 in (field) _ctor (Lua) <18-52>
    scripts/class.lua:181 in (upvalue) ControllerCrafting (Lua) <171-184>
    scripts/widgets/crafttabs.lua:62 in (field) _ctor (Lua) <44-223>
    scripts/class.lua:181 in (upvalue) CraftTabs (Lua) <171-184>
    scripts/widgets/controls.lua:141 in (upvalue) constructor (Lua) <28-158>
    scripts/modutil.lua:147 in (upvalue) constructor (Lua) <146-149>
    scripts/modutil.lua:147 in (upvalue) constructor (Lua) <146-149>
    scripts/modutil.lua:147 in (upvalue) constructor (Lua) <146-149>
    

I also uploaded the modmain and prefab file for the prototyper.

Any help would be greatly appreciated!

help fix me mod.zip

Link to comment
Share on other sites

hm... since 497 line is :
if recipe.level[v] > (self[string.lower(v).."_bonus"] or 0) then
I think that means recipe.level[v] is nil... Cause if the other would be nil, the "or 0" would replace it with 0.

But I don't know why this happens.

Maybe it would be better to implement the new techtree like I did in my quest mod?  with help of the custom_tech_tree.lua ?
There I had no problems.

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
 Share

×
  • Create New...