Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ShadeJackrabbit on Fri 23/12/2005 19:31:18

Title: Out of date coding (FIXED)
Post by: ShadeJackrabbit on Fri 23/12/2005 19:31:18
Okay, I am working on my adventure game using the LEC (LucasArts Style) GUI, and when I try to run it, it gives me the following error:

EDIT:It now works! I'd like to thank everybody who helped to get this game running.
Title: Re: Undefined Symbol
Post by: Akumayo on Fri 23/12/2005 19:37:53
What version of AGS are you using?  That, we need to know to really fix the problem, but try this anyway:

Replace:

      if (character[ GetPlayerCharacter() ].ActiveInventory >= 0)
        SetCursorMode(4);


With:

      if (player.ActiveInventory.ID >= 0) {
        Mouse.Mode = 4;
      }


I think that'll fix it if your using an up-to-date version.
Title: Re: Undefined Symbol
Post by: ShadeJackrabbit on Fri 23/12/2005 19:45:28
Thanks! That worked!!! Guess I was using an out-of-date GUI huh? Thanks again!

EDIT:
Great now I got another problem! If I try to look at the inventory, it crashes and gives the following error: FIXED
Quote from: AGS
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x0041D7A2 ; program pointer is +6, ACI version 2.70.864, gtags (73,24)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and notify CJ on the Tech forum.
Title: Re: Fatal Error!!!
Post by: Akumayo on Fri 23/12/2005 21:28:26
Hrm... Looks odd.Ã,  Try replacing the integer "4" in this bit:

Mouse.Mode = 4;


To the name of the cursor you're using, like eModeLook, or eModeInventory, or whatever cursor you're using as number 4.

If that doesn't work, I'm not sure what to do.
Title: Re: Fatal Error!!!
Post by: ShadeJackrabbit on Sat 24/12/2005 00:46:04
No... That doesn't work. I guess I'll contact CJ then.
Wait... who's CJ? Oh, right. Chris Jones.
How do I contact him?
Title: Re: Fatal Error!!!
Post by: Akumayo on Sat 24/12/2005 01:32:40
I wouldn't contact him directly, rather, copy the error message from this post, and make a new post in the Technical Forum (not Technical Archive) containing the error and when it happens.
Title: Re: Fatal Error!!!
Post by: Candle on Sat 24/12/2005 01:37:19
Here is a rotn template that will work with 2.71 626 + above

http://www.xtrafile.com/uploads/2b84b26ffe.zip.html
Title: Re: Undefined Token
Post by: ShadeJackrabbit on Sat 24/12/2005 14:03:44
Oh great, now there's another error:
FIXED

---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was:
In: 'Global script'
Error (line 58): Undefined token 'show_inventory_window'


Here's the general area:

