Starting to do a little scripting
Merrie
19 Dec 2007, 03:36I just need a bit of help getting started. Here is what I am trying to do.
Set up a timer to display a weather description every four hours in game. I have looked up the timer function, and looked up the random function, but I'm not exactly sure how to put it together. So every four hours one of the below descriptions would show on a random basis.
So the script would have a rain light description, a rain heavy description, a high wind description, a cloudy description, clear description and a storm description.
Please help me to get started, thank you!
Set up a timer to display a weather description every four hours in game. I have looked up the timer function, and looked up the random function, but I'm not exactly sure how to put it together. So every four hours one of the below descriptions would show on a random basis.
So the script would have a rain light description, a rain heavy description, a high wind description, a cloudy description, clear description and a storm description.
Please help me to get started, thank you!
I think Im Dead
19 Dec 2007, 04:44Hey there, what you want to accomplish is pretty simple, I'll seperate the different pieces of code so it's more clear but understand that everything but the timer and actual weather descriptions could go in one procedure. IF we really wanted the weather descriptions in the same procedure we could easily do so, but that seems messy.
Okay Step one the timer, this will go towards the bottom of your script outside of the game definition block. Quest uses seconds so let's see 60seconds * 60minutes * 4hours equals.... 14400 seconds. So we set our interval to 14400, we tell the timer to execute the procedure "forecast" when the timer hits zero, and we start the game with the timer enabled.
Next we have our "forecast" procedure which goes outside the game definition block and is going to pick a weather description at random, display the description, then turn our weather timer back on so the cycle can repeat.
Now we just have to define our text blocks, also outside the game definition block, for each weather description with names such as weather1, weather2, etc.
That should be pretty much it. The timer points to the procedure, the procedure runs when the timer hits zero, the procedure shows the weather and resets the timer. Pretty simple huh?
Okay Step one the timer, this will go towards the bottom of your script outside of the game definition block. Quest uses seconds so let's see 60seconds * 60minutes * 4hours equals.... 14400 seconds. So we set our interval to 14400, we tell the timer to execute the procedure "forecast" when the timer hits zero, and we start the game with the timer enabled.
define timer <weather>
interval <14400>
action do <forecast>
enabled
end define
Next we have our "forecast" procedure which goes outside the game definition block and is going to pick a weather description at random, display the description, then turn our weather timer back on so the cycle can repeat.
define procedure <forecast>
set numeric <n; $rand(1;6)$>
displaytext <weather%n%>
timeron <weather>
end define
Now we just have to define our text blocks, also outside the game definition block, for each weather description with names such as weather1, weather2, etc.
define text <weather1>
It's lightly drizzling.|n
end define
define text <weather2>
It's pouring heavy rain.|n
end define
define text <weather3>
It's a very blustery day.|n
end define
define text <weather4>
It's very overcast.|n
end define
define text <weather5>
The skies are clear.|n
end define
define text <weather6>
It's terribly stormy.|n
end define
That should be pretty much it. The timer points to the procedure, the procedure runs when the timer hits zero, the procedure shows the weather and resets the timer. Pretty simple huh?
Elexxorine
19 Dec 2007, 09:35Merrie wrote:[...] display a weather description every four hours in game [...]By in game time I assume you don't want 4 hours of real life, which is a lnog time to play a game. Here's what I propose, put the following in the define game block:
define variable <min2>
value <0>
type numeric
display <Time: %hours%:%min1%%min2%.>
onchange if ( %min2% > 9 ) then {
set <min2; 0>
inc <min1>
}
end define
define variable <min1>
value <1>
type numeric
onchange if ( %min1% > 5 ) then {
set <min1; 0>
inc <hours>
}
end define
define variable <hours>
value <7>
type numeric
onchange {
if ( %hours% > 23 ) then set <hours; 0>
if ( %hours% = 0 ) or ( %hours% = 4 ) or ( %hours% = 8 ) or ( %hours% = 12 ) or (
%hours% = 16 ) or ( %hours% = 20 ) or ( %hours% = 24 ) then {
do <weather>
}
}
end define
define variable <weathers>
value <Fine>
type string
display <Weather: $capfirst(#weathers#)$.>
onchange msg <The weather is now #weathers#.>
end define
start {
set string <weather[1]; fine>
set string <weather[2]; rain>
set string <weather[3]; heavy rain>
set string <weather[4]; overcast>
set string <weather[5]; clear>
set string <weather[6]; cold>
set string <weather[7]; stormy>
}
This'll display in-game time in the side pannel, the onchange codes make them work together to make the time right (there's two minute varaibles to make it look right, you don't get '10:3'). Outside the define game block:define timer <time>
interval <4>
action inc <min2>
enabled
end define
define procedure <weather>
set numeric <weathern; $rand(1;7)$>
set string <weathers; #weather[weathern]#>
end define
This should work how you want it...Merrie
19 Dec 2007, 15:54Thank you both very much, as to the time it was just a random figure I threw out. Actually what I'm working on is a ongoing MUCK style game. I have quite a few friends who like this style of text game but setting up a MUCK or MUD is a pain in the tushie. I've done it a few times, I know
The only part of this I'm really unsure about is persistent player information, or saving players, but I'll jump that bridge when I get to it.
