Go to... script command?

Started by SilverWizard_OTF, Sat 21/08/2004 17:54:44

Previous topic - Next topic

SilverWizard_OTF

Hello
I would like to know if there is a "Go to" script command that i can use to AGS script editor, like this that Basic and Visual Basic have (and other languages).
   
I mean, to do something like:
                  if(my_counter==0) {
                        Go to(...);
                          }

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

BorisZ

You can call function instead of "go to" command (wich is rather obsloete even in visual basic, not to speak of C/C++, or pascal). You can simply declare global function, use it's header to make your room comunicate with it and then call it when you need it. Check your AGS manual about functions.

SilverWizard_OTF

Hmm... that wasn't exactly what i wanted to say.
See this example:
     if(my_counter==0) {
         Display("You must wait one turn");
          my_counter==1;
          }
      if(my_counter==1) {
           //do something
           }

Here is the problem: I want character to wait one turn before the desired action is activated. But if i say "my_counter==1", it will immediately to "if(my_counter==1",  before executing the rest of the code.

   Any suggestions about that problem?
(Hey, a Go to command would be very nice idea)
"All we have to decide is what to do, with the time that is given to us"

BorisZ

I must warn you that I am pretty new at AGS and I am not really sure what you are looking for but I can point you to a couple of possible solutions: 1. I dont think you can use my_counter==1 inside if loop. when == is used, it is only comparing, not adding (at least it is so in other programing languages), you should use my_counter=1 (if(my_counter==0) is OK, my_counter==1 is not). Another thing is that I think you should't use two if's,  but one if and one else if, the way you use it imediately changes variable and goes to another if. So: use if and else if and I think it will work. Forgive me if I missguided you in any way!

SilverWizard_OTF

Thank you BorisZ, Your help was very valuable!
You had right about If and Else If statements
"All we have to decide is what to do, with the time that is given to us"

monkey0506

Or you could try:

a. Read the manual
b. Wait(int loops);
c. Re-read the manual
d. Search the forums
e. Read the manual

Or, alternatively, you could just try reading the manual that comes with AGS...

Hollister Man

CJ has had several requests for GoTo, but its not really that important to most of us.  As you discovered, most of the time, it can be done another way.
That's like looking through a microscope at a bacterial culture and seeing a THOUSAND DANCING HAMSTERS!

Your whole planet is gonna blow up!  Your whole DAMN planet...

SilverWizard_OTF

Monkey,  i know VERY WELL what to do before i take a decision to post my problem here. Of course i had read the manual, but couldn't find that i wanted.
Hollister man, i disagree. I think a Go to command would be VERY VERY useful.
"All we have to decide is what to do, with the time that is given to us"

Gilbert

Just use functions, it's not really that important to have a goto if the language uses mainly function calling in my opinion.

Kweepa

Show us a situation where you think goto would be very useful and we'll show you an easy way to avoid it.

goto is generally a bit of a hack in a compiler, and often leads to less readable code, which is why its use is shunned.

Steve
Still waiting for Purity of the Surf II

Ishmael

Got is useful in QuickBasic, where you don't use the functions that much.

PRINT "Blah balh balh"
IF blah = 1 THEN GOTO blah
PRING "bleh bleh bleh"
END

blah:
PRINT "Even more blah blah blah"
END

or something.... but in C it's easier to use functions and conditions.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

BlackMan890

#11
Quote from: Ishmael on Tue 24/08/2004 12:22:34
Got is useful in QuickBasic, where you don't use the functions that much.

PRINT "Blah balh balh"
IF blah = 1 THEN GOTO blah
PRING "bleh bleh bleh"
END

blah:
PRINT "Even more blah blah blah"
END

or something.... but in C it's easier to use functions and conditions.

you are not suposed to use goto in qbasic*, i know it and therefor use other things like: do ... loop and in this case, function

i know this because i create games in qbasic*.  In qbasic* you are strongly suggested NOT to use goto, only when you can't use anything else and i see that you don't have a reason to use goto and i think you never will

* qbasic = quickbasic
Jonatan Nilsson
860 Iceland

Please go to www.simnet.is/elinnils52 and download my non ags/adventure game :)

BorisZ

There must be a good reason why using goto in most languages is obsolete. I think the main reason are problems with compiling wich goto may cause.

Snarky

No, the reason is that it's bad programming practice, and contrary to the principles of structured programming (Pascal, C) and object-oriented programming (C++, Java).

In a modern programming language, it is never necessary and never any good reasons to use GOTO.

Although yeah, I can see how it could complicate the compiling as well.

SilverWizard_OTF

A go to script command is useful for things like repeating the proccess of typing e.g. a name. In this case, if player by mistake typed numbers, then game should hive an error and return to this step.

Well, it is good to be added a Go to command for for anyone who wants to use it.
"All we have to decide is what to do, with the time that is given to us"

Snarky

You can do what you describe easily with loops and/or functions.

Using GOTO leads to code that is disorganized, difficult to interpret and buggy.

It shouldn't be added because people should not use it, even if they want to.

SilverWizard_OTF

Ok, ok. I think that we had told enough about "Go to" script command. I realise that it isn't so important (anyway, it isn't  terribe to JUST be added this, for anyone who might want to use it).
   By the way, you told something about "loop". Do you mean something like Basic's Loop script command? I haven't seen something like that to AGS sripting tutorial. (I hope you do not mean repeatedly_execute. It isn't so "effective" to use it more than one time).
"All we have to decide is what to do, with the time that is given to us"

Snarky

A loop is a part of the code that is executed again and again until some condition is satisfied. AGS supports the WHILE loop, other common ones include FOR and DO...WHILE.

Dave Gilbert

GOTO was used back in the old BASIC days when programs used line numbers.  If you wanted to move to a specific line within the program, you used the GOTO command.

10 PRINT "HI!"
20 GOTO 10

Would print "HI!" indefintely.

Ahh. Geek memories...

Albert Cuandero

Yep, last time I used "GOTO", I had my - Sinclair ZX Spectrum 48K -  :D

(if any of the younger folks don't know, that's the thing with rubber keys from the mid-eightys)

I don't see any point in adding it to AGS - at least for me.
int do_you_like_me;
if (do_you_like_me == 1) Display ("You can call me Al");
else {}

SMF spam blocked by CleanTalk