aboutsummaryrefslogtreecommitdiff
path: root/advtrains_signals_ks/models
ModeNameSize
-rw-r--r--advtrains_signals_ks_head_dist.obj6709logplain
-rw-r--r--advtrains_signals_ks_head_main.obj7058logplain
-rw-r--r--advtrains_signals_ks_lamps_dist.obj62142logplain
-rw-r--r--advtrains_signals_ks_lamps_main.obj86593logplain
-rw-r--r--advtrains_signals_ks_main_smr0.obj130499logplain
-rw-r--r--advtrains_signals_ks_main_smr30.obj132341logplain
-rw-r--r--advtrains_signals_ks_main_smr45.obj132341logplain
-rw-r--r--advtrains_signals_ks_main_smr60.obj132598logplain
-rw-r--r--advtrains_signals_ks_mast.obj9179logplain
-rw-r--r--advtrains_signals_ks_mast_smr0.obj3990logplain
-rw-r--r--advtrains_signals_ks_mast_smr30.obj3955logplain
-rw-r--r--advtrains_signals_ks_mast_smr45.obj3954logplain
-rw-r--r--advtrains_signals_ks_mast_smr60.obj3955logplain
-rw-r--r--advtrains_signals_ks_zs_bottom.obj25042logplain
-rw-r--r--advtrains_signals_ks_zs_top.obj21497logplain
/a> 305 306 307 308
-- railwaytime.lua
-- Advtrains uses a desynchronized time for train movement. Everything is counted relative to this time counter.
-- The advtrains-internal time is in no way synchronized to the real-life time, due to:
-- - Lag
-- - Server stops/restarts
-- However, this means that implementing a "timetable" system using the "real time" is not practical. Therefore,
-- we introduce a custom time system, the RWT(Railway Time), which has nothing to do with RLT(Real-Life Time)
-- RWT has a time cycle of 1 hour. This should be sufficient for most train lines that will ever be built in Minetest.
-- A RWT looks like this:    37;25
-- The ; is to distinguish it from a normal RLT (which has colons e.g. 12:34:56). Left number is minutes, right number is seconds.
-- The minimum RWT is 00;00, the maximum is 59;59.
-- It is OK to leave one places out at either end, esp. when writing relative times, such as:
-- 43;3   22;0   2;30   0;10  ;10
-- Those places are then filled with zeroes. Indeed, ";" would be valid for 00;00 .

-- There is an "adapt mode", which was proposed by gpcf, and results in RWT automatically adapting itself to real-world time.
-- It works by shifting the minute/second after the realtime minute/second, adjusting the cycle value as needed.

-- Using negative times is discouraged. If you need a negative time, you may insert a minus (-) ONLY in the "c" place

--[[
1;23;45 = {
	s=45,
	m=23,
	c=1, -- Cycle(~hour), not displayed most time
}

Railway times can exist in 3 forms:
- as table (see above)
- as string (like "12;34")
- as number (of seconds)

Forms are automagically converted as needed by the converter functions to_*
To be sure a rwt is in the required form, explicitly use a converter.

]]

local rwt = {}

--Time Stamp (Seconds since start of world)
local e_time = 0
local e_has_loaded = false

local setting_rwt_real = minetest.settings:get("advtrains_lines_rwt_realtime")
if setting_rwt_real=="" then
	setting_rwt_real = "independent"
end

local e_last_epoch -- last real-time timestamp

-- Advance RWT to match minute/second to the current real-world time
-- only accounts for the minute/second part, leaves hour/cycle untouched
local function adapt_real_time()
	local datetab = os.date("*t")
	local real_sectotal = 60*datetab.min + datetab.sec
	
	local rwttab = rwt.now()
	local rwt_sectotal = 60*rwttab.m + rwttab.s
	
	--calculate the difference and take it %3600 (seconds/hour) to always move forward
	local secsfwd = (real_sectotal - rwt_sectotal) % 3600