Jump to content

(How to make?) new tech branch


Recommended Posts

So I made my own character mod but I want to advance how it works, I have some items with my character but I want to make them only craft able with a unique machine, so I have added a new machine to my mod but I need a completely new Tech branch that only effects the items that I want to craft.

Simply put, how do I add a new Tech branch to my character mod ?

Link to comment
Share on other sites

This adds a new tech branch called skeleton, used in my summons mod. Code from modmain.lua

 

GLOBAL.TECH.NONE.SKELETON = 0for k,v in pairs(GLOBAL.TUNING.PROTOTYPER_TREES) do    GLOBAL.TUNING.PROTOTYPER_TREES[k].SKELETON = 0endGLOBAL.TUNING.PROTOTYPER_TREES.SKELETON = {SCIENCE = 0,MAGIC = 0,ANCIENT = 0,SKELETON=1}
the recipe
 
Recipe( "summonskeleton", { Ingredient("nightmarefuel", 1) }, RECIPETABS.SUMMONS, {SKELETON = 1})

and finally the prefab that gives the "tech aura"

local function enteringradiusofskeleton(inst)	--print ("entering proximity of skeleton")endlocal function leavingradiusofskeleton(inst)	--print ("left proximity of skeleton")	local playervar = GLOBAL.GetPlayer()	if playervar then		playervar.components.builder.accessible_tech_trees = GLOBAL.TECH.NONE	endend-- add undeadskeleton prototype type to skeletonsfunction HF_addskeletonprototype(inst)	inst:AddTag("prototyper")	inst:AddComponent("prototyper")		inst.components.prototyper.trees = GLOBAL.TUNING.PROTOTYPER_TREES.SKELETON		-- these functions have to exist even if one does nothing		inst.components.prototyper.onturnoff = leavingradiusofskeleton		inst.components.prototyper.onturnon = enteringradiusofskeletonendAddPrefabPostInit("skeleton", HF_addskeletonprototype)
 
 
also need to modify a builder function to allow new tech trees
 
--overwrite builder knowsrecipe to not ignore new tech treefunction builderpostinit(inst)	local oldKnowsRecipe = inst.KnowsRecipe	inst.KnowsRecipe = function(self, recname)		local recipe=GLOBAL.GetRecipe(recname)		if oldKnowsRecipe(self, recname) and not self.freebuildmode then			if recipe and recipe.level.SKELETON and recipe.level.SKELETON > 0 then				return false			else				return true			end		end		return oldKnowsRecipe(self, recname)	endendAddComponentPostInit("builder", builderpostinit)

 

Link to comment
Share on other sites

 

This adds a new tech branch called skeleton, used in my summons mod. Code from modmain.lua

 

GLOBAL.TECH.NONE.SKELETON = 0for k,v in pairs(GLOBAL.TUNING.PROTOTYPER_TREES) do    GLOBAL.TUNING.PROTOTYPER_TREES[k].SKELETON = 0endGLOBAL.TUNING.PROTOTYPER_TREES.SKELETON = {SCIENCE = 0,MAGIC = 0,ANCIENT = 0,SKELETON=1}
the recipe
 
Recipe( "summonskeleton", { Ingredient("nightmarefuel", 1) }, RECIPETABS.SUMMONS, {SKELETON = 1})

and finally the prefab that gives the "tech aura"

local function enteringradiusofskeleton(inst)	--print ("entering proximity of skeleton")endlocal function leavingradiusofskeleton(inst)	--print ("left proximity of skeleton")	local playervar = GLOBAL.GetPlayer()	if playervar then		playervar.components.builder.accessible_tech_trees = GLOBAL.TECH.NONE	endend-- add undeadskeleton prototype type to skeletonsfunction HF_addskeletonprototype(inst)	inst:AddTag("prototyper")	inst:AddComponent("prototyper")		inst.components.prototyper.trees = GLOBAL.TUNING.PROTOTYPER_TREES.SKELETON		-- these functions have to exist even if one does nothing		inst.components.prototyper.onturnoff = leavingradiusofskeleton		inst.components.prototyper.onturnon = enteringradiusofskeletonendAddPrefabPostInit("skeleton", HF_addskeletonprototype)
 
 
also need to modify a builder function to allow new tech trees
 
--overwrite builder knowsrecipe to not ignore new tech treefunction builderpostinit(inst)	local oldKnowsRecipe = inst.KnowsRecipe	inst.KnowsRecipe = function(self, recname)		local recipe=GLOBAL.GetRecipe(recname)		if oldKnowsRecipe(self, recname) and not self.freebuildmode then			if recipe and recipe.level.SKELETON and recipe.level.SKELETON > 0 then				return false			else				return true			end		end		return oldKnowsRecipe(self, recname)	endendAddComponentPostInit("builder", builderpostinit)

so does all of this just go in the Mod main or is this several .lua's ? ty btw

 

Link to comment
Share on other sites

when I add this to my mod I get a message saying:

 

...ommon/sont_starve/data/scripts/widgets/craftable.lua:249: table index is nil

