Newbie: Naming and Linking Scripts
Shoal
05 Sept 2006, 22:24I can't seem to find information in the QDK regarding the naming and linking of scripts.
Is the following how you would name a script for reference?
Is the following how you might tell one script to execute another?
Any help would be greatly appreciated. Thanks! :D
Is the following how you would name a script for reference?
script <scriptName> { }
Is the following how you might tell one script to execute another?
script {
msg <Blah, blah, blah.>
scriptName
}
Any help would be greatly appreciated. Thanks! :D
GameBoy
06 Sept 2006, 00:22It looks as though you're used to programming in another language. Scripts are bits of code that perform things, not Sub Routines, that contain code.
You should read the documentation on ASL scripting, it will help you understand the basics.
You should read the documentation on ASL scripting, it will help you understand the basics.
Shoal
06 Sept 2006, 01:39Actually, I'm not used to programming in any language. Furthermore, I've actually done a fair amount of research into the ASL documentation. I've also, with ASL, successfully created a dice-based RPG action system with multiple degrees of success, along with code for character generation, equipment, and so forth.
Combat, however, is where I'm stumped (among a few other places, such as party members).
I'm just not very good at programming. I never have been. In ASL is the most success I've had to date, even though by the standards of a master (or perhaps someone merely competent) my accomplishments are quite rudimentary.
I have lots and lots of little questions beyond this one, as well. Dumb little questions like, does ASL recognize negative numbers? "Negative" isn't in the index of the ASL help. You know, little things like that.
I can handle the coding if I just get my little questions answered. Please don't assume I'm some noob who's going to ask you all to program my game for me and doesn't even take five minutes to look at the documentation. I have looked at the documentation (for more than five minutes, I might add), and I'm still stuck.
Thanks,
Rob
Combat, however, is where I'm stumped (among a few other places, such as party members).
I'm just not very good at programming. I never have been. In ASL is the most success I've had to date, even though by the standards of a master (or perhaps someone merely competent) my accomplishments are quite rudimentary.
I have lots and lots of little questions beyond this one, as well. Dumb little questions like, does ASL recognize negative numbers? "Negative" isn't in the index of the ASL help. You know, little things like that.
I can handle the coding if I just get my little questions answered. Please don't assume I'm some noob who's going to ask you all to program my game for me and doesn't even take five minutes to look at the documentation. I have looked at the documentation (for more than five minutes, I might add), and I'm still stuck.
Thanks,
Rob
GameBoy
06 Sept 2006, 06:45I didn't assume you were a dumb newb. Most (Like myself at one point), don't even try things first hand.
About your question on calling scripts, there is something similar you can do, and this is calling procedures. Some programmers don't like to have a lot of lines of code in one place, so they prefer to run scripts in other places by calling them. Look into writing scripts as procedures, these can help seperate individual scripts, which also have names so you can easily identify what the script does.
I guess I should have put this in my previous post, but for some reason it just didn't pop into myself, so I apologise for that.
If you need examples, just ask!
About your question on calling scripts, there is something similar you can do, and this is calling procedures. Some programmers don't like to have a lot of lines of code in one place, so they prefer to run scripts in other places by calling them. Look into writing scripts as procedures, these can help seperate individual scripts, which also have names so you can easily identify what the script does.
I guess I should have put this in my previous post, but for some reason it just didn't pop into myself, so I apologise for that.
If you need examples, just ask!
Arbutus
06 Sept 2006, 07:34Yes, search for "procedure and function blocks" in Quest help.
MaDbRiT
06 Sept 2006, 07:53Hi Shoal
Quest doesn't quite work in the manner you suggest, but the effect you are after (I think) is possible in two different ways.
The most common (and the one I think you are seeking) is a procedure call.
Basically you write the code (your other 'scripts' if you prefer that terminology) into procedures, which you define like so:
You can then 'call this script' from somewhere else in your code with
You can of course write as many procedures as you want.
Using your terminology again, the 'define procedure' block as above is how you would 'name a script for reference' and the 'do <procedurename>' is how you would tell one script to execute another.
Hopefully this will help. In passing I should mention that you can also call an action method of an object with
this is a something a use for which you may come across a bit later on, but it's good to know it's there anyway
Al (MaDbRiT)
Quest doesn't quite work in the manner you suggest, but the effect you are after (I think) is possible in two different ways.
The most common (and the one I think you are seeking) is a procedure call.
Basically you write the code (your other 'scripts' if you prefer that terminology) into procedures, which you define like so:
define procedure <shoals_killer_widget_script>
.... put all the ASL commands etc you want here....
end define
You can then 'call this script' from somewhere else in your code with
do <shoals_killer_widget_script>
You can of course write as many procedures as you want.
Using your terminology again, the 'define procedure' block as above is how you would 'name a script for reference' and the 'do <procedurename>' is how you would tell one script to execute another.
Hopefully this will help. In passing I should mention that you can also call an action method of an object with
doaction <name_of_object;name_of_action>
this is a something a use for which you may come across a bit later on, but it's good to know it's there anyway

