Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Candle on Wed 22/12/2004 22:01:15

Title: You have Inventory added [SOLVED]
Post by: Candle on Wed 22/12/2004 22:01:15
What would be the best way so anytime a Inventory item is added it says Inventory added in some font ?
I know I could do a add message but don't want to add that to every Inventory item .

:=   felt like using this .  face . lol
Title: Re: You have Inventory added
Post by: Kikutaâ„¢ on Wed 22/12/2004 22:24:18
maybe you want something like this :

AddInventoryItem(number);
Display("I got a key");
Title: Re: You have Inventory added
Post by: Candle on Wed 22/12/2004 22:27:05
No I just want it to say " Inventory Added " and the way you have I have to add it to each Inventory item .
Title: Re: You have Inventory added
Post by: hms on Wed 22/12/2004 22:56:50
well im quit new to AGS but..

You could save it as a global message i dont think it's too hard work for you to do the answer above? Take it as a rutine..
Title: Re: You have Inventory added
Post by: strazer on Wed 22/12/2004 23:39:44
Look in the manual for the "on_event" function. Is that what you're looking for?
Title: Re: You have Inventory added
Post by: Candle on Wed 22/12/2004 23:41:15
I'll take a look strazer right now and see . thanks .
Well found the part you talk about but not sure how I would code it to   display  a font on the screen saying " inventory item added" ?

Title: Re: You have Inventory added
Post by: strazer on Thu 23/12/2004 03:21:20
I don't quite understand what you mean by displaying a "font"?
If you want to display a generic message each time an inventory item is added to the inventory, put this in the global script:

function on_event(int event, int data) {
  if (event == ADD_INVENTORY) {
    Display("Inventory added");
  }
}
Title: Re: You have Inventory added
Post by: Candle on Thu 23/12/2004 03:39:33
Thats what i wanted to do . anyway to remove the white background from it and  change the color of the font that is display ? if not thats ok I'm happy with that .
I just happen to see that the game  Melrin: The Dragon Menace had it done that way and I liked it .
Title: Re: You have Inventory added
Post by: Gilbert on Thu 23/12/2004 03:53:31
Quote from: Candle on Thu 23/12/2004 03:39:33
anyway to remove the white background from it and change the color of the font that is display ? if not thats ok I'm happy with that .

You mean the background of the message? If you're not using "Always display text as speech" option it would be displayed in a message GUI, if you use the Display() function. One simple way is to just check the "Always display text as speech" option, but if you really want texts in message boxes in your game, you change the Display() of the codes to DisplaySpeechBackground(), for example:

function on_event(int event, int data) {
  if (event == ADD_INVENTORY) {
     DisplaySpeechBackground(GetPlayerCharacter(),"Inventory added");
  }
}
Title: Re: You have Inventory added
Post by: Candle on Thu 23/12/2004 03:56:29
Thank you Gilbot , I didn't think to check that .
That makes it lose the background color of white and looks much better .
Thank you both for the help .
Title: Re: You have Inventory added
Post by: strazer on Thu 23/12/2004 03:57:11
And if you want it to display at another location than above the player character's head, do

int oid = DisplaySpeechBackground(GetPlayerCharacter(), "Inventory added");
MoveOverlay(oid, 10, 300); // tweak coordinates for your game resolution
Title: Re: You have Inventory added
Post by: Candle on Thu 23/12/2004 03:58:44
Ok great .. I think above the head is ok ..
Title: Re: You have Inventory added [SOLVED]
Post by: Joacim Andersson on Thu 23/12/2004 21:01:47
I know you've put SOLVED in the subject line but I just wanted to add my 5 cents. The way I did this in the Melrin games was to create a simple GUI with the text "New Inventory Item". I also created my own function named AddInv(int inv) in which I called the AddInventory function, show the GUI and started a timer that when it's fired removes the GUI, so the text is removed automatically after a few seconds.
Title: Re: You have Inventory added [SOLVED]
Post by: Candle on Thu 23/12/2004 21:14:25
Thanks for how you did it . I think what I have now will work fine but good to know how others do things too .