Jump to content
Sign in to follow this  
thiosk

[resolved] Proper syntax for opening package style items

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

Share this post


Link to post
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.

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...