0 Favourites

How do I solve my problem with array for inventory

  • 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:

    Code:

    Thanks you all! Sorry about my english... maybe if you check the example then you will understand it.

  • 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:

    Code:

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

  • 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:

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

    CoDe:

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

    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)

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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)