Axe Software Forums
  Quest Developer Forum
  Now about my fairy....


Author Topic:   Now about my fairy....
Shadow posted 09-02-2003 01:40 GMT     
I have figured out how to make my fairy *poof* appear out of nowhere in the first room and how to enter the player name etc BUT (and that is a big but) how do I make it run another scrift after the character/player answers with their name? Yes, I know all of you are getting tired of my neverending questions but until al decides to marry me and teach me all his coding genius I need help! lol...Here is my coding!

' Created with QDK 3.12

define game <>
asl-version <311>
start <Character Creation: The Border of Reality>
game info <Created with QDK 3.12>
command <open #@object#> if action <#object#; open> then doaction <#object#; open> else msg <You can't open #object#.>
command <close #@object#> if action <#object#; close> then doaction <#object#; close> else msg <You can't close #object#.>
end define

define type <door>
action <open> if property <$thisobject$; closed> then {
msg <You open $thisobjectname$.>
property <$thisobject$; not closed>
}
else msg <$thisobjectname$ is already open.>
action <close> if not property <$thisobject$; closed> then {
property <$thisobject$; closed>
msg <You close $thisobjectname$.>
}
else msg <$thisobject$ is already closed.>
end define

define synonyms
end define

define room <Character Creation: The Border of Reality>
alias <Border of Reality>
look <You have just stepped from reality into the world of E'tanalesia. As you step across the thin border that separates fantasy from the real world, you realize that you are no longer you but someone completely different. The room you are in is small and unfurnished yet it harbors an extremely cozy feeling. The walls glow with an unnatural light and seem to be the only light source in the room. To the north you see a plain wooden door that appears to be the only way out.>
script {
msg <A tiny glowing fairy appears out of nowhere, her giggles catching your attention! She looks you over, nods approvingly and says "Hello, my name is Felia? What is yours?" She tilts her head at you, her face bright with her enthusiasm.>
reveal <Felia, the tiny glowing fairy>
}
command <go door> if property <a plain wooden door; not closed> then {
msg <You go threw a plain wooden door.>
goto <Character Creation: The Gallery>
}
else msg <You walk right into a plain wooden door and smash your nose! Ouch, that hurt!>

define object <a plain wooden door>
alias <a plain wooden door>
alt <door; plain wooden door; wooden door>
look msg <The plain wooden door seems to be old but well cared for.>
prefix <a>
invisible
type <door>
properties <closed>
end define

define object <Felia, the tiny glowing fairy>
alias <Felia>
alt <fairy; a tiny glowing fairy; glowing fairy; tiny fairy>
look msg <At first glance Felia appears to be nothing more than a glowing ball of multicolored light, but upon closer inspection you realize that she is indeed a tiny fairy. Her rainbow colored wings flap with great speed to keep her hovering in the air before you and her long silver hair falls about her body, barely shielding her naked form from view.>
gender <she>
invisible
end define

end define

define room <Character Creation: The Gallery>
look <Flickering torches that are set in scones upon the walls bathe this room in a soft glowing light. The flames illuminate the hand painted murals that cover the stone walls, making the pictures seem to dance between the shadows and light. Soft music drifts from a large stone arch that takes up the west wall.>
end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define


MaDbRiT posted 09-02-2003 11:32 GMT          
Hi Shadow

Here's a way to alter your script to do what you want. I've added a bit of formatting so that the words of the Fairy 'stand out' on the screen, rather than getting lost in the body description.

Here's the changed script:-

quote:

script {
msg <A tiny glowing fairy appears out of nowhere, her giggles catching your attention! She looks you over, nods approvingly and says |n|n|cl"Hello, my name is Felia? What is yours?"|n|n|cbShe tilts her head at you, her face bright with her enthusiasm, waiting for your reply.|n>
reveal <Felia, the tiny glowing fairy>
enter <yourname>
msg <#yourname#|n> 'this prints what the player types next to the screen.
say <|cl#yourname#? What a silly name to have... but welcome to E'tanalesia anyway.|cb>
msg <|n> 'this just puts an empty row in as a spacer.
}

Apologies for slightly tweaking your descriptions, but I think you do need to re-inforce the fact that the next input apter the script is expected to be your reply to the Fairy's question. You can always change it back of course!

You also might like to consider having the fairy simply hover annoyingly until the player speaks to her and initiates a conversation, that automatically puts the player in a 'conversational' frame of mind. :-)

Good luck!

Al

MaDbRiT posted 09-02-2003 11:44 GMT          
Hi (again) Shadow

The point of the above code is to show how, providing you stay inside the original 'script' brackets you can nest as many commands/scripts as you need. There are now 3 "msg" commands, two "say" commands and a couple of "miscellaneous" commands all between the script { and the closing } brace.

