This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
dev:api:railway_time_api [2019-06-20 11:33] 141.76.179.161 api part 1 |
dev:api:railway_time_api [2022-07-15 14:45] (current) maverick2797 ↷ Page moved from usage:lines:railway_time_api to dev:api:railway_time_api |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Railway Time API ====== | ====== Railway Time API ====== | ||
- | These functions are accessible at | + | This is the documentation for the [[usage: |
+ | These functions are accessible | ||
advtrains.lines.rwt.* | advtrains.lines.rwt.* | ||
- | | + | These functions are also accessible in the LuaATC environment at: |
+ | rwt.* | ||
===== Railway Time Formats ===== | ===== Railway Time Formats ===== | ||
A railway time can be represented by 3 different formats: table, string or seconds. All API functions accept any of the formats as input, and usually output in table form, unless specified otherwise. | A railway time can be represented by 3 different formats: table, string or seconds. All API functions accept any of the formats as input, and usually output in table form, unless specified otherwise. | ||
Line 17: | Line 19: | ||
A time string can be either in the form cc;mm;ss or mm;ss. Trailing 0's can be omitted. | A time string can be either in the form cc;mm;ss or mm;ss. Trailing 0's can be omitted. | ||
mm and ss must be within 0-60. | mm and ss must be within 0-60. | ||
- | 1:23:45 | + | 1;23;45 |
==== Seconds ==== | ==== Seconds ==== | ||
Line 58: | Line 60: | ||
The argument order is reverse to diff(). | The argument order is reverse to diff(). | ||
- | adjust_cycle(rwtime, | + | ===== Repeating Times ===== |
- | adjust(rwtime, | + | |
- | adj_diff(t1, t2, thresh) | + | Sometimes, you need to work with times like "at 15;30 every cycle" or "every two minutes" |
+ | |||
+ | Example: The times 05;00 25;00 45;00 would be expressed by interval 20;00, offset 05;00. | ||
+ | |||
+ | time_to_next_rpt(rwtime, | ||
+ | Returns number of seconds until this repeating time occurs the next time | ||
+ | |||
+ | time_from_last_rpt(rwtime, | ||
+ | Returns number of seconds until this repeating time occured the last time | ||
+ | |||
+ | last_rpt(rwtime, | ||
+ | Returns time when this repeating time occured the last time | ||
+ | |||
+ | next_rpt(rwtime, rpt_interval, rpt_offset) | ||
+ | Returns time when this repeating time occurs the next time | ||
- | get_time_until(deptime, | ||
- | time_to_next_rpt(rwtime, | ||
- | time_from_last_rpt(rwtime, | ||
- | next_rpt(rwtime, |