Author Topic: Undefined symbol item  (Read 2143 times)

Inventive Mind

  • Durov's Code - 2017
Undefined symbol item
« on: 07 Jan 2015, 18:37 »
Help me, please!
I want that in TextBox when taking item was his description.
Lines 5 and 6 dont'work
Code: Adventure Game Studio
  1. function btnIconCurInv_Click(GUIControl *control, MouseButton button) {
  2.  
  3. if (player.ActiveInventory != null)
  4. mouse.Mode = eModeUseinv;
  5. if(cEgo.ActiveInventory==iKey){
  6. TextBox1.Text="key";
  7. }
  8. }
  9.  
« Last Edit: 22 Jan 2015, 21:00 by Inventive Mind »

monkey0506

  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
Re: TextBox dont'work
« Reply #1 on: 07 Jan 2015, 19:57 »
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.
« Last Edit: 07 Jan 2015, 20:00 by monkey_05_06 »

Inventive Mind

  • Durov's Code - 2017
Re: TextBox dont'work
« Reply #2 on: 07 Jan 2015, 20:40 »
You probably want a Label, not a TextBox.
need TextBox
a good idea...use your code.
idea good, but don't work

monkey0506

  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
Re: TextBox dont'work
« Reply #3 on: 08 Jan 2015, 00:51 »
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.

Gilbert

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
Re: TextBox dont'work
« Reply #4 on: 08 Jan 2015, 04:05 »
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.

Re: TextBox dont'work
« Reply #5 on: 08 Jan 2015, 10:03 »
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

monkey0506

  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
Re: TextBox dont'work
« Reply #6 on: 08 Jan 2015, 12:31 »
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.

Re: TextBox dont'work
« Reply #7 on: 08 Jan 2015, 14:07 »
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
« Last Edit: 08 Jan 2015, 14:43 by AlienCap »

Inventive Mind

  • Durov's Code - 2017
Re: TextBox dont'work
« Reply #8 on: 08 Jan 2015, 19:04 »
The MouseButton parameter is eMouseLeftInv, eMouseMiddleInv, or eMouseRightInv when clicking on an inventory item.
Big Thanks for help!

Inventive Mind

  • Durov's Code - 2017
Re: TextBox dont'work
« Reply #9 on: 22 Jan 2015, 20:43 »
and now fails to use the item on the item
Code: [Select]
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'
« Last Edit: 22 Jan 2015, 20:49 by Inventive Mind »

monkey0506

  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
Re: Undefined symbol item
« Reply #10 on: 22 Jan 2015, 22:24 »
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:

ERROR: undefined symbol 'item'

Is just simply false.

Good day, sir.



Edit: Pro-tip:

Code: Adventure Game Studio
  1. function on_mouse_click(MouseButton button)
  2. {
  3.   if (IsGamePaused() == 1)
  4.   {
  5.   }
  6.   else if (button == eMouseLeftInv)
  7.   {
  8.     InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y); // DEFINE 'item'
  9.     // HERE, 'item' TOTALLY EXISTS
  10.     // ...SEVERAL LINES LATER...
  11.     // YUP, 'item' STILL EXISTS HERE
  12.   } // HERE, 'item' NO LONGER EXISTS
  13.   // YEAH, 'item' STILL DOES NOT EXIST HERE EITHER
  14. }
« Last Edit: 22 Jan 2015, 22:34 by monkey_05_06 »

Inventive Mind

  • Durov's Code - 2017
Re: Undefined symbol item
« Reply #11 on: 24 Jan 2015, 07:59 »
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!