I probably didn't make that very clear

Al

Shadow posted 09-02-2003 00:21 GMT          
Al, you are a doll :D
Shadow posted 09-02-2003 00:55 GMT          
The next question the fairy asks is "are you a male or a female?" how do I keep people from entering a gender that is not male or female? As in, if you type in your name in the gender line it will show up as your gender being your name instead, how do you prevent it?
Always full of questions, shadow
Shadow posted 09-02-2003 15:37 GMT          
I have another one...actually I have several...I am hoping that this game that I am making is eventually going to be a multiplayer rpg type game (with races, classes, guilds, etc). I am eventually (and hopefully soon) going to need to make a sit/stand command for the players. There are going to be objects such as chairs that a player can sit in...and of course the players are going to be able to sit on the ground if no object is specified. And I don't what the players to be able to do things such as go to another room while sitting. Gah! My brain hurts from all this thinking and planning but I am enjoying it lol. I am sure I will have a few more in the next few days....no wait...I have another one. I am going to have races with certain stats such as halflings, and elves, and dwarves...is this d&d all over again?...how would I make a race that has stats I know I will have to use a #race# thingy but that is about all that I know :-s.
MaDbRiT posted 09-02-2003 18:53 GMT          
Hi again

Shadow wrote:

quote:

... the fairy asks is "are you a male or a female?" how do I keep people from entering a gender that is not male or female? As in, if you type in your name in the gender line it will show up as your gender being your name instead, how do you prevent it?

You can either test the players input in a loop until they either type 'male' or 'female', or you could use a menu to force then to choose between the two options on offer.

Personally I tend to fight shy of using menus, but this is a classic example of a very good place to use one - so I've coded an example doing just that. Because the room script is growing a bit too big for comfort I have written the menu as a procedure and called it from the script, which makes things neater. Obviously you also need to define a menu. First things first though, here's the script as before, but with the call to the new procedure inserted.

quote:

script {
msg <A tiny glowing fairy appears out of nowhere, her giggles catching your attention! She looks you over, nods approvingly and says |n|n|cl"Hello, my name is Felia? What is yours?"|n|n|cbShe tilts her head at you, her face bright with her enthusiasm, waiting for your reply.|n>
reveal <Felia, the tiny glowing fairy>
enter <yourname>
msg <#yourname#|n> 'this prints what the player types next to the screen.
say <|cl#yourname#? What a silly name to have... but welcome to E'tanalesia anyway.>
msg <|cb|n> 'this just puts an empty row in as a spacer.
do <asksex>
}
{/quote]
The only change is the last line do <asksex>, that calls the procedure 'asksex' which looks like this...
[quote]
define procedure <asksex>
set numeric <playersex;0>
msg <The fairy looks as you quizzically...|n>
say <|clAre you a boy or a girl?>
msg <|cb> ' turn text back to black
choose <playersex>
if (%playersex%=1) then {
say <|clOh, so you're a BOY then.>
msg <|cb> ' turn text back to black
}
else say <|clOh, so you're a GIRL- just like me!>
msg <|cb> ' turn text back to black
end define


This procedure calls the menu 'choosesex' with choose <playersex> - the menu is defined like so.
quote:

define selection <playersex>
info <You tell the fairy you are:>
choice <Male> set <playersex;1>
choice <Female> set <playersex;2>
end define


Notice how I use the menu item chosen to set a variable (playersex) which is then read in the 'asksex' procedure and used so that the Fairy can follow up by commenting on the player's sex.

You may put the procedure & selection definitions pretty much where you like in your code, I tend to put them right at the end before the obligatory trio of text sections for Intro, win & lose.

As regards more questions, it's probably best to ask questions individually as they arise and relate to a specific issue, rather than us trying to guess what you might want to do ;-)

As regards your 'races', 'guilds' etc, these will probably be best implemented as Quest types, that way all the properties relevant to a particular 'class' can be assigned simply by setting an individual object to be a member of the type.

Al

MaDbRiT posted 09-02-2003 18:58 GMT          
OOPS - Missed a bracket there - so that last posting looks a mess, try again!

Hi again
Shadow wrote:


quote:

... the fairy asks is "are you a male or a female?" how do I keep people from entering a gender that is not male or female? As in, if you type in your name in the gender line it will show up as your gender being your name instead, how do you prevent it?


You can either test the players input in a loop until they either type 'male' or 'female', or you could use a menu to force then to choose between the two options on offer.

Personally I tend to fight shy of using menus, but this is a classic example of a very good place to use one - so I've coded an example doing just that. Because the room script is growing a bit too big for comfort I have written the menu as a procedure and called it from the script, which makes things neater. Obviously you also need to define a menu. First things first though, here's the script as before, but with the call to the new procedure inserted.

quote:

script {
msg <A tiny glowing fairy appears out of nowhere, her giggles catching your attention! She looks you over, nods approvingly and says |n|n|cl"Hello, my name is Felia? What is yours?"|n|n|cbShe tilts her head at you, her face bright with her enthusiasm, waiting for your reply.|n>
reveal <Felia, the tiny glowing fairy>
enter <yourname>
msg <#yourname#|n> 'this prints what the player types next to the screen.
say <|cl#yourname#? What a silly name to have... but welcome to E'tanalesia anyway.>
msg <|cb|n> 'this just puts an empty row in as a spacer.
do <asksex>
}


The only change is the last line do <asksex>, that calls the procedure 'asksex' which looks like this...
quote:

define procedure <asksex>
set numeric <playersex;0>
msg <The fairy looks as you quizzically...|n>
say <|clAre you a boy or a girl?>
msg <|cb> ' turn text back to black
choose <playersex>
if (%playersex%=1) then {
say <|clOh, so you're a BOY then.>
msg <|cb> ' turn text back to black
}
else say <|clOh, so you're a GIRL- just like me!>
msg <|cb> ' turn text back to black
end define


This procedure calls the menu 'choosesex' with choose <playersex> - the menu is defined like so.
quote:

define selection <playersex>
info <You tell the fairy you are:>
choice <Male> set <playersex;1>
choice <Female> set <playersex;2>
end define


Notice how I use the menu item chosen to set a variable (playersex) which is then read in the 'asksex' procedure and used so that the Fairy can follow up by commenting on the player's sex.

You may put the procedure & selection definitions pretty much where you like in your code, I tend to put them right at the end before the obligatory trio of text sections for Intro, win & lose.

As regards more questions, it's probably best to ask questions individually as they arise and relate to a specific issue, rather than us trying to guess what you might want to do ;-)

As regards your 'races', 'guilds' etc, these will probably be best implemented as Quest types, that way all the properties relevant to a particular 'class' can be assigned simply by setting an individual object to be a member of the type.

Al

Shadow posted 09-02-2003 19:40 GMT          
how do I do a loop? *ish searching through the manuel*

Thankyou so much again Al, you are God!

Shadow posted 09-02-2003 23:48 GMT          
Well now that all went offline I have another question *le sigh*

I don't want my little nekkid fairy to leave the room until after the player/character opens the door...and I don't want the player/character to be able to leave the room until the fairy does. How can I do it?

MaDbRiT posted 10-02-2003 08:11 GMT          
Shadow wrote:
quote:

...don't want my little nekkid fairy to leave the room until after the player/character opens the door...and I don't want the player/character to be able to leave the room until the fairy does.

As usual there are several different ways to do this, and no 'right way'. So here's one solution which will work :-)

In the room script set a numeric variable to 0, call it 'fairypleased' or something such. This is going to be used as what we call a 'flag', ( before you let the player open the door you test it to see if the fairy is pleased, so it is, so it is a 'flag' that indicates her mood.) Here's how it looks...

quote:

