DenBaron Posted July 23, 2017 Posted July 23, 2017 Hi all Quite new at programming for Zomboid but I have to start somewhere so sorry for the stupid questions. My firts hopefully small goal is that I want to be able to write a small mod that changes recipes already in the game. That beeing either adding items keept after crafting or new items gotten after dismantling something. I've figured out how to alter the standard game files to achieve my goals but for the sake of learning i would love to gain the knowledge how to make this into a mod so it can be shared with everbody. So my question is how do i write a script that tweaks / changes already excisting recipes in the game ??
Svarog Posted July 24, 2017 Posted July 24, 2017 (edited) Build 36 Update notes [MODDERS] You can now override recipes, just make a new recipe with the same name than the one you want to override and add a Override:true To be honest I haven't tried it myself but it would probably look more/less like this in a recipe script (use 15 nails instead of 5) recipe Build Spiked Baseball Bat { BaseballBat, Nails=15, keep Hammer/HammerStone, Result:BaseballBatNails, Sound:PZ_Hammer, Time:150.0, Category:Carpentry, OnCreate:SpikedBat_OnCreate, Override:true, } Bolded text is what's different from original recipe in Recipes.txt Edited July 24, 2017 by Svarog Damien Darkside 1
DenBaron Posted July 29, 2017 Author Posted July 29, 2017 Thanks! i'll have to look through update notes more thoroughly. I've probobly missed more very important modder updates like this.
Snakeman Posted September 19, 2017 Posted September 19, 2017 On 29/7/2017 at 2:37 PM, DenBaron said: Thanks! i'll have to look through update notes more thoroughly. I've probobly missed more very important modder updates like this. This feature only worked if you play the game on english language!!
BudeRoy Posted September 20, 2017 Posted September 20, 2017 (edited) There is something very weird going on with this Override thing. I was really happy to find out there's way to override recipes but seems like some of them are hard coded or something!? I was succesfully able to override 9mm and shotgun shells to be my mod versions, but 308 and 223 recipes are duplicated no matter what i do, i've changed names of bullets and bulletboxes and done now all tricks and still circling around the same problem. This is about to drive me crazy, added code from my script file (made fully own for it) and screenshots to show there's still double recipes even there's override. module Base { imports { PZExpanded } recipe Open Box of .308 Ammo { AmmoBox308Win, Result:Win308Bullets=32, Sound:PZ_PutInBag, Time:5.0, Override:true, } recipe Place .308 Ammo in Box { Win308Bullets=32, Result:AmmoBox308Win, Sound:PZ_PutInBag, Time:20.0, Override:true, } recipe Open Box of .223 Ammo { AmmoBox223Rem, Result:223RemBullets=40, Sound:PZ_PutInBag, Time:5.0, Override:true, } recipe Place .223 Ammo in Box { 223RemBullets=40, Result:AmmoBox223Rem, Sound:PZ_PutInBag, Time:20.0, Override:true, } recipe Open Box of 9mm Bullets { AmmoBox9x19mm, Result:9x19mmBullets=60, Sound:PZ_PutInBag, Time:5.0, Override:true, } recipe Place 9mm Bullets in Box { 9x19mmBullets=60, Result:AmmoBox9x19mm, Sound:PZ_PutInBag, Time:20.0, Override:true, } recipe Open Box of Shotgun Shells { AmmoBox12GBuckshot, Result:12GBuckshots=28, Sound:PZ_PutInBag, Time:5.0, Override:true, } recipe Place Shotgun Shells in Box { 12GBuckshots=28, Result:AmmoBox12GBuckshot, Sound:PZ_PutInBag, Time:20.0, Override:true, } recipe Saw Off Shotgun { DoubleBarrelShotgun, keep Saw, Result:SawnOffDoubleBarrel, Sound:PZ_Saw, Time:200.0, Override:true, } recipe Gather Gunpowder { 9x19mmBullets/12GBuckshots/223RemBullets/Win308Bullets/338Bullets/556Bullets/762Bullets, Result:GunPowder, Time:30.0, Override:true, } } Edited September 20, 2017 by BudeRoy
BudeRoy Posted September 20, 2017 Posted September 20, 2017 I've noticed that Override:true, can be used also to override base items. There's also Obsolete:true, to remove whole recipe. But the problem i'am issued with is 99% surely caused by the name of recipe. I can override all other recipes without any issues except these two which are inclued with . [dot] in it's name. That . must somehow break the override process.
Hydromancerx Posted October 6, 2017 Posted October 6, 2017 I am trying to override the Wash Clothes recipie but it is not working. :/ What did i do wrong? recipe Wash Clothing { keep Vest/Shirt/Trousers/Skirt/Blouse/Underwear1/Underwear2/HCScavangeshroud/HCRaincoat/HCRainponcho/HCMexicanponcho/HCDownjacket/HCButtondownshirt/HCPoloshirt/HCTshirt/HCTiedyeshirt/HCHawaiianshirt/HCLifevest/HCLinenshirt/HCLinenpants/HCSilkshirt/HCSilkpants/HCWoolshirt/HCWoolpants, Soap2/HCSoap/HCCleanerall/HCCleanerfabric/HCFabricsoftener/HCHandsoap/HCShampoo, Water=3, Result:Vest, OnTest:WashClothing_TestIsValid, Time:1000.0, OnCreate:WashClothing_OnCreate, RemoveResultItem:true, Category:Weaving, Override:true, }
Nagyx Posted September 20, 2021 Posted September 20, 2021 Sorry for the necro, but I'm having such a pain to override recipes that has more than one with the same recipe name/ID I'm trying to start modding, and the first big wall I'm having is to override a recipe like Make Hot Cuppa, because the recipe that uses coffee, has the same name as the recipe that uses tea. So when I try to do this, only one of the recipes is overriden, no matter what I do the other one stills the same. IMO the recipes should be the same way as the items, with individual ID's.
Kielo Posted February 7, 2022 Posted February 7, 2022 On 9/20/2021 at 5:41 PM, Nagyx said: Sorry for the necro, but I'm having such a pain to override recipes that has more than one with the same recipe name/ID I'm trying to start modding, and the first big wall I'm having is to override a recipe like Make Hot Cuppa, because the recipe that uses coffee, has the same name as the recipe that uses tea. So when I try to do this, only one of the recipes is overriden, no matter what I do the other one stills the same. IMO the recipes should be the same way as the items, with individual ID's. Did you solve this problem somehow? I have it now and I can't find any information about it. I tried to ask some help in discord, but everyone is silent there too.
Tykvesh Posted February 9, 2022 Posted February 9, 2022 Here's an example how you can modify specifically one of "Open Umbrella" recipes. There's probably a way to directly modify recipes with the recipe:Load function, but I haven't figured out the arguments. local recipes = getScriptManager():getAllRecipes() for i = 1, recipes:size() do local recipe = recipes:get(i - 1) if recipe:getName() == "Open Umbrella" then local result = recipe:getResult() if result:getType() == "UmbrellaRed" then result:setType("Pie") return end end end Kielo 1
Kielo Posted February 12, 2022 Posted February 12, 2022 Thanks! Tell me please, where can I check all recipe methods like getResult()? I need to change ingredients, but I can't realize how to get and work with them
Tchernobill Posted February 12, 2022 Posted February 12, 2022 Partial answer: Adding potential ingredients to evolved recipes it is easy, you need to create a dependency on ItemTweaker and tweak the EvolvedRecipe parameter of the item corresponding to the added ingredient. require "ItemTweaker_Core" --adds recipe to evolved recipe management for Base items. the num is the hunger removed from source item by each "use" TweakItem("Coffee2", "EvolvedRecipe", "HotCoffeeIsothermalCanRecipe:6") TweakItem("Teabag2", "EvolvedRecipe", "HotTeaIsothermalCanRecipe:5")
Kielo Posted February 13, 2022 Posted February 13, 2022 (edited) Unfortunately, I'm working not on the EvolvedRecipes. But anyway, I am very thankful for the reply. At least maybe I can disable/delete recipe via code? Like this: function DisableVanillaCampfireRecipes() local recipes = getScriptManager():getAllRecipes() for i = 0, recipes:size() - 1 do local recipe = recipes:get(i) if recipe:getName() == "Make Campfire Kit" then local ingredients = recipe:getIngredients() -- pseudo-method to get ingredients for i = 0, ingredients:size() - 1 do local ingredient = ingredients:get(i) if ingredient.getType() == "Log" or ingredient.getType() == "Plank" then recipe:Disable(); -- pseudo-method to delete/disable recipe return end end end end end Edited February 13, 2022 by Kielo
Tykvesh Posted February 25, 2022 Posted February 25, 2022 On 2/12/2022 at 2:55 PM, Kielo said: Tell me please, where can I check all recipe methods like getResult()? There's probably a better way, but you can get a list of functions by peeking into metatables: --prints functions from userdata type objects local function PrintUserdataFunctions(userdata) for k, v in pairs(getmetatable(userdata).__index) do print(k) end end PrintUserdataFunctions(getScriptManager():getRecipe("Base.Clean Bandage")) --result: getName isHidden getResult getSource getOriginalname needToBeLearn Load getFullType getSound getHeat getTooltip getCategory getLuaCreate setLuaCreate setOriginalname setNeedToBeLearn DoResult setCategory getRequiredSkills getTimeToMake addRequiredSkill FindIndexOf noBrokenItems findSource isKeep setNearItem isDestroy setSound getRequiredSkill DoSource isAllowFrozenItem setLuaGrab setAnimNode getProp1 setStopOnWalk setAllowFrozenItem getProp2 isRemoveResultItem setStopOnRun getLuaGrab isStopOnWalk getLuaTest getLuaGiveXP setProp2 getAnimNode setIsHidden isStopOnRun setLuaTest setLuaGiveXP getCanPerform getNearItem setProp1 setCanPerform getRequiredSkillCount clearRequiredSkills setAllowDestroyedItem getNumberOfNeededItem getWaterAmountNeeded setRemoveResultItem setCanBeDoneFromFloor isCanBeDoneFromFloor isAllowDestroyedItem getModule wait equals toString hashCode getClass notify notifyAll Kielo 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now