aboutsummaryrefslogtreecommitdiff
Commit message (Expand)AuthorAge
* Schematic: Add force_placement parameter to minetest.place_structure APIkwolekr2014-02-15
* Add minetest.set_noiseparam_defaults() Lua APIkwolekr2014-02-15
* Accept any error response code for missing index.mthKahrl2014-02-15
* Add check to avoid usage of broken LuaJIT < 2.0.0beta8sapier2014-02-13
* Fix possible missing unlock of env_locksapier2014-02-12
* ServerEnvironment: Remove direct dependency on EmergeManagerkwolekr2014-02-09
* Define strlcpy on platforms that do not have itkwolekr2014-02-09
* Add capability to read table flag fields from Lua APIkwolekr2014-02-09
* Tune block emerge and sending parameters to more aggressive valueskwolekr2014-02-08
* Make flag strings clear specified flag with 'no' prefixkwolekr2014-02-08
* Remove lots of dead codesapier2014-02-07
* Fix invalid check for fread error on extracting zipsapier2014-02-07
* Fix memory leak in database migrationSelat2014-02-07
* Add missing headerBlockMen2014-02-06
* Add the option to bind to a specific addressShadowNinja2014-02-05
* Remove blank default values for emergequeue_limit_* settingskwolekr2014-02-05
* Revert "Fix settings to honor numeric conversion errors"kwolekr2014-02-05
* Fix another heap-use-after-free in pause menu.Ilya Zhuravlev2014-02-04
* Fix unexpected preprocessor directive in gettext.cppIlya Zhuravlev2014-02-04
* Fix settings to honor numeric conversion errorssapier2014-02-04
* Update minetest.conf.examplekwolekr2014-02-03
* Huge overhaul of the entire MapgenParams systemkwolekr2014-02-03
* Settings: Add no-exception variants of each get methodkwolekr2014-02-03
* Fix crash when a error occurs in a globalstep callbackShadowNinja2014-02-03
* Escape texture pack namesShadowNinja2014-02-03
* Add minetest.kick_player(name, reason)sapier2014-02-03
* Remove noisy error messages, prepend "pathfinder: " to pathfinder messagessapier2014-02-03
* Add missing "-" to list of allowed chars in media filenamessapier2014-02-02
* Add additional check to avoid broadcasting private messages in error conditionssapier2014-02-02
* Add player:override_day_night_ratio() for arbitrarily controlling sunlight br...Perttu Ahola2014-02-01
* Add player:set_sky() with simple skybox supportPerttu Ahola2014-02-01
* Add propper client initializationsapier2014-01-31
* New HUD element - waypoint.RealBadAngel2014-01-26
* Fix bug only half of unreliable queue handled per step in worst casesapier2014-01-26
* Fix use of previously deallocated EmergeManagerkwolekr2014-01-26
* Fix error on mod download failureShadowNinja2014-01-24
* Pass pointed_thing to on_punch and minetest.register_on_punchnode callbacksShadowNinja2014-01-23
* Include system info in the HTTP user agent on WindowsSfan52014-01-23
* Add pointed_thing to minetest.register_on_placenodeShadowNinja2014-01-21
* Connection: Stop processing malformed packet when encounteredkwolekr2014-01-21
* Fix curl dll not getting installed when sound is disabledSfan52014-01-21
* Fix minetest.rotate_and_place() calling on_rightclick() with nil/random param...PilzAdam2014-01-19
* Update lua_api.txt documentationkwolekr2014-01-19
* LuaVoxelManip: Add get_param2_data and set_param2_datakwolekr2014-01-19
* Schematic: Read slice probability table from schematic descriptorskwolekr2014-01-19
* Fixed mainmenu lua errors because of changes in get_textlist_indexDániel Varga2014-01-18
* Deindent HTTPFetchRequest::HTTPFetchRequest()ShadowNinja2014-01-16
* Prevent player jumping into nodes from belowBlockMen2014-01-16
* Prevent placing node when player would be inside new nodeBlockMen2014-01-15
* Fix win32 reading semaphore count not working (broke all queues)sapier2014-01-15
pt">.copy(rwtime) local rwtimet = rwt.to_table(rwtime) return { c = rwtimet.c or 0, m = rwtimet.m or 0, s = rwtimet.s or 0 } end function rwt.to_table(rwtime) if type(rwtime) == "table" then return rwtime elseif type(rwtime) == "string" then return rwt.parse(rwtime) elseif type(rwtime) == "number" then local res = {} local seconds = atfloor(rwtime) res.s = seconds % 60 local minutes = atfloor(seconds/60) res.m = minutes % 60 res.c = atfloor(minutes/60) return res end end function rwt.to_secs(rwtime, c_over) local res = rwtime if type(rwtime) == "string" then res = rwt.parse(rwtime) elseif type(rwtime) == "number" then return rwtime end if type(res)=="table" then return (c_over or res.c)*60*60 + res.m*60 + res.s end end function rwt.to_string(rwtime_p, no_cycle) local rwtime = rwt.to_table(rwtime_p) if rwtime.c~=0 and not no_cycle then return string.format("%d;%02d;%02d", rwtime.c, rwtime.m, rwtime.s) else return string.format("%02d;%02d", rwtime.m, rwtime.s) end end --- local function v_n(str, cpl) if not str then return nil end if str == "" then return 0 end local n = tonumber(str) if not cpl and (n<0 or n>59) then return nil end return n end function rwt.parse(str) --atdebug("parse",str) --3-value form local str_c, str_m, str_s = string.match(str, "^(%-?%d?%d?);(%d%d);(%d?%d?)$") if str_c and str_m and str_s then --atdebug("3v",str_c, str_m, str_s) local c, m, s = v_n(str_c, true), v_n(str_m), v_n(str_s) if c and m and s then return rwt.new(c,m,s) end end --2-value form local str_m, str_s = string.match(str, "^(%d?%d?);(%d?%d?)$") if str_m and str_s then --atdebug("2v",str_m, str_s) local m, s = v_n(str_m), v_n(str_s) if m and s then return rwt.new(0,m,s) end end end --- function rwt.add(t1, t2) local t1s = rwt.to_secs(t1) local t2s = rwt.to_secs(t1) return rwt.to_table(t1s + t2s) end -- How many seconds FROM t1 TO t2 function rwt.diff(t1, t2) local t1s = rwt.to_secs(t1) local t2s = rwt.to_secs(t1) return t2s - t1s end -- Subtract t2 from t1 (inverted argument order compared to diff()) function rwt.sub(t1, t2) return rwt.to_table(rwt.diff(t2, t1)) end -- Adjusts t2 by thresh and then returns time from t1 to t2 function rwt.adj_diff(t1, t2, thresh) local newc = rwt.adjust_cycle(t2, thresh, t1) local t1s = rwt.to_secs(t1) local t2s = rwt.to_secs(t2, newc) return t1s - t2s end -- Threshold values -- "reftime" is the time to which this is made relative and defaults to now. rwt.CA_FUTURE = 60*60 - 1 -- Selected so that time lies at or in the future of reftime (at nearest point in time) rwt.CA_FUTURES = 60*60 -- Same, except when times are equal, advances one full cycle rwt.CA_PAST = 0 -- Selected so that time lies at or in the past of reftime rwt.CA_PASTS = -1 -- Same, except when times are equal, goes back one full cycle rwt.CA_CENTER = 30*60 -- If time is within past 30 minutes of reftime, selected as past, else selected as future. -- Adjusts the "cycle" value of a railway time to be in some relation to reftime. -- Returns new cycle function rwt.adjust_cycle(rwtime, reftime_p, thresh) local reftime = reftime_p or rwt.now() local reftimes = rwt.to_secs(reftime) local rwtimes = rwt.to_secs(rwtime, 0) local timeres = reftimes + thresh - rwtimes local cycles = atfloor(timeres / (60*60)) return cycles end function rwt.adjust(rwtime, reftime, thresh) local cp = rwt.copy(rwtime) cp.c = rwt.adjust_cycle(rwtime, reftime, thresh) return cp end -- Useful for departure times: returns time (in seconds) -- until the next (adjusted FUTURE) occurence of deptime is reached -- in this case, rwtime is used as reftime and deptime should lie in the future of rwtime -- rwtime defaults to NOW function rwt.get_time_until(deptime, rwtime_p) local rwtime = rwtime_p or rwt.now() return rwt.adj_diff(rwtime, deptime, rwt.CA_FUTURE) end -- Helper functions for handling "repeating times" (rpt) -- Those are generic declarations for time intervals like "every 5 minutes", with an optional offset -- ( /02;00-00;45 in timetable syntax -- Get the time (in seconds) until the next time this rpt occurs function rwt.time_to_next_rpt(rwtime, rpt_interval, rpt_offset) local rpti_s = rwt.to_secs(rpt_interval) return (rpti_s - rwt.time_from_last_rpt(rwtime, rpti_s, rpt_offset)) % rpti_s -- Modulo is just there to clip a false value of rpti_s to 0 end -- Get the time (in seconds) since the last time this rpt occured function rwt.time_from_last_rpt(rwtime, rpt_interval, rpt_offset) local rwtime_s = rwt.to_secs(rwtime) local rpti_s = rwt.to_secs(rpt_interval) local rpto_s = rwt.to_secs(rpt_offset) return ((rwtime_s - rpto_s) % rpti_s) end -- From rwtime, get the next time that is divisible by rpt_interval offset by rpt_offset function rwt.next_rpt(rwtime, rpt_interval, rpt_offset) local rwtime_s = rwt.to_secs(rwtime) local rpti_s = rwt.to_secs(rpt_interval) local time_from_last = rwt.time_from_last_rpt(rwtime_s, rpti_s, rpt_offset) local res_s = rwtime_s - time_from_last + rpti_s return rwt.to_table(res_s) end -- from rwtime, get the last time that this rpt matched (which is actually just next_rpt - rpt_offset function rwt.last_rpt(rwtime, rpt_interval, rpt_offset) local rwtime_s = rwt.to_sec(rwtime) local rpti_s = rwt.to_sec(rpt_interval) local time_from_last = rwt.time_from_last_rpt(rwtime, rpt_interval, rpt_offset) local res_s = rwtime_s - time_from_last return rwt.to_table(res_s) end advtrains.lines.rwt = rwt