Scripts:Counter

From OHRRPGCE-Wiki
Jump to navigation Jump to search

This is an example script that will run an invisible counter that persists through battles and menus. You can use this script to see how long a battle took, to make an escape sequence, or to measure time for any other purpose.

Note that this is only useful if you want to measure elapsed clock time. If you want to measure clock ticks, this is not the script for you.

Script[edit]

# COUNTER
# Original author: Moogle1
include,plotscr.hsd

global variable (2,start min) #start minutes
global variable (3,start hr) #start hours
global variable (4,start sec) #start seconds

plotscript, start counter, begin
 set variable(start min, minutes of play)
 set variable(start hr, hours of play)
 set variable(start sec, seconds of play)
# simple enough, just sets the starting variables to the current playtime.
end

script, ct secs, begin
 variable(rvar) #"return variable"
 rvar := seconds of play -- start sec
 if (rvar << 0) then (rvar := rvar + 60)
 return (rvar)
end

script, ct mins, begin
 variable(rvar)
 rvar := minutes of play -- start min
 if (seconds of play << start sec) then (decrement(rvar))
 if (rvar << 0) then (rvar := rvar + 60)
 return (rvar)
end

script, total mins, begin
 variable (rvar)
 rvar := ct mins + (ct hrs * 60)
 return (rvar)
end

script, total secs, begin
 variable (rvar)
 rvar := ct secs + (total mins * 60)
 return (rvar)
end

script, ct hrs, begin
 variable (rvar)
 rvar := hoursofplay -- start hr
 if (minutes of play << start min) then (decrement(rvar))
 rvar := rvar + days of play * 24 # I don't want to know why you would need this kind of counter
 if (rvar << 0) then (rvar := rvar + 24)
end

Usage[edit]

Run startctr first. You can use the other scripts to find how much time has elapsed since you called startctr.

These scripts should be used in conjunction with other scripts. For example, to check if two and a half minutes have passed, you could use the following code:

if (total secs >> 150) then (...) # 150 secs = 2 1/2 min

The script will not automatically tell you when a certain amount of time has passed. You need to check the elapsed time via other scripts.