script {
msg <|n A tiny glowing fairy appears out of nowhere, her giggles catching your attention! She looks you over, nods approvingly and says|n|n|cl "Hello, my name is Felia! What is yours?"|n|n|cb She tilts her head at you, her face bright with her enthusiasm.>
reveal <Felia, the tiny glowing fairy>
enter <name>
set numeric <fairypleased;0>
... (rest of script left out for brevity!)


O.K. now you need to alter the door opening code to test if the fairy is happy before you let the player open the door. This is a little trickier because you have used a door 'type', that applies to all doors, whereas we only want the one in this room restricted by the fairy. The solution is to give this door its own 'open' action (just cut n' paste it from the type definition) and then alter it. This means that the door type will still remain unaltered and work for all the other closed doors in the game, while this door will have a slightly different variation. This specific door definition should now look like so:
quote:

define object <a plain wooden door>
alias <a plain wooden door>
alt <door; plain wooden door; wooden door>
look msg <The plain wooden door seems to be old but well cared for.>
prefix <a>
invisible
type <door>
properties <closed>

action <open> if property <$thisobject$; closed> then {
msg <You open $thisobjectname$.>
property <$thisobject$; not closed>
}
else msg <$thisobjectname$ is already open.>

end define



Now that needs to be altered to take account of the fairy's mood. All you need to do is read the fairypleased 'flag' and allow the player to open the door or not. The code would become something like this:
quote:

define object <a plain wooden door>
alias <a plain wooden door>
alt <door; plain wooden door; wooden door>
look msg <The plain wooden door seems to be old but well cared for.>
prefix <a>
invisible
type <door>
properties <closed>

action <open> if property <$thisobject$; closed> then {
if (%fairypleased%) = 0 then {
msg <Try as you might, it just won't open!>
}
else {
msg <You open $thisobjectname$.>
property <$thisobject$; not closed>
}
}
else msg <$thisobjectname$ is already open.>

end define



This uses a nested test (i.e. a test inside a test) and takes a bit of following logically :-) As it stands, the player will now not be able to open the door. All you need to do is set the 'fairypleased' numeric variable (a.k.a. flag) to 1 once your fairy is happy and/or leaves, and the door becomes openable by the player. Here, I've coded so that once the Fairy has the player's name and gender, she is happy and leaves, and the door becomes usable.
quote:

script {

... few lines left out for brevity

enter <name>
msg <#name#|n >
say <Wonderful! It is very nice to meet you #name#!|n>
do <askgender>
set <fairypleased;1>
msg <Seemingly satisfied, the fairy dematerialises as only fairies can.>
conceal <Felia, the tiny glowing fairy>



That should do the trick.

Oh, it might be a good idea (before you go to far) to shorten all the obect names in your game to one-word descriptions and use aliases etc to display more detailed names, you will find it makes your code a lot less difficult to read and hence less error-prone!

Al

Shadow posted 10-02-2003 00:04 GMT          
I love you al! lol *starts looking for those other pictures*
Shadow posted 10-02-2003 00:51 GMT          
I keep getting an error 9, subscript out of range when I try to open one of my rooms to edit. What am I doing wrong?
Alex posted 11-02-2003 11:38 GMT          
It could be a bug in QDK - if you could please email your ASL file to me at [email protected], I'll take a look into it.
Shadow posted 11-02-2003 14:18 GMT          
Thankyou alex but my baby Al fixed it for me already lol. He deserves a cookie! :D
Alex posted 11-02-2003 17:19 GMT          
What was the problem? If you could let me know (and tell me how you fixed it), I can try and get QDK to display more meaningful error messages in the future and not bomb out when it finds something it doesn't expect.
Shadow posted 11-02-2003 18:22 GMT          
I think it was just the fact that I had left out some {} somewhere in the coding. I am not exactly quite sure but I am sure that Al could tell you. I am not the best coder :S that's for sure so I continue to forget the little important things and then I have no idea what is going wrong.
MaDbRiT posted 11-02-2003 20:01 GMT          
Alex wrote:

quote:

What was the problem? If you could let me know ...

it was a mismatch of bracket types, a couple of (manually added I think) 'if' statements were coded

quote:

if (%variable%=0> then


Al
Evelsvia posted 15-02-2003 00:20 GMT          
now THIS, is a confusing post lol. i have no idea how to code at all. is there a manual on how to code for quest net? i have 2 computers infront of me (6 on the network) and i can use one as the server, then connect to it using this computer to test my online games. but that will only be helpful if i knew how to code online games. please help me
MaDbRiT posted 16-02-2003 10:30 GMT          
Elsevia wrote:
quote:

now THIS, is a confusing post lol. i have no idea how to code at all. is there a manual on how to code for quest net

Back in the distant days of Quest 2.1x, I wrote a "how to write ASL code the manual way" tutorial, which Alex distributed with the later V2.1x install packages.

Now version 311 of Quest ASL is a completely different animal from the earlier product, being MUCH more powerful. As a result the old tutorial is effectively redundant and is no longer available.

(Actually that isn't strictly true, it is still available from my website but irrelevant now).

I did begin writing an equivalent manual/tutorial for Quest's "ASL 311", but as it seemed most people were happy to use the Quest GUI (a.k.a. Q.D.K.) to make Quest games anyway, I shelved the idea to concentrate on making a better extension library.

The extension library is now finished, and so I've moved on to developing a game to demonstrate what it can do. This game also serves as the world's best library debugging tool, there is no substitute for actually using the thing!

So, (finally) here's the point of this ramble. IF there is any level of interest in coding Quest ASL the manual way, I will take on the task and write a new 'manual / tutorial' - assuming Alex isn't already doing something.

My previous tutorial assumed absolutely no coding knowledge at all, being aimed at complete beginners and so really taught basic coding principles along the way. It is my opinion that this is an appropriate approach, because if you can code already, Quest ASL is very easy to pick up.

I've taken the liberty of starting a new topic with a duplication of this post, because it really is something of a diversion from the main subject of the original topic.

Al