Jump to content

Custom Tab, Tech and Prototyper troubles


Recommended Posts

I've made a custom structure, placeholder name is "Cave Machine", and when built lets you access the "CaveTech" tech tree, along with the "CaveTab" crafting tab. I've followed guides, everything of the sort. I'll attach the entire mod to this thread, but here are the key lines of code.

Spoiler

 

So I've used the "custom_tech_tree" api thing, in my modmain is this.


modimport "custom_tech_tree.lua"
AddNewTechTree("CAVETECH")
local CaveTab = AddRecipeTab("Cave", 10, "images/cavetab.xml", "cavetab.tex")
STRINGS.TABS.CAVETAB="Cave"

In the cavemachine prefab, is this


    inst:AddComponent("prototyper")
    inst.components.prototyper.trees = TUNING.PROTOTYPER_TREES.CAVETECH

an example for a recipe,


AddRecipe("lightbulb", { Ingredient("petals", 6), Ingredient("flint", 2) }, 
RECIPETABS.CAVETAB, 
TECH.CAVETECH, 
nil, nil, true, 6)

 

 

 

here is the error from the crash log, it doesn't reference any of my code or any of my files, so I am kinda stumped.

Spoiler

[00:00:58]: [string "scripts/components/builder.lua"]:191: attempt to index field 'accessible_tech_trees' (a nil value)
LUA ERROR stack traceback:
scripts/components/builder.lua:191 in (method) EvaluateTechTrees (Lua) <135-243>
   self =
      exclude_tags = table: 61A79D68
      buffered_builds = table: 61A79CF0
      current_prototyper = 114738 - cavemachine (valid:true)
      recipes = table: 61A793B8
      station_recipes = table: 670E0CA0
      bonus_tech_level = 0
      inst = 109283 - wilson (valid:true)
      _ = table: 61A886D8
   pos = (77.60, 0.00, 98.87)
   ents = table: 670E0A98
   old_accessible_tech_trees = table: 670E0C00
   old_station_recipes = table: 670E7708
   old_prototyper = nil
   prototyper_active = true
scripts/components/builder.lua:108 in (method) OnUpdate (Lua) <107-109>
   self =
      exclude_tags = table: 61A79D68
      buffered_builds = table: 61A79CF0
      current_prototyper = 114738 - cavemachine (valid:true)
      recipes = table: 61A793B8
      station_recipes = table: 670E0CA0
      bonus_tech_level = 0
      inst = 109283 - wilson (valid:true)
      _ = table: 61A886D8
scripts/update.lua:192 in () ? (Lua) <149-228>
   dt = 0.033333335071802
   tick = 614
   k = 109283
   v = 109283 - wilson (valid:true)
   cmp = table: 61A886B0

[00:00:58]: [string "scripts/components/builder.lua"]:191: attempt to index field 'accessible_tech_trees' (a nil value)
LUA ERROR stack traceback:
    scripts/components/builder.lua:191 in (method) EvaluateTechTrees (Lua) <135-243>
    scripts/components/builder.lua:108 in (method) OnUpdate (Lua) <107-109>
    scripts/update.lua:192 in () ? (Lua) <149-228>
 

Any help would be  greatly appreciated! 

Cave Content Surfaced.zip

Edited by Cherryzion
Link to comment
Share on other sites

-- modmain
-- We will add the CAVESCIENCE crafting tab

-- Add it to the tech trees
local TechTree = require("techtree")
table.insert(TechTree.AVAILABLE_TECH, "CAVESCIENCE")


-- NONE gets created before our thing is added to AVAILABLE_TECH, so hack it in
TECH.NONE.CAVESCIENCE = 0


-- Our tab
-- String and ID, num sort, atlas, image, owner tag, crafting station
-- Either is valid for modmain recipes: MYCAVETAB or CUSTOM_RECIPETABS.CAVESCIENCE
local MYCAVETAB = AddRecipeTab("CAVESCIENCE", 10, "images/cavetab.xml", "cavetab.tex", nil, true)

-- Replace the ID for a the name
STRINGS.TABS.CAVESCIENCE = "Cave"


-- Our science levels (set to one since one prototyper is enough)
TECH.CAVESCIENCE_ONE = {CAVESCIENCE = 1}

-- Cave machine gets same bonuses as CAVESCIENCE_ONE so it unlocks it
TUNING.PROTOTYPER_TREES.CAVEMACHINE = TechTree.Create({CAVESCIENCE = 1})


-- prototyper

inst:AddComponent("prototyper")
inst.components.prototyper.trees = TUNING.PROTOTYPER_TREES.CAVEMACHINE

 

CCS.zip

Link to comment
Share on other sites

8 hours ago, DarkXero said:

-- modmain
-- We will add the CAVESCIENCE crafting tab

-- Add it to the tech trees
local TechTree = require("techtree")
table.insert(TechTree.AVAILABLE_TECH, "CAVESCIENCE")


-- NONE gets created before our thing is added to AVAILABLE_TECH, so hack it in
TECH.NONE.CAVESCIENCE = 0


-- Our tab
-- String and ID, num sort, atlas, image, owner tag, crafting station
-- Either is valid for modmain recipes: MYCAVETAB or CUSTOM_RECIPETABS.CAVESCIENCE
local MYCAVETAB = AddRecipeTab("CAVESCIENCE", 10, "images/cavetab.xml", "cavetab.tex", nil, true)

-- Replace the ID for a the name
STRINGS.TABS.CAVESCIENCE = "Cave"


-- Our science levels (set to one since one prototyper is enough)
TECH.CAVESCIENCE_ONE = {CAVESCIENCE = 1}

-- Cave machine gets same bonuses as CAVESCIENCE_ONE so it unlocks it
TUNING.PROTOTYPER_TREES.CAVEMACHINE = TechTree.Create({CAVESCIENCE = 1})


-- prototyper

inst:AddComponent("prototyper")
inst.components.prototyper.trees = TUNING.PROTOTYPER_TREES.CAVEMACHINE

 

CCS.zip

thank you! it works 

Link to comment
Share on other sites

@DarkXero Oops actually, been testing. The cave tab (and cavescience? it's kinda hard to know the difference between the two when they're bsaically the same thing) becomes available with any crafting machine. Science machine, alchemy engine, ancient pseudoscience, all of em. Not sure what could cause this. In case you wanted to poke through again, here's the latest version.

Cave Content Surfaced.zip

Link to comment
Share on other sites

41 minutes ago, Cherryzion said:

Oops actually, been testing. The cave tab (and cavescience? it's kinda hard to know the difference between the two when they're bsaically the same thing) becomes available with any crafting machine.

-- NONE gets created before our thing is added to AVAILABLE_TECH, so hack it in
TECH.NONE.CAVESCIENCE = 0

-- PROTOTYPER_TREES also are created before
-- And apparently a nil means "you can make it" instead of a 0
for k, v in pairs(TUNING.PROTOTYPER_TREES) do
	v.CAVESCIENCE = 0
end

That for loop will fix that.

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...