summaryrefslogtreecommitdiff
path: root/builtin
Commit message (Expand)AuthorAge
* Give unnamed world names incrementing numbers. Format 'world<number>' (#10247)Paramat2020-10-13
* Add a short_description to be used by mods (#8980)DS2020-10-09
* Improve the `fsaa` setting description (#10279)Hugo Locurcio2020-10-06
* Add minetest.get_artificial_light and minetest.get_natural_light (#5680)HybridDog2020-10-06
* Deprecate get_player_velocity and add_player_velocity (#10173)rubenwardy2020-10-04
* Lua API: Add register_on_chatcommand to SSM and CSM (#7862)Elijah Duffy2020-10-03
* Reduce the FPS when the window is unfocused (#8837)HybridDog2020-10-03
* Chatcommand: Show help message if func returns false without messageHybridDog2020-10-03
* Improve layout of main menu 'local' tab (#10366)Paramat2020-09-29
* Ability to remove minetest.after once set (#10103)tenplus12020-09-23
* Remove "generate normal maps" feature (#10313)hecks2020-09-14
* Add 'ores' global mapgen flag (#10276)Paramat2020-09-03
* Fix #10349 game crashing if dropped an item with undefined light_source (#10351)Pierre-Yves Rollo2020-08-30
* Fix dropped craftitems/tools not using light_source values (#9438)LoneWolfHT2020-08-30
* Add vector.offset (#10321)DS2020-08-29
* Android: drop simple MainMenu (#10227)Maksim2020-08-27
* Auto focus on OK button in main menu error messages (#10300)Vincent Robinson2020-08-23
* Allow the ABM time budget to be configurable.Lars2020-08-18
* ContentDB: Add Update All and download queuing (#9995)rubenwardy2020-08-17
* Allow binding dig, place actions to keys; remove LMB/RMB hardcodingANAND2020-08-15
* Change `last-login` command to show player name in output (#10263)Emojigit2020-08-06
* Mapgen Flat: Add caverns, disabled by default (#9913)Paramat2020-08-05
* Falling: Fix error caused by missing param2SmallJoker2020-07-30
* Fix incorrect view URL for gamesrubenwardy2020-07-28
* Add object crosshair, disable entity selectionboxes by default (#9523)LoneWolfHT2020-07-14
* Fix ContentDB menu icons not appearing on Windowssfan52020-07-08
* Some vector functions useful for working with rotations (#9572)NetherEran2020-06-09
* LuaItemStack: Add __tostring metamethod (#8785)Paul Ouellette2020-06-09
* Fix incorrect extension used for ContentDB thumbnailsrubenwardy2020-06-06
* Add HTTP API to main menu (#9998)rubenwardy2020-06-06
* Add buttons to ContentDB in game bar and configure world (#9944)rubenwardy2020-06-04
* Add minetest.is_creative_enabledWuzzy2020-05-29
* Update ContentDB dialog (#9949)rubenwardy2020-05-29
* Change item entity collisionbox so that they don't sink into the groundsfan52020-05-27
* Fix falling entity not falling through playerssfan52020-05-27
* Make ContentDB downloads not block the UI (#9948)rubenwardy2020-05-27
* Rename “Minimal development test” to “Development Test” (#9928)Wuzzy2020-05-26
* Add engine version string to ContentDB API request (#9890)rubenwardy2020-05-24
* Add chat_font_size setting (#9736)SmallJoker2020-05-24
* Fix documentation of emergequeue_limit settingssfan52020-05-24
* Add on_authplayer callback and 'last_login' to on_joinplayer (#9574)sorcerykid2020-05-23
* Various documentation fixes in settingtypes.txt (#9910)Paramat2020-05-22
* Rework functionality of leveled nodes (#9852)Wuzzy2020-05-19
* builtin: Move common/async_event.lua to mainmenu/async_event.luasfan52020-05-17
* Add core.open_url() to main menu API (#8592)rubenwardy2020-05-17
* Error msg if trying to teleport attached player (#9824)Wuzzy2020-05-16
* Add new Mapgen V7 floatland implementation (#9296)Paramat2020-05-14
* Add chat_log_level setting (#9223)SmallJoker2020-05-14
* Item Entity: Add message to moveresult assertion (#9797)rubenwardy2020-05-14
* Allow placing auto-rotating nodes on other nodes in on_rightclick (#9859)Yaman Qalieh2020-05-13
n class="hl opt">) 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 atlog("[lines][rwt] Skipping",secsfwd,"seconds forward to sync rwt (",rwt.to_string(rwttab),") to real time (",os.date("%H:%M:%S"),")") e_time = e_time + secsfwd end function rwt.set_time(t) e_time = t or 0 if setting_rwt_real == "adapt_real" then adapt_real_time() end atlog("[lines][rwt] Initialized railway time: ",rwt.to_string(e_time)) e_last_epoch = os.time() e_has_loaded = true end function rwt.get_time() return e_time end function rwt.step(dt) if not e_has_loaded then rwt.set_time(0) end if setting_rwt_real=="independent" then -- Regular stepping with dtime e_time = e_time + dt else -- advance with real-world time local diff = os.time() - e_last_epoch e_last_epoch = os.time() if diff>0 then e_time = e_time + diff end end end function rwt.now() return rwt.to_table(e_time) end function rwt.new(c, m, s) return { c = c or 0, m = m or 0, s = s or 0 } end function rwt.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(t2) 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(t2) 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