How do I solve my problem with array for inventory

0 favourites
  • 8 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hey guys! I am making an inventory and i am having problems with the array because when I pick up an item and then I pick up an other one item these last item i picked up replaced the other one.

    Example:

    https://gyazo.com/392a16c3d84d11acc311cc349e4d3156

    Code:

    https://gyazo.com/e93053272319db299665e79354511599

    https://gyazo.com/f3b20a5d1a78c3c98e60620e78c7bfed

    Thanks you all! Sorry about my english... maybe if you check the example then you will understand it. <img src="{SMILIES_PATH}/icon_e_geek.gif" alt=":geek:" title="Geek">

  • Manual:

    CurX

    CurY

    CurZ

    The current zero-based index for each dimension in a For each element loop.

    Me:

    Where is the For each element loop ?

  • Manual:

    CurX

    CurY

    CurZ

    The current zero-based index for each dimension in a For each element loop.

    Me:

    Where is the For each element loop ?

    Still not working right:

    https://gyazo.com/46406d62be1e71c52d8237839b1bafc3

    Code:

    https://gyazo.com/e281f94cd1e46747fb02e6a3ed5f1cc4

    https://gyazo.com/4aa7d541ea73dc5284c00349c8130b16

    I am not sure about what did you mean... sorry :S

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Not in the inventory does not mean it is not in the array. Did you look at the array in the debugger ?

    You dont show how you let the inventory read out the array.

  • Not in the inventory does not mean it is not in the array. Did you look at the array in the debugger ?

    You dont show how you let the inventory read out the array.

    That happened:

    https://gyazo.com/37f0de3c7eae5d424584827270495e7f

    <img src="{SMILIES_PATH}/icon_redface.gif" alt=":oops:" title="Embarrassed">

  • I tried it, and it works fine! but i need to pick up the item when you are scavaging the corpse or the bush...

    https://gyazo.com/31139f11db84b46e7f895bf437c23931

    CoDe:

    https://gyazo.com/584ce7de1a88fac6b733179ab575a20b

    Item.QueSoy (translate to english: Item.WhatIam):

    https://gyazo.com/255c09390ac8ffa053cf6514c7c89254

    One of the item have the variable name: berries, and the other one: Bones

    I can't understand why the "For each X" fill all the array

  • Contains value

    Searches the entire array to check if any of the elements contains the given value. For example, you can use this to test if the string "sword" is stored anywhere in the array.

    That is what the manual says about that condition.

    You inverted it.

    So, this is only true when there is at least 1 times Item.QueSoy in the WHOLE array.

    Further

    Item.QueSoy is a 'string'.

    Variable = "berries" means you gave that variable the content of a STRING.

    Variable = 11 means you gave that variable the value 11

    So, either you have a number OR a string.

    The value of "berries" = zero. The content of "berries" = "berries"

    If you want to know if something is EMPTY (that it will not contain a string) you have to compare to a empty string.

    Is variable = "" ?

    At the moment you compare: Is variable = 0 ?

    But, you did not pre-format the array. As a result there are numbers and strings in the array.

    So, either you pre-fill the whole array with "" (the EMPTY STRING).

    Or, you make the 'for every x' conditon.

    Then a sub condition.

    Value at curX = ""

    OR

    Value at curX = 0

    Have to make it an OR block.

    Since you coded only "Value at curX = 0" it filled the whole array because as string has a value of zero.

    (those that expected me to use programming gramar at this moment are laughting there a.. off)

  • Contains value

    Searches the entire array to check if any of the elements contains the given value. For example, you can use this to test if the string "sword" is stored anywhere in the array.

    That is what the manual says about that condition.

    You inverted it.

    So, this is only true when there is at least 1 times Item.QueSoy in the WHOLE array.

    Further

    Item.QueSoy is a 'string'.

    Variable = "berries" means you gave that variable the content of a STRING.

    Variable = 11 means you gave that variable the value 11

    So, either you have a number OR a string.

    The value of "berries" = zero. The content of "berries" = "berries"

    If you want to know if something is EMPTY (that it will not contain a string) you have to compare to a empty string.

    Is variable = "" ?

    At the moment you compare: Is variable = 0 ?

    But, you did not pre-format the array. As a result there are numbers and strings in the array.

    So, either you pre-fill the whole array with "" (the EMPTY STRING).

    Or, you make the 'for every x' conditon.

    Then a sub condition.

    Value at curX = ""

    OR

    Value at curX = 0

    Have to make it an OR block.

    Since you coded only "Value at curX = 0" it filled the whole array because as string has a value of zero.

    (those that expected me to use programming gramar at this moment are laughting there a.. off)

    You solve my problem! Thanks youuu very much!!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)