function interface_click(int interface, int button) {
  if (interface == ICONBAR) {
    if (button == 4) {  // show inventory
      show_inventory_window();
    }

Just getting the  game to work seems to be the hard part eh?
Title: Re: Undefined Token
Post by: Gilbert on Sat 24/12/2005 15:49:20
Did you comment out or removed the show_inventory_window() function codes from the global script?
Title: Re: Undefined Token
Post by: ShadeJackrabbit on Sat 24/12/2005 16:48:57
I don't know what comment out means, but I didn't remove show_inventory_window() function codes from the script.
Title: Re: Undefined Token
Post by: Akumayo on Sat 24/12/2005 17:20:30
Did you download the template for the newer version that GBC linked?  I'll bet that'd solve all your problems with errors.
Title: Re: Undefined Token
Post by: ShadeJackrabbit on Sun 25/12/2005 02:39:42
This problem IS with the new template.
Title: Re: Undefined Token
Post by: Akumayo on Sun 25/12/2005 02:45:31
Ahh, found your problem  :D
Replace:

show_inventory_window();


With:

InventoryScreen();


That oughta patch it up real nice.
Title: Re: Undefined Token
Post by: Elliott Hird on Sun 25/12/2005 13:24:59
Default Inv...Screen is evil.
Title: Re: Undefined Token
Post by: ShadeJackrabbit on Sun 25/12/2005 15:34:17
I'll try that when It's not christmas day.
Title: Re: Undefined Token
Post by: Elliott Hird on Sun 25/12/2005 16:14:48
:O Ags > christmas :P
Title: Re: Undefined Token
Post by: ShadeJackrabbit on Sun 25/12/2005 16:17:27
CJ doesn't let you use AGS on Chrstmas Day. it's part of the program.
Title: Re: Undefined Token
Post by: Elliott Hird on Sun 25/12/2005 23:03:37
*cough*double click time in windows systray, change date*cough*
Title: Re: Undefined Token
Post by: ShadeJackrabbit on Mon 26/12/2005 23:35:09
Okay, now I got another "Undefined Token" this one's called "save"


    else if (button == 6)    // save game
      Save();

FIXED
I think I should start learning the AGS language. This is getting real annoying.
Title: Re: Undefined Token
Post by: Gilbert on Tue 27/12/2005 03:34:28
You should really start reading documents than throwing in random function names. :P
Title: Re: Undefined Token
Post by: ShadeJackrabbit on Tue 27/12/2005 17:00:23
I didn't. I'm using a RON template that GBC gave a link to. I'm trying to make it run, yet it won't.
Title: Re: Undefined Token
Post by: Elliott Hird on Tue 27/12/2005 18:38:22
MakeGame();

AddPuzzle();
Title: Re: Undefined Token
Post by: ShadeJackrabbit on Wed 28/12/2005 23:42:51
You aren't being very helpful. How can I make a game if I can't test it or save it because of an error? Answer that before you make rude (to me at least) remarks.
Title: Re: Undefined Token
Post by: Akumayo on Fri 30/12/2005 02:05:58
Replace "Save" with the "SaveDialogue" function methinks.
Title: Re: Undefined Token
Post by: ShadeJackrabbit on Sun 01/01/2006 00:25:05
That doesn't work. Then it says SaveDialogue is undefined.
Title: Re: Undefined Token
Post by: Akumayo on Sun 01/01/2006 00:27:52
Check the manual for Save/Load functions
Title: Re: Undefined Token
Post by: ShadeJackrabbit on Sun 01/01/2006 01:47:17
Now I've got a problem with SetCursorMode. Undefined Token AGAIN.
FIXED
Title: Re: Undefined Token
Post by: Akumayo on Sun 01/01/2006 01:50:33
SetCursorMode isn't used anymore.

Use instead:

Mouse.Mode = eModeLook;

or

Mouse.Mode = eModeUse;

etc.
Title: Re: Parse error in expr
Post by: ShadeJackrabbit on Sun 01/01/2006 03:13:52
Oh great, another problem:

Error (line 59): Parse error in expr near 'eModeUseinv'


  if (button==2) Mouse.Mode = eModeUseinv);

FIXED
So anybody knows, I am using a GUI which is like the lucasarts one, link to it's topic:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=18974.0
Title: Re: Parse error in expr
Post by: Akumayo on Sun 01/01/2006 03:18:28
The last closing brace is unneccessary.
Title: Re: Unknown Scripting
Post by: ShadeJackrabbit on Sun 01/01/2006 04:08:18
Different error: (disregard what was previously here)

Error (line 63): 'top_inv_item' is not a public member of 'GameState'


  if ((button == 7) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed))  {
      game.top_inv_item = game.top_inv_item + game.items_per_line;  }
  if ((button == 6) && (game.top_inv_item > 0))  {
      game.top_inv_item = game.top_inv_item - game.items_per_line;  }
  }

FIXED
Title: Re: Not public member of "GameState"
Post by: Akumayo on Sun 01/01/2006 04:24:16
Replace:

  if ((button == 7) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed))  {
      game.top_inv_item = game.top_inv_item + game.items_per_line;  }
  if ((button == 6) && (game.top_inv_item > 0))  {
      game.top_inv_item = game.top_inv_item - game.items_per_line;  }
  }


