Post new topic    
Metal Slime
Send private message
Utilizing the system clock 
 PostSun Jun 16, 2019 5:36 am
Send private message Reply with quote
Hi!

I'd like some advice or examples on utilizing the system clock.

Some examples:

A training minigame that can only be used once per (realtime) day/hour/whatever.
Having NPCs appear on set days of the week

Similar to Surfasaurus but for different end results.
Any help much appreciated!

-G
vvight.wordpress.com
Liquid Metal Slime
Send private message
 
 PostSun Jun 16, 2019 6:33 am
Send private message Reply with quote
I haven't personally written anything that uses, them, but the Time Functions in the plotscripting dictionary are a good place to start:

http://hamsterrepublic.com/ohrrpgce/docs/plotdict.xml#Time%20Functions
Ps. I love my wife
Chemical Slime
Send private message
 
 PostSun Jun 16, 2019 10:20 am
Send private message Reply with quote
This is totally my jam. Except users can change their system time to cheat Sad
You might want to (additionally) consider using game-time for some things.

there might be a few ways to use the time.

Broad Usage:
- things on cooldown. similar to how mobile/f2p games have cooldown timers
- special events after real time has elapsed. could be used to measure out rewards or gameplay
- events occurring on specific days of the week, or at certain times.
- perhaps like a day/night or season cycle

Specifically:
- prevent players from abusing/spamming powerful gameplay loops
- ration out rewards or punishments. administer (special) gameplay in doses
- way to reward persistent players. or increase challenges over time.
- celebrate or commemorate specific days or times
- encourage/discourage playing at certain times/days...years etc.,

Stuff like that? I really want to see devs use the in-game and system clock for more things, it's an under-rated tool.
Metal King Slime
Send private message
 
 PostSun Jun 16, 2019 4:04 pm
Send private message Reply with quote
You can use this script by James to work out what day of the week it is.

If you want to allow something (e.g. a making a wish) only every real-world hour, you can do something like this:

Code:
global variable, begin
 100, last wish hour
 101, last wish day
end

plotscript, make a wish, begin
   # Technically you should also check that the month and year are the same, but it's very unlikely that the player
   # will next try to wish on exactly the same hour of the same day of a different month.
  if (system hour == last wish hour && system day == last wish day) then (
    show textbox (45)  # "Come back later!"
    exit script
  )

  show textbox (46)  # "What do you wish?"
  last wish hour := system hour
  last wish day := system day
end


Note that this lets you make a wish at 3:59 and another at 4:00. If you instead want to require at least 60 real-world minutes before you can wish again, you need to count total number of minutes, e.g.: +
Code:
total minutes := system minutes + 60* system hours + 60*24 * system days + 60*24*31 * system months + 60*24*31*12 * system years

And then you can test "if (total minutes >= last wish total minutes + 60)".
OK, so this is not the right number of minutes in a month or year, it can only be used to tell you whether the number of minutes elapsed is at least some amount, if you want the actual amount, then adapt James' day-of-the-week script.

Obviously we need to add builtin script commands to get the ttotal number of play and system seconds.
Metal Slime
Send private message
 
 PostMon Jun 17, 2019 3:17 am
Send private message Reply with quote
Thanks! Exactly what I was looking for , TMC.
vvight.wordpress.com
Slime Knight
Send private message
 
 PostMon Jun 17, 2019 6:23 am
Send private message Reply with quote
It was already mentioned, that the current play time might be useful, too. Here is an example script for a blacksmith, who takes 5 minutes to forge you something. He will tell you, how much time he still needs.
The command "minutes of play" doesn't give you the total minutes of how long the game was played. It must be calculated back by using "hours of play" and "days of play".

Code:
global variable (1,smithready)

plotscript,forgeit,begin
# Total minutes of play + 5 minutes
smithready := days of play * 1440 + hours of play * 60 + minutes of play + 5
end

plotscript,blacksmith,begin
variable (timestamp)
timestamp := days of play * 1440 + hours of play * 60 + minutes of play
clear string (1)
clear string (2)
clear string (3)
if (timestamp > smithready)
then ( $1 = "Your goods are ready! Take them." )
else (
  $1 = "Give me some more time! "
  append number (2,smithready -- timestamp)
  $3 = " more minutes!"
  concatenate strings (2,3)
  concatenate strings (1,2)
)
show string (1)
end
Metal King Slime
Send private message
 
 PostMon Jun 17, 2019 8:19 am
Send private message Reply with quote
BTW Bird, you should write "if (timestamp >= smithready)" instead of "if (timestamp > smithready)", because that script might display "Give me some more time! 0 more minutes!"

Also, it's possible to combine the contents of the 'else' block into one line:
Code:
string sprintf(1, $1 = "Give me some more time! %d more minutes!", smithready -- timestamp)
Display posts from previous: