Author |
Message |
goroyoshi
|
Posted: Tue Apr 19, 2011 5:43 pm Post subject: using time to add to rpg |
|
|
how can i use the time to tell the game if the marketplace is open
i tried and failed
Turing: |
var timepassed
loop
timepassed := Time.Elapsed %how would i detect what time it is and tell the program what to do
if timepassed > and timepassed < %i have no clue what to do
%do whatever here
else
%do nothing
end if
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Tue Apr 19, 2011 5:46 pm Post subject: RE:using time to add to rpg |
|
|
from Time.Elapsed
Quote:
The Time.Elapsed function returns the amount of time since a program (process) started running. The number of milliseconds since the program started running is returned.
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Raknarg
|
Posted: Tue Apr 19, 2011 5:49 pm Post subject: RE:using time to add to rpg |
|
|
So are you trying to set it up so it opens at a specific time in real time? or are you doing some kind of hour based thing, where when you do some major action, an hour passes or something? |
|
|
|
|
|
goroyoshi
|
Posted: Tue Apr 19, 2011 5:49 pm Post subject: RE:using time to add to rpg |
|
|
whoops sorry, then "time"
Turing: |
var timepassed
loop
timepassed := time %how would i detect what time it is and tell the program what to do
if timepassed > and timepassed < %i have no clue what to do
%do whatever here
else
%do nothing
end if
end loop
|
yes, i would like to open the market when its a certain hour in real time |
|
|
|
|
|
Raknarg
|
Posted: Tue Apr 19, 2011 5:56 pm Post subject: RE:using time to add to rpg |
|
|
You should look up time before you use it, however; you set timepassed as a string and then use:
time (timpassed)
That will set timepasses as a string version of whatever time it is at the moment.
For this problem, I would use strint. This converts a string into an integer. So to check the hour, you would use strint (timepassed (1 .. 2). Then you just compare the hour to the store's hours. |
|
|
|
|
|
goroyoshi
|
Posted: Tue Apr 19, 2011 6:06 pm Post subject: RE:using time to add to rpg |
|
|
im trying to use strint but it returns as illegal character in string passed to strint |
|
|
|
|
|
Raknarg
|
Posted: Tue Apr 19, 2011 6:17 pm Post subject: RE:using time to add to rpg |
|
|
Here, this might help. A random program i made with your stuff.
Turing: |
var timepassed : string
loop
time (timepassed )
put timepassed
if strint (timepassed (1 .. 2)) > 13 or strint (timepassed (1 .. 2)) < 9 then
put "Its not inbetween 9 am and 1 pm."
exit
else
put "It is inbetween 9 am and 1 pm."
exit
end if
cls
end loop
|
|
|
|
|
|
|
Raknarg
|
Posted: Tue Apr 19, 2011 6:21 pm Post subject: RE:using time to add to rpg |
|
|
You dont change time. You check a variable you set with time. It checks the first two numbers of whatever timepassed was when it got to the if statement, or at least it does in my program. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
goroyoshi
|
Posted: Tue Apr 19, 2011 6:21 pm Post subject: RE:using time to add to rpg |
|
|
ok i see, i missed the 1 .. 2
+1 karma |
|
|
|
|
|
Raknarg
|
Posted: Tue Apr 19, 2011 6:22 pm Post subject: RE:using time to add to rpg |
|
|
Yeah, checks only the hours. I beleive that in the morning its preceded by a zero, so it should work all hours of the day.
EDIT: thx |
|
|
|
|
|
|