Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ VBscript
➜ Recognizing Time
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Jkoster
USA (8 posts) Bio
|
| Date
| Fri 06 Jun 2003 11:56 AM (UTC) |
| Message
| I'm trying to write a script that will change the meal I order based on the time of day.
In the game I play, you have three options for meals.
Breakfast, Lunch, or Dinner.
In order to get a meal, you type "get (meal) from Melvin" (Melvin being the distributer).
So far, I have had only one problem. How can I set the script to recognize times of day? The @time command, which returns the current time, lists in a 24-hour format of 00:00:00.
I would like something to the effect of:
if (time) > 00:00:00 < 12:00:00
world.send "get breakfast from melvin"
or some such.
Thank you.
Jay |
[j] | | Top |
|
| Posted by
| Hve
Germany (11 posts) Bio
|
| Date
| Reply #1 on Sat 07 Jun 2003 08:04 PM (UTC) |
| Message
| I'm not quite sure if I got You right.
First of all, the time You need is the time in Your MUD, not Your local time, right?
Once you have that time in 00:00:00 format and as a string,
teses can be compared as strings (i.e.
if (timestring < "12:00:00")
(In fact, You could simply compare timestring<"12:" ).
Hagen
| | Top |
|
| Posted by
| Jkoster
USA (8 posts) Bio
|
| Date
| Reply #2 on Sun 08 Jun 2003 04:27 AM (UTC) |
| Message
| Correct... it is MUD time.
What I have now is a variable set that sets the "time" variable whenever I check time.
The script I'm writing first checks the time, to reset the "time" variable.
Then, it checks the "time" variable to see what time it is.
If it is between 00:00:00 and 07:00:00, it returns Breakfast
If between 07:00:00 and 12:00:00 it returns Lunch.
If between 12:00:00 and 00:00:00 it returns dinner.
The problem I have is how to set the less than and greater than determination.
the way I have it written now (which doesn't work) is:
if (Time) < "12:" > "07:"
world.send "get breakfast from melvin"
end if
if (Time) < "07:" > "00:"
world.send "get dinner from melvin"
end if
if (Time) < "19:" > "12:"
world.send "get lunch from melvin"
end if
Anyone? |
[j] | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Sun 08 Jun 2003 06:48 AM (UTC) |
| Message
| You want something like this:
dim thetime
thetime = world.GetVariable ("time")
if thetime < "12:" and thetime > "07:" then
world.send "get breakfast from melvin"
end if
' and so on
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Jkoster
USA (8 posts) Bio
|
| Date
| Reply #4 on Sun 08 Jun 2003 07:19 PM (UTC) |
| Message
| Awesome.
It works great. Thanks Nick!
|
[j] | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
16,950 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top