Jump to content

Recommended Posts

I know how to make that a character know a recipe when starting, but not an entire tab/tier

 

This is the code i'm using for knowing a recipe at the start :

	inst:DoTaskInTime(0, function(inst)
	inst.components.builder:AddRecipe("backpack")
	inst:PushEvent("unlockrecipe", { recipe = "backpack" })
	end)
	

Put it in your master postinit

Edited by Lumina
17 hours ago, Lumina said:

I know how to make that a character know a recipe when starting, but not an entire tab/tier

 

This is the code i'm using for knowing a recipe at the start :


	inst:DoTaskInTime(0, function(inst)
	inst.components.builder:AddRecipe("backpack")
	inst:PushEvent("unlockrecipe", { recipe = "backpack" })
	end)
	

Put it in your master postinit

It works just fine, thanks!

If you want your character to know all the recipes from tier 1 science (like Wickerbottom) throw this line into the master_postinit section

inst.components.builder.science_bonus = 1

Change it to 2 if you want him to know everything from the alchemy engine. I assume you'd just change "science" to "magic" if you want to do the same for prestihatitator/shadow manipulator, but I don't know. You can test it if you want.

The problem with Wickerbottom is that she don't know all the recipe for tier 1. She got a bonus to science. Meaning that if you craft a science machine, the science bonus allows her to craft all tier 2 recipe with the science machine.

This is a lot more powerful than knowing all the tier 1 recipe.

For unlocking recipes in a certain tab:

inst:DoTaskInTime(0,function()
	local rtab = RECIPETABS.FARM
	if inst.components.builder==nil then return end
	for k,v in pairs(AllRecipes) do 
		if IsRecipeValid(v.name) and v.tab == rtab and inst.components.builder:CanLearn(v.name) and not inst.components.builder:KnowsRecipe(v.name) then
  			inst.components.builder:UnlockRecipe(k)
  		end
	end
end)

For unlocking recipes in certain research levels:

inst:DoTaskInTime(0,function()
    local rtech = "ORPHANAGE"
    local rlvl = 1
    if inst.components.builder==nil then return end
    for k,v in pairs(AllRecipes) do 
        if IsRecipeValid(v.name) and v.level[rtech]==rlvl and inst.components.builder:CanLearn(v.name) and not inst.components.builder:KnowsRecipe(v.name) then
              inst.components.builder:UnlockRecipe(k)
          end
    end
end)

 

Edited by JohnWatson

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
×
  • Create New...