Forum rules - please read before posting.

Put token on inventory item

Hello everybody. I downloaded the example of buying and selling items from the AC, and I have a problem that I can't solve in the inventory.

In the coin item
I want to use the game currency variable token on that inventory item instead of the value assigned on the item to start. It is possible?

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

«1

Comments

  • I'm not sure I'm following you - do you want to set the "Quantity on start?" value dynamically based on a variable token's value?

  • yes.

    Because in my game there are negative monetary values, as if you owe a bank or a store, for example, the AC inventory does not accept negative values.

    I tried the way to add coins to the inventory through the list of actions but it only accepts a positive balance.

    I tried to combine a currency value variable that has negative and positive value with inventory item through the list of actions but I couldn't.

  • You can't carry negative amounts of an inventory item.

    Inventory items can be assigned properties - which can be modified through script - but the amount owed by the player to a bank is best represented with a Global Variable, leaving the amount of your currency item to represent how much the Player actually has.

  • edited June 2023

    Good evening everyone. Is it possible to copy the quantity value of item ''coins'' from inventory to an integer variable?

    For example, a constantly changing amount of money in inventory would be constantly copied to a variable.

  • Yes - both the amount of an inventory item currently held, and the value of variables, can be accessed through script.

    For example:

    using UnityEngine;
    using AC;
    
    public class CoinsToVariable : MonoBehaviour
    {
    
        public int coinItemID;
        public string variableName;
    
        void Update ()
        {
            int numCoins = KickStarter.runtimeInventory.PlayerInvCollection.GetCount (coinItemID);
            GlobalVariables.SetIntegerValue (variableName, numCoins);
        }
    
    }
    
  • this error appears;

    Assets\TripliceReal2.0\Managers\ESCRIPTS\CoinsToVariable.cs(13,41): error CS1503: Argument 1: cannot convert from 'string' to 'int'

  • My mistake:

    using UnityEngine;
    using AC;
    
    public class CoinsToVariable : MonoBehaviour
    {
    
        public int coinItemID;
        public int variableID;
    
        void Update ()
        {
            int numCoins = KickStarter.runtimeInventory.PlayerInvCollection.GetCount (coinItemID);
            GlobalVariables.SetIntegerValue (variableID, numCoins);
        }
    
    }
    
  • edited June 2023

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

    I was in doubt about how to use this escript and the name I use for the variable and the Item correctly. I ended up adding the script to an object to test. It didn't work, I created a variable with the name variableID and the inventory item was coinItemID had no effect. I changed the names to variable and coin didn't work either.

  • It's not associated with any specific Hotspot - detach it from the Hotspot and add to an empty GameObject that you can prefab.

    Set the "Coin Item ID" to the ID number of the Coin item in your Inventory Manager. This will be the number to the left of it in the Items list.

    Set the "Variable ID" to the ID number of the Global Integer variable in your Variables Manager. This too will be the number to the left of its name.

  • edited June 2023

    thanks now it works. I had been confused by not knowing how to use the ID of the inventory and the global variable that was very simple to use the number in order of the listing.

  • Hello, Chris. There is a bug in the example scene of the store, if you don't put anything in the cart and click on buy, the value of the inventory of the coins is spent.

  • Fixed - thanks for the bug report.

  • Worked, thank you

  • edited June 2023

    Sim - tanto a quantidade de um item de estoque atualmente mantido quanto o valor das variáveis ​​podem ser acessados ​​por meio de script.

    Por exemplo:

    Is it also possible the other way around for an integer variable to be copied to an inventory item?

  • Please use only English on the forum.

    You can go the other way, but it's complicated. It's best to stick to the item -> variable direction, and manipulate the item directly if you want to change how many there are.

  • I now saw an error, yesterday I mistakenly copied the already translated text and pasted it without realizing it. As the page is translated automatically, then I got confused.

  • edited June 2023

    Is it possible through an action list variables to put a formula that subtracts some item from the inventory using tokens? It would be different from the action list to remove or add items.

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

  • I didn't quite understand how to do it. I had mentioned subtraction, but now it's more complicated because I need it, for example, when entering
    a random value of coins through the script for watching those advertisements in unity ads , this new value of the variable would have to increase the value of the item's currency.

    If you enter random values ​​of the coin variable, you would need to increase the value of the coin item.

    example; variable coins 5 --> item coins 5
    variable coins 7--> item coins 7 from inventory.

    If you already entered the variable ''coins 5'' and the ''item coins'' already had a value of 5 if you enter another value of the variable ''coins 7'' then the inventory item will become 12 and so on.

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

    If you can share screenshots that illustrate what you have already, with a description of what's not working, that will help clarify the situation.

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.