Forum rules - please read before posting.

Put token on inventory item

2»

Comments

  • edited July 2023

    I'm not following your explanation. What is it in general you're trying to accomplish?

    In the other topic this ADS code used this line to increase a variable value.

    Simply put... If in place of the line AC.GlobalVariables.GetVariable(130).IntegerValue += 5; another one that directly increases the inventory item would solve the problem.

    public void RewardUser()
    {
    if (debugMode) Debug.Log("[MonetizationManager] RewardUser:" + selectedRewardType.ToString());

        switch (selectedRewardType)
        {
            case REWARD_TYPE.COINS_5:
                AddCoins(5);
                AC.GlobalVariables.GetVariable(130).IntegerValue += 5;
                break;
            case REWARD_TYPE.COINS_17:
                AddCoins(17);
                AC.GlobalVariables.GetVariable(130).IntegerValue += 17;
                break;
            case REWARD_TYPE.COINS_42:
                AddCoins(42);
                AC.GlobalVariables.GetVariable(130).IntegerValue += 42;
                break;
        }
    }
    
  • You can add "Y" amount of an Inventory item with an ID of "X" with:

    KickStarter.runtimeInventory.Add (X, Y);
    
  • Hi Chris. There was an error so I added AC in the code line KickStarter.runtimeInventory.Add (X, Y); and it worked. Thanks

  • edited July 2023

    You can use an Integer parameter to override the Inventory: Add or remove Action's Reduce count by field, so that you can set the number to remove dynamically.

    This parameter can be transferred from an Integer Variable value using the ActionList: Set parameter Action. The Integer Variable's value can be set, using a Formula and tokens, with the Variable: Set Action.

    Unlike the other problem with the script that has already been resolved, this is another one that occurs within the game. Basically when the player owes money and needs to pay with an inventory item.

    This part I am not able to add or subtract some value of a variable that is always changing for an inventory item through a formula. I used the token [param:0] related to inventory coins and it had no effect.

    https://uploaddeimagens.com.br/imagens/abjZ6d0

    What I am trying to do is the following ;

    If I have 500 coins of an inventory item that always varies and I have a global variable that is also a currency, but this variable is not part of the inventory, as this variable can sometimes present a negative number, I would like to use a formula to subtract the value of the inventory item.

    example;

    If the player owes - 40, then 40 coins will be taken from the inventory item.
    (I don't mean that the player owes the store, it could be to a bank or people who have to pay)

    At any time, another higher or lower value may appear, which may be negative, hence the formula would always resolve to pay the debt while there are coins in the stock.

    So whenever a negative variable number appears, it will have to be calculated with the Inventory Item to settle something like that.

  • The parameter you're using here is of the type "Inventory Item" - its value will represent the ID number of the assigned item, not the amount of that item you're carrying.

    If you're always dealing with the "Coins" item, then the Inventory item you're referencing is fixed - an Inventory Item parameter is not necessary.

    To affect the amount of an item the player holds, check Set amount? in the Inventory: Add or remove Action. The Amount to remove field beneath will be the one you want to override - with an Integer parameter.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.