With:

if (button == 7) {
  ScrollUp();
}
if (button == 6) {
  ScrollDown();
}
Title: Re: Not public member of "GameState"
Post by: ShadeJackrabbit on Sun 01/01/2006 05:17:31
Only problem is that ScrollUp is an undefined token.
Title: Re: Not public member of "GameState"
Post by: monkey0506 on Sun 01/01/2006 05:42:04
Okay, you have to give a script o-name to your InventoryWindow...and then put that (and a period) in front of ScrollUp...such as if you name it MainInvWindow then it would be:

MainInvWindow.ScrollUp();
Title: Re: Not a public member of 'GUI'
Post by: ShadeJackrabbit on Sun 01/01/2006 16:08:08
But now it says that ScrollUp is not a public member of 'GUI'.
Title: Re: Not a public member of 'GUI'
Post by: Akumayo on Sun 01/01/2006 16:23:05
May we see the script again?
Title: Re: Not a public member of 'GUI'
Post by: ShadeJackrabbit on Sun 01/01/2006 17:43:14
Sure:

#sectionstart interface_click  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
if (interface == COM) {
  if (button==0) Mouse.Mode = eModeWalkto;
  if (button==1) Mouse.Mode = eModeLookat;
  if (button==2) Mouse.Mode = eModeInteract;
  if (button==3) Mouse.Mode = eModePickup;
  if (button==4) Mouse.Mode = eModeTalkto;
  if (button==5) Mouse.Mode = eModeUsermode1;
if (button == 7) {
  gInv.ScrollUp();
}
if (button == 6) {
  gInv.ScrollDown();
}
Title: Re: Not a public member of 'GUI'
Post by: Akumayo on Sun 01/01/2006 17:47:16
Ahh, found your problem!Ã,  You wrote "gInv", the 'g' indicates that Inv is indeed a GUI.Ã,  However, it's actually the Inventory Window that you need to give a script name to.Ã,  Ya' know, the box that all the inventory shows up in?Ã,  You have to click that and assign it a name... like... err... Inventory.Ã,  I think that would work.Ã,  So after re-naming the Inventory Window "Inventory", change the code to:

if (button == 7) {
Ã,  Inventory.ScrollUp();
}
if (button == 6) {
Ã,  Inventory.ScrollDown();
}


I'm pretty sure that'll patch it up.
Title: Re: Not a public member of 'GUI'
Post by: ShadeJackrabbit on Sun 01/01/2006 19:01:58
It almost does, but it says that a "[" is expected.
Title: Re: Not a public member of 'GUI'
Post by: Akumayo on Sun 01/01/2006 19:03:34
We'll need to see the scriipt again  :P
Title: Re: Not a public member of 'GUI'
Post by: monkey0506 on Sun 01/01/2006 20:02:00
He almost definitely used inventory which is a keyword of AGS as it is the ARRAY of global pointers to the InventoryItems, in which case it would need an array index, hence the opening '[' that would be needed.

I would recommend using something else for the name to prevent confusion between your InventoryWindow and inventory...
Title: Re: Not a public member of 'GUI'
Post by: Akumayo on Sun 01/01/2006 22:04:04
Gar.. I never think of things like that....
Title: Re: Not a public member of 'GUI'
Post by: ShadeJackrabbit on Sun 01/01/2006 22:16:33
But then it says that it is undefined.
Title: Re: Undefined token
Post by: Akumayo on Sun 01/01/2006 22:20:56
Try changing the name of the Inventory Window to "MyInv".  Then change "Inventory.SrollUp()" and "Inventory.ScrollDown()" to "MyInv.ScrollUp()" and "MyInv.ScrollDown()"
Title: Re: Undefined token
Post by: ShadeJackrabbit on Mon 02/01/2006 00:19:42
Then "Myinv" is undefined.
Title: Re: Undefined token
Post by: Akumayo on Mon 02/01/2006 00:21:14
Check to see that you Inventory Window is called "Myinv"  capitalization counts!
Title: Re: Undefined token
Post by: monkey0506 on Mon 02/01/2006 02:48:03
Make sure that you are actually setting the script o-name of the InventoryWindow, not just changing the name of the GUI.

Title: Re: Undefined token
Post by: ShadeJackrabbit on Tue 03/01/2006 16:09:11
Oh I get what you mean! It worked! Wait... DARN!! Why is there another error!!!!!! GUIOFF is undefined now. Here's the code:

  if (interface == SET) {     // They clicked a button on the Settings Tab
    if (button == 0)  {  // save game
      GUIOff(SET);
      SaveGameDialog();}
    else if (button == 1) {  // load game
      GUIOff(SET);
      RestoreGameDialog();}
    else if (button == 2)   // restart game
      RestartGame();
    else if (button == 3) {  // quit
      GUIOff(SET);
      QuitGame(1);}
    else if (button == 4) {   // about
      Display("Adventure Game Studio v2 run-time engine[     Copyright (c) 1999-2003 Chris Jones");}
    else if (button == 5) {  // resume
      GUIOff (SET);
      SetCursorMode (MODE_WALK);
      }

Again, I want to make it clear that I am using somebody else's GUI and did not put these commands in myself.
Title: Re: Undefined token
Post by: Ashen on Tue 03/01/2006 16:49:04
As with a lot of the problems so far, it's because the code was written for an older version and the command (GUIOff()) is obsolete. Assuming SET is still the right name for the GUI, replace every instance of GUIOff(SET); with gSet.Visible = false;. (Check the script-o-name of the GUI in the GUI Editor, just to be sure.)

Next time you get an error like this, try looking up the old, 'undefined' command in the manual - it should link you to the new one you need to use instead, saving you from having to wait for someone to answer before you can move on.
Title: Re: Undefined token
Post by: ShadeJackrabbit on Tue 03/01/2006 19:22:16
I've done as Ashen said for a while, yet now I just don't understand this one part of code that is out of date.

      }
    else if (button == 6) {  // volume
      SetDigitalMasterVolume (volume.Value);
      string vol;
      StrFormat (vol, "%d", int Slider.Value;
      SetLabelText(SET, 8, vol);   }
    else if (button == 7) {  // game speed
      SetGameSpeed (GetSliderValue (SET, 7));
      string spe;
      StrFormat (spe, "%d", GetSliderValue(SET, 7));
      SetLabelText(SET, 9, spe);   }
    }  // end if interface SET

P.S. I tried to fix it up, yet now I'm just confused.
Title: Re: Out of date coding
Post by: Ashen on Tue 03/01/2006 20:03:51
What have you tried? What is the problem? What particularly has you confused?
Seriously, you need to be a bit more specific about the problem here.

One thing that stands out:

StrFormat (vol, "%d", int Slider.Value;


Firstly, you're missing a closing ')' (when in doubt, it's usually one of these, a }, or a semi-colon). Secondly, you don't need to declare the int there, and thirdly you'll want to use volume.Value, so the line should be:
StrFormat (vol, "%d", volume.Value);

