Gui script

Started by SilverWizard_OTF, Sun 22/08/2004 21:37:24

Previous topic - Next topic

SilverWizard_OTF

I made a gui called INTRO, and i have inserted this code (edit script  gui's window).

{
    if(interface==INTRO) {
      if(button==0) {
        do_dance();
        }
      }
Where do_dance() is a function that i made.

The problem is: When i go to test my game, it gives an error:
        "There was an error compiling your script. The problem was in main script.  Error(Line 80):  Already referenced name as import"

After that, when i click yes (i want to fix the script) it goes me to the Global Script, where is my function do_dance().

I can't understand why is this happening. It happens ONLY if i insert the code that i mentioned before. (Gui script).

Thanks for your time
"All we have to decide is what to do, with the time that is given to us"

strazer

Try putting the do_dance function at the top of the global script, before all others.

SilverWizard_OTF

Thanks, that worked.
Hey,  by the way, i have created a Gui but when i say to be revealed (It is GuiOff at start), then it is dissappeared immediately. Why is that  happening?
"All we have to decide is what to do, with the time that is given to us"

strazer

Glad it worked.
I think the error message "Already referenced name as import" could be more intuitive. Chris?

As for your second problem, you say the GUI disappears immediately. Do you see it before it disappears? If not, are you sure it is shown at all?
What code are you using and where did you put it?

SilverWizard_OTF

Actually, i have just created a new Gui (with some buttons) and i  adjusted it as visible.
When the game starts (before fade in) i say: GuiOff( //this Gui).
And when i want to appear it again, i say: GuiOn.
   Actually i want to Pause the game when this Gui will be revealed, and Unpaused, when it will be turned off. Of course, when the game is paused, i want to be able to interact with gui buttons. How can i do that?

Thanks for your help
"All we have to decide is what to do, with the time that is given to us"

Pumaman

If the GUI is set as Popup Modal, it will pause the game automatically when turned on.

As for that earlier error message, I agree that it could be more intuitive so I'll reword it for the next version.

SilverWizard_OTF

Just one question: Could you add a Go to command? I think it would be REALLY useful.
"All we have to decide is what to do, with the time that is given to us"

Gilbert

I think a goto command can cause more troubles than convenient, it may not work good under function oriented languages (C-style) in my opinion.

SilverWizard_OTF

after fade in:

string name;
InputBox("Your name is", name);
//other things
Let's say that i want to have an error message when player will set e.g. numbers than a name and then to be returned to start, to type his name.

Can you do that without a go to command?
"All we have to decide is what to do, with the time that is given to us"

Rui 'Trovatore' Pires

You can get around it by making your own costum GUI instead of InputBox and then checking if the textbox's data is valid, and if so proceed to the next thing.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Ashen

And / or use a combination of StrContains Ã, and Run(object/hotspot/character/inventory)Interaction commands, e.g.
Code: ags

 Ã, // script for object2: Talk to object
string name;
InputBox ("Name?", name);
if (NumCheck (name) == 1){
 Ã, Display ("Hi, %s!", name); // No numbers, so run script
 Ã, // other things
}
else { // Numbers, so run error script
 Ã, Display ("No numbers");
 Ã, RunObjectInteraction (2, MODE_TALK); // Starts script running again
}

Where NumCheck is a custom function that checks the input for numbers. Looks something like this:

Code: ags

function NumCheck (string input) {
 Ã, if (StrContains (input, "0") != -1) return 0; // Returns 0 if 0 is in line
 Ã, else if (StrContains (input, "1") != -1) return 0; // Returns 0 if 1 is in line
 Ã, else if (StrContains (input, "2") != -1) return 0; // Returns 0 if 2 is in line
 Ã, else if (StrContains (input, "3") != -1) return 0; // Returns 0 if 3 is in line
 Ã, else if (StrContains (input, "4") != -1) return 0; // Returns 0 if 4 is in line
 Ã, else if (StrContains (input, "5") != -1) return 0; // Returns 0 if 5 is in line
 Ã, else if (StrContains (input, "6") != -1) return 0; // Returns 0 if 6 is in line
 Ã, else if (StrContains (input, "7") != -1) return 0; // Returns 0 if 7 is in line
 Ã, else if (StrContains (input, "8") != -1) return 0; // Returns 0 if 8 is in line
 Ã, else if (StrContains (input, "9") != -1) return 0; // Returns 0 if 9 is in line
 Ã, else return 1; // No numbers, so return 1
}


Although there may be a more elegant way to search for all numbers at once.
Works for me, anyway. Feel free to use it if it's any good for you.
I know what you're thinking ... Don't think that.

SilverWizard_OTF

Thank you, your help was very valuable!
I agree with you, there many ways to do something. However, it isn't bad to  include as much as it can to AGS (even if it is a Go to script command!). Maybe SOMEONE in a very SPECIAL case, needs something like that.
ReDrum, thanks for your idea. And Ashen, thanks for your code.


"All we have to decide is what to do, with the time that is given to us"

SMF spam blocked by CleanTalk