I searched for help for this topic but the only answers I found were "use the variable system/ score system" which is where my problem lies. I want the player to start out with $0 and, after looking through the couch, receive $10, which adds an inventory item (which I have already made, called "iMoney"), and makes the item display $10, which increases with each subsequent profit. I don't want to use the score system because I plan on using that for experience that levels the player up, so my only choice is the variable system. I made a global variable called "myMoney", but every time I try to enable it in my room script (room1.asc) by typing "int myMoney;" in line 2 (line 1 is a //description), it says "room1.asc(2): Error (line 2): Variable 'myMoney' is already imported". Any help on how to fix this and make a working money system would be great. Also, whenever I select the money item in the inventory, it makes it appear on my GUI and I can't remove it, any way to disable this? Thanks in advance.
I think an easier way of doing what you're trying to do WOULD be to simply use a variable, but in a different way.
Don't try to 'activate' it, since you already will have done so by making the global variable.
Start by going under the global variables and make an integer one called 'money' or something similar. Make sure it is set to 0.
Then, when the character goes to grab the money, make a simple code such as:
{
cEgo.Say("I found some money in the couch!");
money = money + 10;
}
Then, with your inventory item, when the character looks at it, have it display the variable with something like:
{
Display ("My wallet holding %d dollars.", money);
}
Ags will know to use the number of the integer variable 'money' where '%d' is in the display string.
Lookup inventory inthe manual and you will find ...
Quote from: TFM ;)
readonly static int Game.InventoryItemCount
Returns the number of inventory items in the game. This is the total number of items that you created in the Inventory Items pane of the editor, not how many the player is currently carrying.
Example:
Display("The game has %d inventory items.", Game.InventoryItemCount);
So then you would have ...
// Then, when the character goes to grab the money, make a simple code such as:
{
cEgo.Say("I found some money in the couch!");
iMoney.InventoryItemCount = iMoney.InventoryItemCount + 10;
}
// Then, with your inventory item, when the character looks at it, have
// it display the variable with something like:
{
Display ("My wallet holding %d dollars.", iMoney.InventoryItemCount);
}
Rick you're confusing Game.InventoryItemCount with Character.InventoryQuantity:
// Then, when the character goes to grab the money, make a simple code such as:
{
cEgo.Say("I found some money in the couch!");
player.InventoryQuantity[iMoney.ID] += 10;
UpdateInventory();
}
// Then, with your inventory item, when the character looks at it, have
// it display the variable with something like:
{
Display ("My wallet holding %d dollars.", player.InventoryQuantity[iMoney.ID]);
}
Thank-you for your help thus far, but is there any way to have my inventory items display names under them? And also whenever I left click the iMoney inventory item it makes it appear in my GUI bar on top of the button next to the default game save button.. any way to fix this?
Latest versions of AGS support different images for inv items and their cursors natively, so you could simply use a sprite that contains the text description as regular image and one without as cursor image.
Re the button: this is intentional and should be the case for every active inventory item.
Either remove the button or change its text to "" (blank).
Thanks a lot, that works great!