Jump to content

problem getting recipes to work


PZ-NOOB

Recommended Posts

Hello my fellow gamers. I have been making a mod over this last week with a bit of everything in it so I can get to know the wonderful world of code. However I have just started playing with recipes and for some strange reason I cant get it to work here is what I have;

 

 Module MeleeModRecipes   recipe Open Crate Of Juice  {        SmallCrateOfJuice,         Result:JuiceCarton=5,SmallCrate,        Sound:PZ_PutInBag,        Time:5.0  } }

 

Since this is my first ever mod I'm not really sure what I'm doing wrong. If it could be explained to me It will be much appreciated. By the way I have a strange feeling its something super simple so sorry if it is.

Link to comment
Share on other sites

Hello my fellow gamers. I have been making a mod over this last week with a bit of everything in it so I can get to know the wonderful world of code. However I have just started playing with recipes and for some strange reason I cant get it to work here is what I have;

 

 Module MeleeModRecipes   recipe Open Crate Of Juice  {        SmallCrateOfJuice,         Result:JuiceCarton=5,SmallCrate,        Sound:PZ_PutInBag,        Time:5.0  } }

 

Since this is my first ever mod I'm not really sure what I'm doing wrong. If it could be explained to me It will be much appreciated. By the way I have a strange feeling its something super simple so sorry if it is.

 

I'm at work so my solution to your problem would have to wait until I get home to look at some files, but for the spoiler you need to put a "/" between the "[" and the spoiler, like this

 

[/"spoiler] (just remove the quote in the center, if I don't put it there, the spoiler won't show up)

 

the result

see it worked

 

Edit:

 

Got home. So, your problem is that you can't have two results from a recipe in the scripts section (for whatever reason) to add a second item to the result you need to add an OnCreate tie in to an .lua.

 

So for example, your script file should look something like:

        SmallCrateOfJuice,

        Result:JuiceCarton=5,

        Sound:PZ_PutInBag,

        Time:5.0

        OnCreate:spawnemptycrate_OnCreate,

 

Then in an lua somewhere you add a function like this:

function spawnemptycrate_OnCreate(items, result, player)

         local plinv= player:getInventory();

         plinv:AddItem("Base.SmallCrate");

end

 

keep in mind I am not positive the small crate is a base game item, if it is not you will have to change the "Base" part of that code.

 

Hopefully that works for you

Link to comment
Share on other sites

I'm just learning and this seemed like a good practice for me so I tried it out and got it working :)

Just used some placeholder images for the icons for testing.

 

I based the Juice on the Pop item from the Base module.


// file name: <Username>\Zomboid\mods\PZNoob\media\scripts\pznoob.txtmodule PZNoob {  imports {    Base  }  item JuiceCarton {    HungerChange = -8,    Weight = 0.1,    AlwaysWelcomeGift = TRUE,    Type = Food,    UnhappyChange = -10,    ThirstChange = -60,    DisplayName = Carton of Juice,    Icon = juicecarton, // file access:  <Username>\Zomboid\mods\media\textures\Item_juicecarton.png    CustomContextMenu = Drink,    CustomEatSound = PZ_DrinkingFromBottle,  }  item SmallCrate {    Weight = 1.0,    Type = Normal,    DisplayName = Small Crate,    Icon = smallcrate, //file access: <Username>\Zomboid\mods\media\textures\Item_smallcrate.png  }  item SmallCrateOfJuice {    Weight = 1.5,    Type = Normal,    DisplayName = Small Crate of Juice,    Icon = smallcrateofjuice, // file access: <Username>\Zomboid\mods\media\textures\Item_smallcrateofjuice.png  }  recipe Put in small crate {    JuiceCarton=5,    destroy SmallCrate,    Result:SmallCrateOfJuice,    Sound:PZ_PutInBag,    Time:5.0,  }  recipe Open Crate Of Juice  {    SmallCrateOfJuice,    Result:JuiceCarton=5,    Sound:PZ_PutInBag,    Time:5.0,    OnCreate:returnEmptySmallCrate_OnCreate,  }}

 

-- file name: <User>\Zomboid\mods\PZNoob\media\lua\client\pznoobOnCreate.luafunction returnEmptySmallCrate_OnCreate(items, result, player)  player:getInventory():AddItem("PZNoob.SmallCrate");end

 

I managed to get the context menu to come up saying "open crate of juice" however when I click it, it doesn't give me anything. Ideas?

Link to comment
Share on other sites

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