
-----------------------------------
goroyoshi
Tue Apr 19, 2011 5:43 pm

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 

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


-----------------------------------
Tony
Tue Apr 19, 2011 5:46 pm

RE:using time to add to rpg
-----------------------------------
from 
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.


-----------------------------------
Raknarg
Tue Apr 19, 2011 5:49 pm

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
Tue Apr 19, 2011 5:49 pm

RE:using time to add to rpg
-----------------------------------
whoops sorry, then "time"

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
Tue Apr 19, 2011 5:56 pm

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
Tue Apr 19, 2011 6:06 pm

RE:using time to add to rpg
-----------------------------------
im trying to use strint but it returns as illegal character in string passed to strint

-----------------------------------
Raknarg
Tue Apr 19, 2011 6:17 pm

RE:using time to add to rpg
-----------------------------------
Here, this might help. A random program i made with your stuff.

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
Tue Apr 19, 2011 6:21 pm

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.

-----------------------------------
goroyoshi
Tue Apr 19, 2011 6:21 pm

RE:using time to add to rpg
-----------------------------------
ok i see, i missed the 1 .. 2

+1 karma

-----------------------------------
Raknarg
Tue Apr 19, 2011 6:22 pm

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 :P
