Scolias Posted May 6, 2020 Share Posted May 6, 2020 Hello! I'm making my first mod and I'm trying to change the recipe of an item to reflect it's usefulness of a mod I'm making. This is the last piece of the puzzle before I'm done! I tried putting this Quote Recipe("item1", {Ingredient("ingredient", 1),Ingredient("ingredient", 1), Ingredient("ingredient", 15)}, RECIPETABS.ANCIENT, TECH.ANCIENT_FOUR, nil, nil, true) Where obviously the item and ingredients are replaced with what I'd like them to be, but it only seems to work in RoG only worlds, but if hamlet and/or shipwrecked are linked then it won't change the recipe. Help? Link to comment Share on other sites More sharing options...
Ultroman Posted May 6, 2020 Share Posted May 6, 2020 Modinfo Guide Check that out. I think you may be missing the bools telling the game which DLCs it's compatible with. Link to comment Share on other sites More sharing options...
Scolias Posted May 6, 2020 Author Share Posted May 6, 2020 53 minutes ago, Ultroman said: Modinfo Guide Check that out. I think you may be missing the bools telling the game which DLCs it's compatible with. I do have those, and all the flags are set to true because if i set any of the DLCs to false it crashes on non-RoG worlds. Everything in the mod works perfectly except the recipe change. Is there a different way to make the recipe change in hamlet/sw? Is there a way to have the only only active while you're in RoG but still linked to Hamlet and SW? Thank you. Link to comment Share on other sites More sharing options...
Ultroman Posted May 6, 2020 Share Posted May 6, 2020 I don't have time to make one of my usual tutorials right now, but this should lead you in the right direction. Recipe function declarations for each type of game, taken from their recipe.lua files: -- DS and RoG Recipe = Class(function(self, name, ingredients, tab, level, placer, min_spacing, nounlock, numtogive) -- SW Recipe = Class(function(self, name, ingredients, tab, level, game_type, placer, min_spacing, nounlock, numtogive, aquatic, distance) -- Hamlet Recipe = Class(function(self, name, ingredients, tab, level, game_type, placer, min_spacing, nounlock, numtogive, aquatic, distance, decor, flipable, image, wallitem, alt_ingredients) I grabbed this from the game code. I believe it is the best way to check for each kind of DLC. I think there's some difference between how to check for RoG compared to SW and Hamlet, and I don't know why. if SaveGameIndex:IsModePorkland() then -- Do Hamlet code elseif SaveGameIndex:IsModeShipwrecked() then -- Do SW code elseif IsDLCInstalled(REIGN_OF_GIANTS) then -- Do RoG code else -- Do original DS code end You can translate those if-statements to bool-variables if you prefer. Link to comment Share on other sites More sharing options...
krylincy Posted May 10, 2020 Share Posted May 10, 2020 Especially for recipes I use this switch in my mods local function AddModRecipe(_recName, _ingrList, _tab, _techLevel, _recType, _placer, _spacing, _proxyLock, _amount) if GLOBAL.CAPY_DLC and GLOBAL.IsDLCEnabled(GLOBAL.CAPY_DLC) or GLOBAL.IsDLCEnabled(GLOBAL.PORKLAND_DLC) then return GLOBAL.Recipe(_recName, _ingrList , _tab, _techLevel, _recType, _placer, _spacing, _proxyLock, _amount) else return GLOBAL.Recipe(_recName, _ingrList , _tab, _techLevel, _placer, _spacing, _proxyLock, _amount) end end Link to comment Share on other sites More sharing options...
penguin0616 Posted May 12, 2020 Share Posted May 12, 2020 If the recipe already exists, this will directly modify the ingredients for said recipe. If the recipe does NOT exist, I would keep using Recipe() local Ingredient = _G.Ingredient _G.Recipes["example"].ingredients = { Ingredient("item1", 1), Ingredient("item2", 5), Ingredient("item3", 2) } -- A more practical example, let's change the ingredients of a spear to require 2 gold nuggets, 5 logs, and 3 flint. _G.Recipes["spear"].ingredients = { Ingredient("goldnugget", 2), Ingredient("log", 5), Ingredient("flint", 3) } Result: Hope that helped. Link to comment Share on other sites More sharing options...
Recommended Posts
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.