Now, assuming you've set script-o-names for the sliders (like monkey_05_06 showed for the Inventory Window), you should be set for that and the GetSliderValue(SET, 7) bits later on.

The other problem is the SetLabelText() commands. These depend on whether you're using 2.7 or 2.71 (I can't tell from previous posts).

Either way, first you need to name the labels (objects 8 & 9 on SET).
In 2.7, use Label.SetText(...);. Change Label as needed - obviously - and replace ... with either vol or spe, depending on the label.
In 2.71, I think you can delete the string and StrFormat lines, and just use Label.Text = String.Format("%d", Slider.Value); (changing Label and Slider as needed).
Title: Re: Out of date coding
Post by: ShadeJackrabbit on Tue 03/01/2006 22:34:44
First, I'm using 2.7. Second, there is a problem where it says "else".

    else if (button == 7) {  // game speed
      SetGameSpeed (GetSliderValue (SET, 7));
      string spe;
      StrFormat (spe, "%d", GetSliderValue(SET, 7));
      SetLabelText(SET, 9, spe);   }
    }  // end if interface SET

Says there is a "parse error" of some kind...
Title: Re: Out of date coding
Post by: Ashen on Tue 03/01/2006 23:45:12
Oh, OK. In that case - while everything I said is true, it's also totally beside the point ... Sorry about that - but that's where knowing what the problem actually was before I typed a load of useless stuff would've helped.

