Project Zomboid

Project Zomboid

Caster Plus
 This topic has been pinned, so it's probably important
zitronic  [developer] 14 May @ 7:01pm
Compatibility
Compatibility
---------------------------------------------------------------------------------------

This mod uses the lua file zitcaster_recipecode.lua, located here:

Caster Plus\Contents\mods\Caster Plus\42\media\lua\server\zitcaster_recipecode.lua

This file adjusts the vanilla recipe known as "HalveFillet", located here in the vanilla game:

ProjectZomboid\media\scripts\recipes\recipes_cooking.txt

This file also adjusts the vanilla recipe code "Recipe.OnCreate.CutFillet" located here:

ProjectZomboid\media\lua\server\recipecode.lua

This is the file zitcaster_recipecode.lua:

require "recipecode" local script = "{ outputs { item 2 CasterPlus.FishFilletHalf, } }" local recipe = getScriptManager():getCraftRecipe("HalveFillet") recipe:getOutputs():clear() recipe:Load("HalveFillet", script) function Recipe.OnCreate.CutFillet(craftRecipeData, character) local items = craftRecipeData:getAllConsumedItems(); local results = craftRecipeData:getAllCreatedItems(); local fillet = nil for i=0,items:size() - 1 do if items:get(i):getType() == "FishFillet" then fillet = items:get(i) break end end if fillet then local hunger = math.max(fillet:getBaseHunger(), fillet:getHungChange()) fillet:setBaseHunger(hunger * 0.5) fillet:setHungChange(fillet:getBaseHunger()) fillet:setActualWeight(fillet:getActualWeight() * 0.5) for j=0,results:size() - 1 do local result = results:get(j) result:setBaseHunger(fillet:getBaseHunger() / 2) result:setHungChange(fillet:getBaseHunger()) result:setActualWeight(fillet:getActualWeight() / 2) result:setWeight(result:getActualWeight()) result:setCustomWeight(true) result:setCarbohydrates(fillet:getCarbohydrates() / 2); result:setLipids(fillet:getLipids() / 2); result:setProteins(fillet:getProteins() / 2); result:setCalories(fillet:getCalories() / 2); end end end

The top part of the code creates a local script with the custom output string, and then calls the vanilla recipe "HalveFillet" via the Script Manager. The outputs are then cleared from the vanilla recipe and set to the custom item made in Caster Plus.
This creates Compatibility issues with any mod that also modifies the "HalveFillet" recipe

The second half of the code is for the OnCreate command. The only things that are different from the vanilla file are the number values in the result:get() function. This is because the vanilla code divides the hunger twice.
This creates Compatibility issues with any mod that also modifies the "Recipe.OnCreate.CutFillet" function.
Last edited by zitronic; 14 May @ 7:18pm