I've looked through the forums to find if anyone has had the same problem as me. The closest to it, were these:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=27973.0
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=43817.0
For some reason, my problem is this:
GlobalScript.asc(12): Error (line 12): Undefined token 'lblVoice'
The area is scripted as so:
if (!IsSpeechVoxAvailable()) {
// If there is no speech-vox file, and therefore no speech,
// disable all the controls related with speech.
lblVoice.Visible = false;
btnVoice.Visible = false;
sldVoice.Visible = false;
}
I did not touch the global script before this error showed up.
I was customising the GUI 3: gPanel (nothing script related, just visually)
I deleted the voice slider when this error showed up
I tried getting rid of everything voice related (although I will have speech- so to speak) to try and find out if the problem was related to the idea that it lblVoice did not 'lead' anywhere.
Thinking it may be like barefoot's problem where because there is no voice files the game 'delete's it somehow, so I added a hotspot somewhere which makes my character speak...no cigar.
I tried to find the place where lblVoice might have been used, I don't see it anywhere in the whole global script
Tried getting rid of the complete Control Panel function (didn't work)
I haven't slept, lost my patience 5 hours ago.
Help?
What is happening? :'(
NB: On another note, can anyone *PLEASE* explain to me, what lblVoice actually *does*? I don't see it used anywhere else in the global script
If you're getting an undefined token from lblVoice (exact spelling!!) then in editing the GUI you've either deleted or renamed that control.
And it's just a label that lets the user know what the related button and slider are for I guess. I don't really use that panel at all, I always just delete it. I know that by default the voice-related controls will be hidden if there is no speech.vox available. But that wouldn't delete the control from existence.
Edit: Your post is kind of wordy without saying much of anything, but I just realized that you specifically said you deleted these controls. That is your problem. How do you expect AGS to know what lblVoice is when you explicitly deleted it?? Just because you delete a GUIControl (or a GUI, Character, Object, etc.) doesn't mean AGS is going to go through every one of your scripts and just delete lines from your script. That would be ridiculous. What if you deleted the control by mistake, and then added it back to try and fix it? Then your scripts would all be broken.
AGS will let you know if you're still referencing something that you've deleted, and then you can just remove the lines from the script yourself, but again, I don't know how you expect AGS to know what something is that you told it directly to delete.
I know, but here's the thing, I checked the Default game template script and lblVoice doesn't appear to be connected to anything to begin with (or am I missing something?) after being overly frustrated, I'm making the game again from scratch (someone kill me now).
Hopefully I won't do the same mistake twice, and if I do, hopefully I'll be able to remedy it.
The error is being generated in the GlobalScript, right? Well there you go, that's exactly where it's being referenced. You deleted the GUIControl but you didn't remove the line in the GlobalScript that was referencing it, hence the error.
For example if you have the following code:
int i = 5;
// ...
i = 27;
Then you delete that first line:
// deleted line
// ...
i = 27;
What do you expect to happen?
I know exactly what you mean, but what I'm saying is that I was unable to find it. so for example if
int i = 5;
//..
i = 27;
is what I was supposed to be looking for, and is meant to be in the original untouched default script.
how do I explain this, I really don't know how to explain myself well.
int i = 5
//..
i=27
is not there in the original untampered script.
Which is what confused me, greatly.
I did not see anything that related the lblVoice to the gPanel GUI.
A Label is a GUIControl. Every GUIControl belongs to a GUI.
GUIControls can have script names which you can use in your scripts to help make them more readable and prevent bugs from using the wrong control IDs. If you delete the GUIControl then it no longer exists, and the script name is no longer valid. If the script name is no longer valid, then any references to it within any of your scripts will generate this error.
Is this solved now that you know why you were getting the error?
I think so.
But it wouldn't have affected the script of a completely new game.
I'll just back up my stuff more cautiously, its obvious that I still have a lot to learn.
QuoteI tried to find the place where lblVoice might have been used, I don't see it anywhere in the whole global script
Wait, you even posted the block of code where it is used, how did you not find it a few lines down your post..!?
Quote from: vertigoaddict on Tue 21/06/2011 07:20:24I did not see anything that related the lblVoice to the gPanel GUI.
You
could reference the label by its ID:
gPanel.Controls[10].Visible = false;
But if you use the script name, you can access it directly, without having to know what its GUI is called.
Quote from: vertigoaddict on Tue 21/06/2011 07:46:09I think so.
But it wouldn't have affected the script of a completely new game.
So wait, now you're saying you started a brand new game project completely from scratch using the default game template and somehow the issue persisted into the new project as well??
Quote from: Khris on Tue 21/06/2011 08:27:40You could reference the label by its ID:
gPanel.Controls[10].Visible = false;
While you're at it, why use script names at all?
gui[5].Controls[10].Visible = false;
No, really, Khris is right. The entire purpose of these script names is to make things simpler, but if you get rid of the object the script name was referring to then obviously your scripts are going to break. I don't know how else to try and explain it to you.
The issue was not brought to the new project (I had started a new project to see if anything was different in the script that may have caused the error but I couldn't find a difference). I think it was just my newbie understanding of scripting, I was actually looking for another place where the line 'lblVoice' was being used.
I think that last code you showed pretty much clears it for me. Thanks guys
It wasn't being used "somewhere else", it was being used exactly in the same code snippet you posted in your first post, on the exact line that the error was being generated. The line which apparently you didn't delete from the script.
The issue didn't carry over to the new project because you didn't delete those controls or the GUI from the new project, so the script names still validly referred to the items they represented.
If you delete a GUIControl or GUI you must delete any lines of script that refer to the control or GUI yourself. That was your problem.