Recognizing Time

Posted by Jkoster on Fri 06 Jun 2003 11:56 AM — 5 posts, 19,113 views.

USA #0
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
Germany #1
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
USA #2
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?
Australia Forum Administrator #3
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

USA #4
Awesome.

It works great. Thanks Nick!