Jump to content
Sign in to follow this  
Cernu

Has/Get/set/change items in player inventory

Recommended Posts

Would this be possible, or maybe it already exists ? some way to get if a player has a certain item in its inventory, return its number, and change this number. this would be very handy for a custom crafting system.

Share this post


Link to post
Share on other sites

Yes I discovered this indeed, thanks. however, there are still some issues. I created a function to try to return the amount of a certain item. So I loop through the items using this "get inventory" array, and then for each item, I insert an "IF" check. I here I have issues. For some items, like "fern seeds", i can reference it easily using a get type of the item. So "if get type "item" = get type "fern seed", do something. Then, i actually count and return the number of items. Works fine. 

However, if I use "grass", it seems that the "grass" item doesn't have a type.  So it doesn't match. So I tried using the name of the item, but in this case, I have to reference an actual entity that exists on the map, it seems I can't reference a template or type, and get its name. And however, it would be much easier to reference a type, than having to create a template for each and every item I want to create in my game.

Share this post


Link to post
Share on other sites

Ok, I found the issue, I wasn't refernecing the proper type of "grass", as there are at least 3 or for differeint "grass" items when choosint the entity type. It works fine, also the get and set stack. Onward to my custom crafting !

Share this post


Link to post
Share on other sites

Items in stacks counts e.g. 20 bullets are ONLY one item of bullets, but in stack 20 of them. Two stack of bullets are two items, atc. 

If you want to find out the number of bullets (in all of your stacks in inventory) you need check number of all stacks and if you find stack, you need check number of items in this stack.
For this you need to use this script: "https://community.bistudio.com/wiki/Ylands_Tile_-_Item_stack_count"

Sorry for my english...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×