LUA ERROR stack traceback:

     C:/Program Files (x86/Steam/steamapps/common/dont_starve/data/scripts/widgets/crafttabs.lua(249,1) in function 'DoUpdateRecipes'

     C:/Program Files (x86/Steam/steamapps/common/dont_starve/data/scripts/widgets/crafttabs.lua(189,1) in function 'OnUpdate'

     C:/Program Files (x86/Steam/steamapps/common/dont_starve/data/scripts/frontend.lua(538,1) in fuction 'Update'

     C:/Program Files (x86/Steam/steamapps/common/dont_starve/data/scripts/update.lua(46,1)

 

What does this mean ?

Link to comment
Share on other sites

You'll have to adapt the code for your own purposes, obviously. I'm guessing the above problem is because you don't have a SUMMONS tab as referenced in the recipe. Either way, this is not code you can just copy-paste. You'll have to go through every detail yourself.

Link to comment
Share on other sites

You'll have to adapt the code for your own purposes, obviously. I'm guessing the above problem is because you don't have a SUMMONS tab as referenced in the recipe. Either way, this is not code you can just copy-paste. You'll have to go through every detail yourself.

 

Heya ty very much for all the help, I have *** almost all working now thanks to you :grin:

 

1 last question though if you don't mind answering it, at the moment the items on my tab have no pictures inside the tab window, every attempt I have made to tell the game the Recipes atlas I just get the same error, the game simply shuts down without giving me any error message at all & I end up back at my desktop, I have included a picture of the script adding the items with no tab icons to show you what I am referring too

post-417812-0-82324600-1408099537_thumb.

Link to comment
Share on other sites

 

Example from Summons mod:

local temprecipe0 = Recipe( "summonskeleton", { Ingredient("nightmarefuel", 1) }, RECIPETABS.SUMMONS, {SKELETON = 1})	temprecipe0.atlas = "images/inventoryimages/summonskeleton.xml"

 

 

yeah for some reasson that is not working for me at all, I tried & it just crashes the game completely leaving me on a menue I cant press anything on & I have to use Ctrl, Alt, Del to get out of it.

here are too pictures showing that I did the equivelant.

post-417812-136836.jpg

post-417812-0-45377400-1408100453_thumb.

Link to comment
Share on other sites

...common/dont_starve/data/../mods/Motoko Character/scripts/prefabs/mkh.lua:194: unfinished string near '"images/inventoryimages/crossbow.xml'

You're missing a " at the end of that line

 

Also you can remove AddMinimapAtlas("images/inventoryimages/crossbow.xml")  

Link to comment
Share on other sites

...common/dont_starve/data/../mods/Motoko Character/scripts/prefabs/mkh.lua:194: unfinished string near '"images/inventoryimages/crossbow.xml'

You're missing a " at the end of that line

 

Also you can remove AddMinimapAtlas("images/inventoryimages/crossbow.xml")  

 

yer I realized that I was missing the " on the end shortly after but when I add it the game still crashes for me :(

Link to comment
Share on other sites

...common/dont_starve/data/../mods/Motoko Character/scripts/prefabs/mkh.lua:194: unfinished string near '"images/inventoryimages/crossbow.xml'

You're missing a " at the end of that line

 

Also you can remove AddMinimapAtlas("images/inventoryimages/crossbow.xml")  

 

 

it keeps saying "AccessibleTechTree" = (nil value)

log.txt

Link to comment
Share on other sites

This thread might be a bit old, but I've also got a question about this. Basically I want to create a custom tech tree which holds recipes for normally uncraftable items. Sounds pretty easy, but I've got no idea how to add the custom tech tree.

Link to comment
Share on other sites

This thread might be a bit old, but I've also got a question about this. Basically I want to create a custom tech tree which holds recipes for normally uncraftable items. Sounds pretty easy, but I've got no idea how to add the custom tech tree.

 

Here's an example from my most recent mod (all in modmain.lua) including syntax comments:

--this is just to simplify thingslocal Recipe = GLOBAL.Recipelocal RECIPETABS = GLOBAL.RECIPETABSlocal STRINGS = GLOBAL.STRINGSlocal TECH = GLOBAL.TECHSTRINGS.TABS.ELECTRIC = "Electricity" --name as seen in-game--[tab_code_name] = {str = tab_code_name, sort= position, icon = symbol_file, icon_atlas = symbol_map}RECIPETABS['ELECTRIC'] = {str = "ELECTRIC", sort=8, icon = "electric.tex", icon_atlas = "electric.xml"}--..._DESC.craftable_thing = Crafting window descriptionSTRINGS.RECIPE_DESC.WIRESPOT = "Wireless wire! Legitimate and safe!"--random_name = (craftable_thing, {ingredients(name,count)},tab_code_name,research_tier,optional_structure_preview)local rec = Recipe("generator_coal", {Ingredient("goldnugget",3),Ingredient("cutstone",3),Ingredient("gears",1)}, RECIPETABS.ELECTRIC, TECH.SCIENCE_ONE, "generator_coal_placer")--these are for the item imagerec.atlas = "images/recipe.xml"rec.image = "recipe.tex"

Many big and big-ish mods have custom tech trees, so you won't run short of examples.

Link to comment
Share on other sites

Thx, but I already answered my own question a few hours after asking it. Currently I'm trying to do something else, but I don't think this is the correct thread about it. Basically I'm trying to make a complete port of craftable uncraftables - I already removed all the recipes for items which currently aren't in the game (I hope) and ATM I'm trying to figure out why some recipes make the game crash. It says that it failed to get the picture for the recipe or something, but I'm 100% that the item/entity is ALREADY in the game.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
×
  • Create New...