Jump to content

[resolved] Proper syntax for opening package style items


thiosk

Recommended Posts

Hello All,

 

I'm using ItemZED to work on an item mod.  The idea is that an unopened bottle of mayo is shelf stable and found on grocery shelves, and can then be opened to give a full, perishable bottle of standard mayo. this enables good sammies later in the game.

 

First, heres the candypackage and recipe i'm imitating

 

image.png.3584f8457f5f6cfb6b81bc9884f2734f.png

'

However, the LuaCode for the candy package using the OnCreate (string) line does not seem to correspond to what happens in game. In game, you create the lollipops. However, the luacode called by oncreate shows the following, and does not create mint candy.

 

function OpenCandyPackage_OnCreate(items, result, player)
    player:getInventory():AddItem("Base.MintCandy");
    player:getInventory():AddItem("Base.MintCandy");
    player:getInventory():AddItem("Base.MintCandy");
    player:getInventory():AddItem("Base.MintCandy");
    player:getInventory():AddItem("Base.MintCandy");
    player:getInventory():AddItem("Base.MintCandy");
end
 

I've tried my own codes, with and without the functions.

 

my function:

 

function OpenMayoPackage_OnCreate(items, result, player)
    player:getInventory():AddItem("Base.MayonnaiseFull");
end
 

and heres my item currently. I've had the corresponding oncreate line in there too, but it didn't seem to do anything.

 

I get the correct context, but no MayonnaiseFull is created when I execute the recipe.

 

image.png.83d1445e8f3c43b5f64a61de26ecf9a5.png

 

Edited by thiosk
Link to comment
Share on other sites

RESOLVED

 

Ok I figured it out.

1. MayonnaiseFull=1 is insufficient. You need the module too, and for some reason, mayo is in the farming module, so the RESULT line should read:

 

farming.MayonnaiseFull=1

 

2. You do not need the LUA. I suspect that was needed in earlier builds when you wanted to spawn multiple items or something. 

 

image.png.c67e40d4a539b3f564753321d5780a96.png

 

Now on to making powdered milk work.

 

 

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