Is that all the error says? A line number and "parse error at 'else'", or something like that? Now I'm confused. That error usually means there's a problem with braces on the conditions (usually a missing } somewhere - I said they where trouble), but I can't see any in the code you've posted so far. Is it possible you've accidentally deleted one since you posted that version? If so, the mistake is actually before that line - scan backwards and try to match all the braces (use Ctrl-B to make it easier), to check if that's the problem. Otherwise, can you post the whole condition for if (interface == SET)?

(Alternatively, if you really want to, you could try shifting all the code out of interface_click, and into the proper 2.7-style control functions - more work, but it'll eliminate all the else if ... conditions, and so hopefully solve the problem.)
Title: Re: Out of date coding
Post by: ShadeJackrabbit on Wed 04/01/2006 00:26:48
Nonono. What you sad helped. It helped me find this "else" error. And I made sure I didn't delete any of the "}". Also, here's the error message:

Error (line 93): PE04: parse error at 'else'

Anyways, here's the entire "if" thing you wanted:

70  if (interface == SET) {     // They clicked a button on the Settings Tab
71    if (button == 0)  {  // save game
72      gSet.Visible = false;
73      SaveGameDialog();}
74    else if (button == 1) {  // load game
75      gSet.Visible = false;
76      RestoreGameDialog();}
77    else if (button == 2)   // restart game
78      RestartGame();
79    else if (button == 3) {  // quit
80      gSet.Visible = false;
81      QuitGame(1);}
82    else if (button == 4) {   // about
83      Display("Adventure Game Studio v2 run-time engine[     Copyright (c) 1999-2003 Chris Jones");}
84    else if (button == 5) {  // resume
85      gSet.Visible = false;
86      Mouse.Mode = eModeWalkto;
87      }
88    else if (button == 6) {  // volume
89      SetDigitalMasterVolume (volume.Value);
90      string vol;
91      StrFormat (vol, "%d", volume.Value);
92      volume_number.SetText(vol);
93    else if (button == 7) {  // game speed
94      SetGameSpeed (GetSliderValue (SET, 7));
95      string spe;
96      StrFormat (spe, "%d", GetSliderValue(SET, 7));
97      SetLabelText(SET, 9, spe);   }
98    }  // end if interface SET
Title: Re: Out of date coding
Post by: Ashen on Wed 04/01/2006 00:38:00
92      volume_number.SetText(vol);
93    else if (button == 7) {  // game speed


BAM! Right there, missing } at the end of the if (button == 6) condition. It was there a few posts back - you must've deleted it fixing the other bits (That whole line has changed).

For ease of use, I put the closing brace on the next line, as has been done for if (button == 5) in that code you posted (lines 84 - 87). Doesn't always work, but I find it's easier to see what's missing than if it's on the same line as a command. Just a matter of personal preference, though.
Title: Re: Out of date coding
Post by: ShadeJackrabbit on Wed 04/01/2006 00:57:23
Heh. You know, my friend just looked at it and said almost the same thing. Sorry, I don't know much about C or C++ or any programming.

EDIT:
There! It now works! I'd like to thank everybody who helped to get this game running.
Title: Re: Out of date coding (FIXED)
Post by: monkey0506 on Wed 04/01/2006 01:40:58
Glad you finally got it working! ;D

Furious that Ashen has beaten me once again. :P  Nah, I'm just kidding, but I'm glad I was able to help (some :D).