Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: monkey0506 on Sun 15/08/2004 14:55:15

Title: Get Inventory Name...
Post by: monkey0506 on Sun 15/08/2004 14:55:15
I have searched the manual, and I don't know how to do this. I found GetInvName, but the help manual says to use player.activeinv, and mouse.x, mouse.y doesn't work. I need to make it so when the mouse is over an inventory item it adds the inventory's name to my label. I'm already using GetLocationName for hotspots, objects, and characters, but it doesn't add inventory names. Thanks in advance!
Title: Re: Get Inventory Name...
Post by: Bernie on Sun 15/08/2004 15:34:59
I'm not sure, but did you try this yet?

string name;
GetInvName(GetInvAt(mouse.x,mouse.y),name);

Works fine for me, at least. :)
Title: Re: Get Inventory Name...
Post by: monkey0506 on Mon 16/08/2004 01:12:30
Actually I did have a SIMILAR script, that just didn't work. And when I tried to implement this script I messed something up, and forgot to back up my game first. Now the "Walk to" cursor doesn't animate, and it still doesn't work. I do have an idea though. I'm going to re-do my script now that I understand and know AGS a little better than when I started (i.e.{
*When I started scripting my GUI, I was afraid to make functions.
*When I started scripting my GUI, I was afraid to use strings.
*When I started scripting my GUI, I was afraid to make non-popup-modal GUIs.
*When I started scripting my GUI, I was afraid to start.
*When I started scripting my GUI, I was afraid to not copy Proskrito's template to a T.
*When I started scripting my GUI, I was afraid to do anything.
}). Perhaps I started too early, perhaps not. Fact of the matter is, I know what I'm doing now. I understand how functions work. I understand the difference between an int and a string an the differences in how they are used. And, I'm no longer afraid to script anything. I'm going to start from scratch with the empty template, import my images, one at a time, and script them as I go. Perhaps a lot of the problem is that I scripted much of my GUI in repeatedly execute. Perhaps not. Perhaps I'll never say perhaps again. Perhaps.
Title: Re: Get Inventory Name...
Post by: Proskrito on Mon 16/08/2004 09:18:38
GetLocationName works for me with inventory items
Title: Re: Get Inventory Name...
Post by: monkey0506 on Tue 17/08/2004 03:15:06
Ok... This is kind of wierd. My images are displayed correctly, but the names appear only when the cursor is inbetween items (it displays the name if the inventory item to the left). And yes I am revamping my GUI still, and I'm kind of glad that I am. My script is much cleaner, and much more user friendly. Well, I have to go to bed because I have school tomorrow, but please reply ASAP!

EDIT: It also displays the name of the inventory item above the inbetween space. I have this: SetInvDimensions(40, 24); but my images are only 38 X 22. I set it larger because... Well, it's kind of hard to describe. It just acted a lot wierder.
Title: Re: Get Inventory Name...
Post by: on Wed 18/08/2004 01:53:25
Ok... I've played around with it, and I guess I don't know what I'm doing. My inventory size is 158 X 46 with 2 rows each with 4 inventory items. My inventory pictures are displayed correctly, and to try to add the inventory name to my status label, I have the following scripts:

in game_start():
    SetInvDimensions(38, 22);
    game.items_per_line=4;
    game.num_inv_displayed=8;

in LucasLabel()://the function I created to update the label
  if ((GetInvAt(mouse.x, mouse.y)>=1) && (GetCursorMode()!=MODE_WALK_TO)) GetInvName(GetInvAt(mouse.x, mouse.y), text);
  else if (GetInvAt(mouse.x, mouse.y)==0) StrCopy(text, "");
  StrCat(label, text);
  //updates label text
  SetLabelText(0, 0, label);

in repeatedly_execute:
  LucasLabel();//updates status label

And that's pretty much it in regards to the inventory names. My problem, with SetInvDimensions(38, 22) it displays the name of the inventory items when the cursor is over the transparent space between items, and it displays the name of the item to the right. I have tried SetInvDimensions(40, 24) and that moved the names to the transparent space to the right of the object, and displays the name of the item on the left. Please advise!  :-\
Title: Re: Get Inventory Name...
Post by: monkey0506 on Thu 19/08/2004 22:48:56
Ok... This was stupid. I think. Not yet sure about this. Ok, I think I know what my problem is. I think I know why the game is reacting the way it is. And I think I know how to fix it. But, I don't have time to fix it... My problem is that way back in the day... er... When I started making this GUI I was following Proskrito's template fairly closely, trying to emulate his script without copying it. In doing so, my main GUI is just a big black box. For the inventory, I wanted to include something Proskrito's template did not contain. Inventory place holder boxes. I.E. Blank images in place of no inventory item. So, I did this by creating a lot of buttons. DUH! That's my problem. All I have to do is delete the buttons, add the blank boxes to the sprite for the GUI, update the sprite, and it will work! I think. But I am supposed to be typing 4 1/2 - 6 pages on three articles I haven't read for my english class.... Due tomorrow.  8) I'll be aight.