Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Anarcho on Thu 09/12/2004 00:42:54

Title: Scripting Error w/Inventory [SOLVED]
Post by: Anarcho on Thu 09/12/2004 00:42:54
Hi, I just imported my first inventory sprite into my game, pasted it over the key image in the inventory items, and check the box that says "start with inventory item".Ã,  When i open up the inventory in the game, the image is there and looks fine, but when i click on the image and press "ok" in the GUI i get this error message:

(Global Script Line 27)
Error: SetLabelText: specified control is not a label

My Global Script Line 27 is this:
SetLabelText(0,0,useinvtxt);Ã,  }

What am I doing wrong?

Title: Re: Scripting Error w/Inventory
Post by: Gilbert on Thu 09/12/2004 01:40:39
Are you sure object 0 of gui 0 is a label?
Title: Re: Scripting Error w/Inventory
Post by: Anarcho on Fri 10/12/2004 00:45:12
No, it isn't, but I'm a little lost here.  Here's the whole troublesome bit of code:

if (GetCursorMode()==0) SetLabelText(2,0,"Walk to @OVERHOTSPOT@");
if (GetCursorMode()==1) SetLabelText(2,0,"Look at @OVERHOTSPOT@");
if (GetCursorMode()==2) SetLabelText(2,0,"Interact with @OVERHOTSPOT@"); 
if (GetCursorMode()==3) SetLabelText(2,0,"Talk to @OVERHOTSPOT@");
if (GetCursorMode()==4) {   
   string usinginv;   
   string useinvtxt;   
   StrCopy (useinvtxt, "Use ");   
   GetInvName(character[GetPlayerCharacter()].activeinv,usinginv);   
   StrCat (useinvtxt,usinginv);   
   StrCat (useinvtxt," with ");   
   StrCat (useinvtxt,"@OVERHOTSPOT@");   
   SetLabelText(0,0,useinvtxt);  }


It's something I copied from someone else so I get that nice status line at the bottom of the screen.   My inventory GUI is GUI 1, so I imagine I should change that first 0 in the final line to 1, but what object number do I use?  I don't have a label in the inventory box, so do I create one?

I want the status line to display the name of the inventory item after I click it.   You know, so it says, "Use stick on sofa" and so on.

Title: Re: Scripting Error w/Inventory
Post by: Gilbert on Fri 10/12/2004 01:32:25
Quote from: Anarcho on Fri 10/12/2004 00:45:12
No, it isn't, but I'm a little lost here.Ã,  Here's the whole troublesome bit of code:
So that's the reason why it crashed.

From what I read of what you're going to do, that line in question should be:
SetLabelText(2,0,useinvtxt);Ã,  }

Title: Re: Scripting Error w/Inventory
Post by: Anarcho on Fri 10/12/2004 01:51:13
Ha!  That did it.  Why was it 2?
Title: Re: Scripting Error w/Inventory
Post by: Gilbert on Fri 10/12/2004 01:52:58
Because that status line GUI on the bottom of the screen is #2, from what I read from the codes you pasted.
Title: Re: Scripting Error w/Inventory
Post by: Anarcho on Fri 10/12/2004 02:09:39
Aaah.  Duh.  Sorry, I'm inept at times.

Thanks!

-Logan
Title: Re: Scripting Error w/Inventory [SOLVED]
Post by: TerranRich on Fri 10/12/2004 03:30:40
It's okay, inepititude is very common among AGSers, especially the elders. ;)