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.
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.
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:
FIXEDQuote 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.
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.
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?
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.
Here is a rotn template that will work with 2.71 626 + above
http://www.xtrafile.com/uploads/2b84b26ffe.zip.html
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?
Did you comment out or removed the show_inventory_window() function codes from the global script?
I don't know what comment out means, but I didn't remove show_inventory_window() function codes from the script.
Did you download the template for the newer version that GBC linked? I'll bet that'd solve all your problems with errors.
This problem IS with the new template.
Ahh, found your problem :D
Replace:
show_inventory_window();
With:
InventoryScreen();
That oughta patch it up real nice.
Default Inv...Screen is evil.
I'll try that when It's not christmas day.
:O Ags > christmas :P
CJ doesn't let you use AGS on Chrstmas Day. it's part of the program.
*cough*double click time in windows systray, change date*cough*
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.
You should really start reading documents than throwing in random function names. :P
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.
MakeGame();
AddPuzzle();
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.
Replace "Save" with the "SaveDialogue" function methinks.
That doesn't work. Then it says SaveDialogue is undefined.
Check the manual for Save/Load functions
Now I've got a problem with SetCursorMode. Undefined Token AGAIN.
FIXED
SetCursorMode isn't used anymore.
Use instead:
Mouse.Mode = eModeLook;
or
Mouse.Mode = eModeUse;
etc.
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
The last closing brace is unneccessary.
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
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();
}
Only problem is that ScrollUp is an undefined token.
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();
But now it says that ScrollUp is not a public member of 'GUI'.
May we see the script again?
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();
}
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.
It almost does, but it says that a "[" is expected.
We'll need to see the scriipt again :P
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...
Gar.. I never think of things like that....
But then it says that it is undefined.
Try changing the name of the Inventory Window to "MyInv". Then change "Inventory.SrollUp()" and "Inventory.ScrollDown()" to "MyInv.ScrollUp()" and "MyInv.ScrollDown()"
Then "Myinv" is undefined.
Check to see that you Inventory Window is called "Myinv" capitalization counts!
Make sure that you are actually setting the script o-name of the InventoryWindow, not just changing the name of the GUI.
- Choose the GUI from the list of GUIs in the GUI Editor.
- Click on the InventoryWindow to select it.
- In the window with the GUI information (i.e., Script Name, X-Position, Y-Position, Image, etc.), double-click where it says "Script Name."
- Type the script o-name you wish to give the InventoryWindow, i.e. MyInv.
Then you should be able to compile your game. Otherwise...you'll definitely need a more in depth tutorial with photos...so please...try to make this work. :D
If you can't get it to work, I will try to help you though.
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.
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.
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.
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).
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...
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.)
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
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.
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.
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).