Turns - that abstract fragment of time

dennis
19 Feb 2005, 14:11
Is there a "Turn" timer function?

Say one player command is a Turn.

If I want a train to pass the railway station every 5 commands of the player for instance?

Or have an actor move from location to location with 1 turns (player input) reststop at each location?

(Not that I have penetrated the secrets of the moving NPC yet)

007bond
19 Feb 2005, 19:27
To create a turn-based system, you'd have to create a special library. I think Computer Whizz's RPG Library has something like this.

paul_one
20 Feb 2005, 02:42
No, it doesn't.

To do this, you create a variable in the startscript, then increase this variable in the "afterturn" part... Then you simply heck to see if that variable is a certain number to do certain things...

I've got a kind of busy day tomorrow, once I get back, and if no-one else makes one, I'll put-up a little demo for you.

Shadowalker
20 Feb 2005, 10:40
Hello there, Dennis. I've just created a DEMO for you. I know that you wanted a train to pass every 5 turns, so I implemented that, but I wasn't sure what you meant about the NPC. I think you meant that you want it to follow you, but I'm not sure about when, how, what etc. you meant. So I created a character that follows you onto the train when you get on. If you wanted something else, tell me, and I'll fix it. Anyway, the DEMO has that every five turns, the train comes....but you only have a limited time to board it before it leaves again....and in case it does, it comes again in another five turns. After boarding, it takes you to a different location. (And moves the NPC with you.) Anyway, I hope I didn't make any mistakes, because it's 4:30 A.M. here, and I'm drop dead tired. If something doesn't work, just let me know. Hope this helps.
P.S. (I know I always post this when I post a code, but here goes again...) In case you don't know how to use the posted code, just copy it into a word program, such as wordpad, or notepad, and save as "something.asl" Then just click on that file.
' "Train Stop/Turn based DEMO"
' Created with QDK 3.53 - UNREGISTERED VERSION

define game <Train Stop/Turn based DEMO>
asl-version <350>
gametype singleplayer
start <Train Station>
game author <>
game version <1.0>
game copyright <© Artistic Productions 2005>
game info <Created with QDK 3.53 - UNREGISTERED EVALUATION VERSION.>
default fontname <Century Gothic>
default fontsize <12>
background <black>
foreground <white>
startscript {
msg <|jc>
flag on <train>
exec <about>
wait <Press any key to begin...>
clear
}
afterturn if flag <train> then inc <Train/Turns; 1>
define variable <location>
type string
value <Chicago>
display <Current City: !>
end define
define variable <Train/Turns>
type numeric
value <0>
onchange if ( %Train/Turns% = 5 ) then {
set <Train/Turns; 0>
if ( #quest.currentroom# = Outside ) then {
msg <|cr|bThe wind rushes past your face as the train pulls in, abruptly halting with a |ijolt.|xi|n|cy|i"All Aboard!!"|xi|cr the conductor shouts.|cb|xb|n|n>
show <Train>
timeron <Train Departing>
flag off <train>
}
else {
msg <|b|crYou hear the clatter of the train pulling into the station. Faintly, you hear the conductor shouting for everyone to |i|cy"Board the train!!"|xi|cb|xb|n>
show <Train>
timeron <Train Departing>
flag off <train>
}
}
end define
end define

define synonyms
end define

define room <Train Station>
prefix <the>
look <All around you, people are bustling about, rushing to and fro to get to various locations.>
north <Hallway>
description msg <You are in the |cg|bTrain Station.|cb|xb|n|n#quest.lookdesc#|n|nYou can travel |cg|bNorth.|cb|xb|n>
end define

define room <Hallway>
prefix <the>
look <It's well-lit. The faint odor of some cleaning agent lingers in the air.>
out <Outside>
south <Train Station>
description msg <You are standing in the |cg|bHallway.|cb|xb|n|n#quest.lookdesc#|n|nYou can travel |cg|bSouth,|xb|cb and |cg|bOut|xb|cb to |b|cgOutside.|cb|xb|n>
end define

define room <Outside>
look <The wind brushes against your face, leaving you with a slight chill.>
south <Hallway>
description msg <You are waiting |cg|bOutside |cr[Chicago]|cg.|cb|xb|n|n#quest.lookdesc#|n|nYou can travel |cg|bSouth.|cb|xb|n>
command <board #spare#;get on #spare#;go on #spare#;enter #spare#> if here <Train> then exec <x train> else msg <You can't get onto the train...it's not here...|n>

define object <Train>
look <The train is painted a dull, metallic gray.>
take msg <Who do you think you are? One of the Incredibles?|n>
speak <Trains don't speak. Usually.>
examine if ask <Would you like to board the train?> then {
timeroff <Train Departing>
timeroff <Train Departing 2>
flag off <train>
msg <You step onto the train. Behind you, you see Mr. Stern getting ready to board too.|n>
goto <On the train>
hide <Mr. Stern>
show <Mr. Stern2>
move <Mr. Stern2; On the train>
timeron <On The Train>
}
else msg <You choose not to get on.|n>
prefix <the>
article <it>
gender <it>
hidden
end define

