Adventure Game Studio | Forums

AGS Support => Beginners' Technical Questions => Topic started by: Voedino on Wed 07/01/2015 18:37:33

Title: Undefined symbol item
Post by: Voedino on Wed 07/01/2015 18:37:33
Help me, please!
I want that in TextBox when taking item was his description.
Lines 5 and 6 dont'work
Code (ags) Select

function btnIconCurInv_Click(GUIControl *control, MouseButton button) {

if (player.ActiveInventory != null)
mouse.Mode = eModeUseinv;
if(cEgo.ActiveInventory==iKey){
TextBox1.Text="key";
}
}
Title: Re: TextBox dont'work
Post by: monkey0506 on Wed 07/01/2015 19:57:20
You probably want a Label, not a TextBox. And not intentionally screwing up the automatic indenting is probably a good idea if anyone is ever meant to see, read, understand, or otherwise use your code.

Where are you setting the ActiveInventory property at? You haven't provided complete code. If this is all the code you have then your problem is that you are never assigning the active inventory item.

I probably shouldn't, so as to not cause confusion, but I'll also point out that anyone using default names like TextBox1 is doing it wrong, and you should be using player.ActiveInventory.Name instead of manually setting the string "key" in your script.
Title: Re: TextBox dont'work
Post by: Voedino on Wed 07/01/2015 20:40:11
Quote from: monkey_05_06 on Wed 07/01/2015 19:57:20
You probably want a Label, not a TextBox.
need TextBox
Quote from: monkey_05_06 on Wed 07/01/2015 19:57:20
a good idea...use your code.
idea good, but don't work
Title: Re: TextBox dont'work
Post by: monkey0506 on Thu 08/01/2015 00:51:56
Interesting way to misquote me. Well, I tried. I honestly gave it a shot.

P.S. This type of newbie coder question belongs in the other help board.
Title: Re: TextBox dont'work
Post by: Gilbert on Thu 08/01/2015 04:05:59
Two things to check:
1. This may not matter that much in this case, as your player character may always be cEgo anyway, but for consistency it is advised that the cEgo in line 5 be changed to player, like line 3. This could prevent problems that if you say, decide to have the player able to control another character later.
2. As Monkey mentioned, you need to provide complete codes, at least state where the ActiveInventory of the player is changed, otherwise we cannot help you. For line 5 and line 6 to "not work" it is possible that the player's ActiveInventory is never iKey for some reason.
Title: Re: TextBox dont'work
Post by: AlienCap on Thu 08/01/2015 10:03:51
Firstly you need to understand what the problem is "I want that in TextBox when taking item was his description."

strange that no one was surprised by the terms of the existence of a suitable function btnIconCurInv_Click it's normal button GUI, and not click on inventory items.

I thought that should helpfunction on_mouse_click(MouseButton button) { but for some reason do not work commands GetAtScreenXY and therefore I can not determine when pressed for inventory
need a function that will be able to catch this moment and by the way this code is obtained only after a quick look GlobalScript without verification code, so please first look at what need and only then give advice
Title: Re: TextBox dont'work
Post by: monkey0506 on Thu 08/01/2015 12:31:26
No one was surprised? You mean the way that we have repeatedly asked for complete code? Are you the same person on two accounts? First look only at what is needed then give advice?

First look at screw yourself, then RTFM. The MouseButton parameter is eMouseLeftInv, eMouseMiddleInv, or eMouseRightInv when clicking on an inventory item. Don't sit here and say that code that was never provided doesn't work properly and then blame those that are trying to help you FFS.
Title: Re: TextBox dont'work
Post by: AlienCap on Thu 08/01/2015 14:07:16
firstly I'm just familiar with the developer and therefore know more about this code, Text question incorrectly formulated as that part of the code is useless, it has created over 2 minutes after viewing the global whether funktsii appropriate, I did not know then what it is with the button on the GUI is associated not with the equipment. Yes and I already wrote to him that this code is incorrect, don't understand why he's here as an example.

thanks for the tip about eMouseLeftInv check what it will lead, for some reason, I had not thought of that inventory in the event there is a separate mouse. And I'm sorry but I would how to read to learn to ride and tell me how to walk, that's not restrained


it worked thanks
Title: Re: TextBox dont'work
Post by: Voedino on Thu 08/01/2015 19:04:24
Quote from: monkey_05_06 on Thu 08/01/2015 12:31:26The MouseButton parameter is eMouseLeftInv, eMouseMiddleInv, or eMouseRightInv when clicking on an inventory item.
Big Thanks for help!
Title: Re: TextBox dont'work
Post by: Voedino on Thu 22/01/2015 20:43:49
and now fails to use the item on the item

function on_mouse_click(MouseButton button) {
  if (IsGamePaused() == 1) {
  }
   else if(button == eMouseLeftInv) {
   InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
   cEgo.ActiveInventory = inventory[game.inv_activated];
   if(item==iKey){ 
   if(cEgo.ActiveInventory==iBenzin){
   TextBox1.Text="benzin";
  cEgo.ActiveInventory=null;
  cEgo.LoseInventory (iKey);
  cEgo.LoseInventory (iBenzin);
  cEgo.ActiveInventory=iKey2;
            if(player.InventoryQuantity[iKey2.ID]!=1){
cEgo.AddInventory (iKey2);
   }
}
}
   if(item==iBenzin){ 
   if(cEgo.ActiveInventory==iKey){
  TextBox1.Text="key";
  cEgo.ActiveInventory=null;
  cEgo.LoseInventory (iKey);
  cEgo.LoseInventory (iBenzin);
  cEgo.ActiveInventory=iKey2;
            if(player.InventoryQuantity[iKey2.ID]!=1){
cEgo.AddInventory (iKey2);
   }
}
}
}


ERROR: undefined symbol 'item'
Title: Re: Undefined symbol item
Post by: monkey0506 on Thu 22/01/2015 22:24:20
I'll ignore that you are still intentionally messing up the formatting of your code.

The snippet you posted compiles and runs without any problems. (Note: I graciously provided a closing brace which was missing from your snippet. This was the only "error".)

I did not test the logic of your code for desired behavior because you have not explained what the problem is or what you expect to happen ("fails to use the item on the item" literally means nothing).

Once again, the code does not produce any errors, so this:

Quote from: Inventive Mind on Thu 22/01/2015 20:43:49ERROR: undefined symbol 'item'

Is just simply false.

Good day, sir.




Edit: Pro-tip:

Code (ags) Select
function on_mouse_click(MouseButton button)
{
  if (IsGamePaused() == 1)
  {
  }
  else if (button == eMouseLeftInv)
  {
    InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y); // DEFINE 'item'
    // HERE, 'item' TOTALLY EXISTS
    // ...SEVERAL LINES LATER...
    // YUP, 'item' STILL EXISTS HERE
  } // HERE, 'item' NO LONGER EXISTS
  // YEAH, 'item' STILL DOES NOT EXIST HERE EITHER
}
Title: Re: Undefined symbol item
Post by: Voedino on Sat 24/01/2015 07:59:56
Quote from: monkey_05_06 on Thu 22/01/2015 22:24:20
I'll ignore that you are still intentionally messing up the formatting of your code.
Sorry! my brain was inattentive, not inventive
Now all work! Thanks!