Go to... script command?

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

Previous topic - Next topic

Ishmael

Quote from: blackman890 on Tue 24/08/2004 15:35:49
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

I was talking for myself, I've made text adventures with it, and in the I see no need for functioning everything.. I've made subs for repeated menu actiions and such, but the game part itself is IF's, PRINT's, GOTO's and labels in the simplest.
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

#21
first of all goto can be useless because you could use something else example:
Code: ags

choose:
print "the door was over there but you didn't have the key, what will you do?"
input "i will 1(break the door), 2(leave) or 3(check my soutcase)" done%
if done% = 1 then
  print "you broke the door but you fell down the stairs and died"
  goto dead
elseif done% = 2 then
  print "you left"
  goto room3
elseif done% = 3 then
  goto suitcase
end if
goto choose
room3:
code....


but what i would do is use subs so each room has its own sub
and the it would be much acurate example
this is sub room2
Code: ags

sub room2
print "the door was over there but you didn't have the key, what will you do?"
input "i will 1(break the door), 2(leave) or 3(check my soutcase)" done%
select case done%

case is 1
   print "you broke the door but you fell down the stairs and died"
    room2% = 5 '5 is what i use for dead

case is 2
   print "you left"
   room2% = 1
  
elseif done% = 3 then
  room2% = 2
end case

loop until done% = 5 or done% = 1 or done% = 2
end sub

then in main code would look like this:
Code: ags

call room2
select case room2%

case is 5
call dead

case is 1
call room3

case is 2
call soutcase


this is what i would use, i would have a sub for each room and using the main code to call them.
it would make it easyier to understand and shorter and would be easyier to change and add because everithing is in order

please forgive my english
Jonatan Nilsson
860 Iceland

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

Ishmael

I make dead ends like those print's inside if's, but the continueing options have a got to put you to the new set of options....
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.

SilverWizard_OTF

I wave programmed with Basic too. From there i learnt Go to, and because i found it so useful command, i thought it would be fine to be added to AGS.
However, i realise that script code can be a bit complicated to be checked, as a result of using this command.
I do not insist any more. AGS provides us options for doing same things, using many different methods.  Also many experienced Basic users had told me too, that this command (Go to) is STRONGLY NOT RECOMMENDED. Anyway, maybe they have right. However, everything, under some circumstances, are useful. Even if a Go to script command in AGS!
            (I wonder, is it truth that AGS script editor is based on C++? I mean, if someone learns scripting in AGS, could he easily learn C++, and vice-versa?)
"All we have to decide is what to do, with the time that is given to us"

Ishmael

Goto would be useful in AGS if you'd be making a text adventure, I see no other use for it. And, as I said, I used Goto in basic only to take the player to the next set of options, or to the help section, the quit section, the main menu... etc. as it is much more clear to me as making everything subs or functions.

Quote(I wonder, is it truth that AGS script editor is based on C++? I mean, if someone learns scripting in AGS, could he easily learn C++, and vice-versa?)

YES, it's stated in very many places already.
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.

SilverWizard_OTF

Hmm... yes, i think you have right about text-based games. I have not tried yet to create one, but i will try (even without  Go to script command!).
   It is very positive that AGS script editor is based on C++. However, i suppose that their command are totally different. I do not think that C++ has a command like "SetPlayerCharacter" !
   Anyway, AGS engine is versatile and i am sure that we can create with it anything we wish, even if we have to do it with a bit complicated method.
   
"All we have to decide is what to do, with the time that is given to us"

Mr Jake

things such as SetPlayerCharacter are pre-set custom functions from within the AGS engine

SilverWizard_OTF

Oh, i didn't knew this. It explains a lot of things. Well, thanks for your information.  This brings me the idea IF I CAN create a function like "Go to" by myself.

(From these i hear, i realise that C++ must be very powerful language.)
"All we have to decide is what to do, with the time that is given to us"

BlackMan890

also, when i learned qbasic, i found ags script very easy, so i would think that you would have none proplem learning C/C++ if you already know AGS script code, NOTE, in C/C++ there are Many Many Many more lines you have to learn
Jonatan Nilsson
860 Iceland

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

SilverWizard_OTF

Thanks for the advice.
Well,  any idea of how can i create a Go to custom function? I imagine that i have to learn things that aren't written to AGS manual  (e.g. we would never be able to create a SetPlayerCharacter function. Custom functions that we can do are very limited in terms of what they can do).

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

Ishmael

The AGS script code is not C, it's a C-like language. You don't, for ex. have FOR loops in it. So, you cannot create a Goto command, atleast not with the standard scripting. I don't konw about the plugin creation possiblities, you could always have a go at making a plugin for Goto in C, but I think it wouldn't turn up very usefull in the end...
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.

Scummbuddy

- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Radiant

Sample go to functionality:

Code: ags

int action;
while (1) {
  if (action == 0) {
    // do stuff
  } else if (action == 1) {
    // do other stuff
  }
   // etc
}


Now you can change the 'action' variable as a substitute for gotos.

SilverWizard_OTF

Yes, i think that's a good approach of a Go to script command. Well done, Radiant.

Anyway, i think it is simpler and and with more effectiveness the idea of using Guis or Function.
Something like this:

int action;
if(action==0) GuiOn(1);   //Or     Function_doONE();
if(action==1) GuiOn(2); // or     Function_doTWO();

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

Edwin Xie

Actually, I think that you don't need goto commands, you can always just type more simple things like GUIOn, SaveGameDialog, RestoreGameDialog show_inventory_window .etc... rather than typing unnecessary script like goto.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Ishmael

Yeah,, that's the whole point in function based languages, at least to my understanding.
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.

BorisZ

Let's make it simple: If you used goto you would use it with line number:

goto 13

But as you noticed, line numbers are not important in object oriented languages, so what else could you do with goto?

goto Where

Considering Where was the title of your line. Isn't it the same as calling functions or subs or something like that (depending of language):

call Where

Considering where is name of your function.

Or am I wrong again?

Ishmael

I think you're at the bottom of it. (The way to say.....?)

Thus QB IS object oriented, goto is useful, for me, when I make text based games/programs, but so far, nowhere else.
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.

SilverWizard_OTF

1 string password;
2 InputBox("The password is",password);
3 if(password==silver) // do things
4 if(password != silver) {
5   Display(WRONG!);
6    "Go to 1;"

It is usefull for something like that, so to do not be obligated to use functions for a so simple case.  But i agree that  using usually this command (Go to) it may make the script code a bit confused and a mess.

Using Function would be:

After fade in:

password_type();        //custom function (lines 1-2)
if(password==silver) // do things
if(password != silver) {
Display(WRONG!);
password_type();        //repeat the function
}


Ok, i got that.

BoriZ,  congratulations for your argumentation!  ;) 
(You should be proud with that,  because a Wizard is used to congratulate only people that really deserve it).
"All we have to decide is what to do, with the time that is given to us"

Alynn

string password;

InputBox("The password is",password);
while (password!=silver){
   Display(WRONG!);
   InputBox("The password is", password);
}
//all other code here

In this instance it's a simple loop problem, you don't need to make recursive calls, which can be bad for the simple fact that recursive calls fill up the stack and will cause a stack overflow if too many wrong answers are given... (just FYI)

SMF spam blocked by CleanTalk