Al (MaDbRiT)
Shoal
06 Sept 2006, 16:03Hey, thanks all! I'll be sure to look into procedures... :D
Thanks much,
Rob
Thanks much,
Rob
paul_one
06 Sept 2006, 19:57I suggest functions myself - much more programmatically (new word?) correct.
You can effectively 'give' your 'script' bits to do things with.
Like mathmatical functions.
You can effectively 'give' your 'script' bits to do things with.
Like mathmatical functions.
witch wyzwurd
06 Sept 2006, 23:14Hey Shoal,
How's the water? How's the fish?
I just wanted to respond to your pondering concerning negative numbers. I can tell you for sure that it does. Look in an Add Conditional pop-up menu box, you'll see the first choice (Compare two strings or values). If you go to the Comparison drop-down list, you'll now see the different greater to-less than-equal to options. If you have a numerical string set at zero, and go less than zero, Quest will print a negative value. It happened to me for a Status Variable I was using. I also scripted an if-then statement using a negative value. Just test it out, even if the guide doesn't say anything about what you question. If it works... well, then it works!
-Witch
How's the water? How's the fish?
I just wanted to respond to your pondering concerning negative numbers. I can tell you for sure that it does. Look in an Add Conditional pop-up menu box, you'll see the first choice (Compare two strings or values). If you go to the Comparison drop-down list, you'll now see the different greater to-less than-equal to options. If you have a numerical string set at zero, and go less than zero, Quest will print a negative value. It happened to me for a Status Variable I was using. I also scripted an if-then statement using a negative value. Just test it out, even if the guide doesn't say anything about what you question. If it works... well, then it works!
-Witch
MaDbRiT
06 Sept 2006, 23:20Tron wrote
You can pass (multiple) parameters to procedures too, the only difference between procedures and functions is that a function returns a value, a procedure doesn't. You create and call them differently of course, but that's another issue.
Unless you need your code to return a value for some reason (in which case a function is surely the way to go) I don't 'see' using functions in this case.
Al (MaDbRiT)
I suggest functions myself - much more programmatically (new word?) correct.
You can effectively 'give' your 'script' bits to do things with.
Like mathmatical functions.
You can pass (multiple) parameters to procedures too, the only difference between procedures and functions is that a function returns a value, a procedure doesn't. You create and call them differently of course, but that's another issue.
Unless you need your code to return a value for some reason (in which case a function is surely the way to go) I don't 'see' using functions in this case.
Al (MaDbRiT)
paul_one
06 Sept 2006, 23:22You can pass a parameter to a procedure?
I remember trying - and failing - using procedures.. Perhaps I'm doing it wrong?
do <action(1;2;3)> ?
I remember trying - and failing - using procedures.. Perhaps I'm doing it wrong?
do <action(1;2;3)> ?
MaDbRiT
07 Sept 2006, 07:59Tron wrote
That looks right, though I have a clue why you can't get it to work, but first here's a quick 'proof of concept' that shows a string variable, a numeric variable and a literal being passed to a procedure.
So procedures can be passed parameters - but (and I don't know why) if you try calling the above procedure direct from the 'look' in its alternative style, it fails. Very weird 'bug', but it could easily lead you to think procedures with params don't work at all, when actually they do - mostly
Al (MaDbRiT)
You can pass a parameter to a procedure?
I remember trying - and failing - using procedures.. Perhaps I'm doing it wrong?
do <action(1;2;3)> ?
That looks right, though I have a clue why you can't get it to work, but first here's a quick 'proof of concept' that shows a string variable, a numeric variable and a literal being passed to a procedure.
' Quest 3.5 ASL Template
define game <Game Name>
asl-version <350>
gametype singleplayer
game version <1.0>
game author <Your Name>
game copyright <© 2004 ...>
game info <Enter any additional information about this game here.>
start <Start Room>
end define
define room <Start Room>
look <A start room>
script {
set numeric <count;5>
set string <descrip;widgets>
do <test(9;%count%;#descrip#)>
}
end define
define procedure <test>
set string <stuff;>
set <stuff;The $parameter(1)$ $parameter(3)$ are in $parameter(2)$ boxes>
msg <#stuff#>
end define
define text <intro>
Enter intro text here
end define
define text <win>
Enter win text here
end define
define text <lose>
Enter lose text here
end define
So procedures can be passed parameters - but (and I don't know why) if you try calling the above procedure direct from the 'look' in its alternative style, it fails. Very weird 'bug', but it could easily lead you to think procedures with params don't work at all, when actually they do - mostly

Al (MaDbRiT)
witch wyzwurd
07 Sept 2006, 21:14Okay, now, now, now.... hod on a second here.
I come across these in-depth posts concerning variables and parameters and strings and such, and tron is usually involved. Now, what games have you written? I would more than enjoy the opportunity to see how you are implementing the code as a game.
-Witch
I come across these in-depth posts concerning variables and parameters and strings and such, and tron is usually involved. Now, what games have you written? I would more than enjoy the opportunity to see how you are implementing the code as a game.
-Witch
paul_one
08 Sept 2006, 12:32I, unfortunately, first got into a rut with making my RPG-engine, and then started working. So I've been unable to get back into creating any 'game'.
I have started a couple off - Alex saw my first attempt, and I'm sort of sad that I didn't improve and evolve that beginning.
Perhaps I'll go back.
I still wish to create an adventure game though.
I have started a couple off - Alex saw my first attempt, and I'm sort of sad that I didn't improve and evolve that beginning.
Perhaps I'll go back.
I still wish to create an adventure game though.