define object <Mr. Stern>
look <A tall, thin man is resting leaning against the wall.>
take msg <|cy|b"Excuse me!!"|cb|xb|n>
speak msg <|b|cy"Oh hello there, sir,"|xb|cb the thin man says happily, |b|cy"My name is Mr. Stern. Pleased to meet you."|cb|xb |nHe shakes your hand firmly.|n|b|cyI'll be seeing you on the train. I'm going to New York too!"|xb|cb|nWith that, he turns away from you, nothing more to say.|n>
examine <On closer examination, you can see that his face is pockmarked with the remnants of scars that bad acne has left upon him.>
displaytype <Human>
article <him>
gender <he>
end define

define object <Mr. Stern2>
alias <Mr. Stern>
look <A tall, thin man is resting leaning against the wall.>
take msg <|cy|b"Excuse me!!"|cb|xb|n>
speak msg <|cy|b"Isn't this exciting?"|xb|cb Mr. Stern asks you. He smiles. |n|b|cy"I'm visiting my sister in Brooklyn."|xb|cb|nHis smile widens as the thought excites him even more.|n>
examine <On closer examination, you can see that his face is pockmarked with the remnants of scars that bad acne has left upon him.>
displaytype <Human>
article <him>
gender <he>
hidden
end define

define object <Mr. Stern3>
alias <Mr. Stern>
look <A tall, thin man is resting leaning against the wall.>
take msg <|cy|b"Excuse me!!"|cb|xb|n>
speak msg <Mr. Stern looks at you. |b|cy"Isn't New York exciting?"|xb|cb he asks.|n>
examine <On closer examination, you can see that his face is pockmarked with the remnants of scars that bad acne has left upon him.>
displaytype <Human>
article <him>
gender <he>
hidden
end define

end define

define room <On the train>
alias <Train>
look <Seats line the aisles. You are in coach, so the decor isn't of much beauty to your naked eye.>
description msg <You are on the |cg|bTrain.|cb|xb|n|n#quest.lookdesc#|n>
end define

define room <New York>
alias <Outside>
look <The wind brushes against your face, leaving you with a slight chill.>
description msg <You are |cg|bOutside |cr[New York]|cg.|cb|xb|n|n#quest.lookdesc#|n>
end define

define timer <Train Departing>
interval <10>
action {
timeroff <Train Departing>
msg <|cl|bThe train will depart in 5 seconds...|xb|cb|n>
timeron <Train Departing 2>
}
disabled
end define

define timer <Train Departing 2>
interval <5>
action {
timeroff <Train Departing 2>
msg <|cl|bThe train has departed. The next one should be arriving shortly.|xb|cb|n>
hide <Train>
flag on <train>
}
disabled
end define

define timer <On The Train>
interval <15>
action {
timeroff <On The Train>
msg <|cl|bThe train will be arriving in New York in 5 seconds.|xb|cb|n>
timeron <On the train 2>
}
disabled
end define

define timer <On the train 2>
interval <5>
action {
timeroff <On the train 2>
msg <|b|clThe train stops with a lurch. Everyone gets off.|xb|cb|n>
hide <Mr. Stern2>
show <Mr. Stern3>
move <Mr. Stern3; New York>
goto <New York>
set string <location; New York>
}
disabled
end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define



Anonymous
20 Feb 2005, 14:18
Wow - Thanks a million!

It'sgoing to take me some time to digest all of this - But It will surely be a great help, and save me months of mistake making and hair pulling.

Thanks again.

Anonymous
20 Feb 2005, 14:21
Say, are you really this fast? Or did you have something like it allready prepared :)

paul_one
20 Feb 2005, 15:57
Nice work EBfan (hope you don't mind me shortening to that)...

I like the idea of the status-variable event, very neat and tidy! I really should have thought of that - D'oh.

007bond
21 Feb 2005, 06:55

Nice work EBfan (hope you don't mind me shortening to that)...



Writing the full name would have been shorter.

On the main topic, you probably should have the train pass at random intervals, unless you want it for a specific reason, but otherwise, good code ebayfan.

Shadowalker
21 Feb 2005, 09:17

Say, are you really this fast? Or did you have something like it allready prepared

:D lol Nope, I made it all right away. If I was coding in asl, it probably would have taken me longer, but I did in in QDK, and I've actually grown quite fluent in that. Though it did take me a while to make that. But everyone in this forum is so helpful, (and was helpful to me when I first started) and I try to help whenever I can...if the fast coders don't beat me to it first lol....

Nice work EBfan (hope you don't mind me shortening to that)...

I like the idea of the status-variable event,

Thanks for the compliments, every1...and you can call me whatever u want, CW...lol