Jump to content

Recommended Posts

Well, this is my question.

How do you tweak an existing recipe in modmain.lua without it losing it's position?

 

For example Science Machine. It's easy to change it's recipe, but how do you keep it's position in the crafting tab?

STRINGS = GLOBAL.STRINGSRECIPETABS = GLOBAL.RECIPETABSTECH = GLOBAL.TECHRecipe = GLOBAL.RecipeIngredient = GLOBAL.IngredientRecipe ("researchlab", {Ingredient("log", 4), Ingredient("rocks", 4), Ingredient("nitre", 2)}, RECIPETABS.SCIENCE, TECH.NONE, "researchlab_placer")

Using this code makes it drop down to the bottom.

Any help please?

@IcyTheWhite:

local AllRecipes = GLOBAL.AllRecipeslocal Ingredient = GLOBAL.Ingredientlocal RECIPETABS = GLOBAL.RECIPETABSlocal       TECH = GLOBAL.TECHlocal sortkey = AllRecipes["researchlab"].sortkeyAddRecipe("researchlab", {Ingredient("log", 4), Ingredient("rocks", 4), Ingredient("nitre", 2)}, RECIPETABS.SCIENCE, TECH.NONE, "researchlab_placer")AllRecipes["researchlab"].sortkey = sortkey

That's smart. So you copied its sortkey, changed the recipe and than returned its original sortkey.

I understand the logic, but didn't know there was such a function.

 

Edit:

Although it doesn't work for DS RoG at all. These two games are so much different from each other nowadays.

 

For one "AllRecipes" is a nil value in DS RoG, I think it has to be just "Recipe" and "AddRecipe" function doesn't work. Also the ".sortkey" doesn't seem to work the way it does in DST. Do you have any idea what has to be changed?

Edited by IcyTheWhite

@IcyTheWhite:

local Ingredient = GLOBAL.Ingredientlocal RECIPETABS = GLOBAL.RECIPETABSlocal TECH = GLOBAL.TECHlocal game = TheSim:GetGameID()if game == "DS" then	local Recipes = GLOBAL.Recipes	local sortkey = Recipes["researchlab"].sortkey	Recipe("researchlab", {Ingredient("log", 4), Ingredient("rocks", 4), Ingredient("nitre", 2)}, RECIPETABS.SCIENCE, TECH.NONE, "researchlab_placer")	Recipes["researchlab"].sortkey = sortkeyelseif game == "DST" then	local AllRecipes = GLOBAL.AllRecipes	local sortkey = AllRecipes["researchlab"].sortkey	AddRecipe("researchlab", {Ingredient("log", 4), Ingredient("rocks", 4), Ingredient("nitre", 2)}, RECIPETABS.SCIENCE, TECH.NONE, "researchlab_placer")	AllRecipes["researchlab"].sortkey = sortkeyend

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