aboutsummaryrefslogtreecommitdiff
path: root/doc
Commit message (Expand)AuthorAge
* Add nametag background setting and object property (#10937)rubenwardy2021-02-17
* Fix short_description fallback order (#10943)rubenwardy2021-02-17
* Use consistent temp folder path (#10892)rubenwardy2021-02-07
* Fix documentation of formspec sound style (#10913)Wuzzy2021-02-04
* Revise dynamic_add_media API to better accomodate future changessfan52021-02-01
* Preserve immortal group for players when damage is disabledsfan52021-01-31
* Fix minetest.dig_node returning true when node isn't diggable (#10890)rubenwardy2021-01-31
* Rework use_texture_alpha to provide three opaque/clip/blend modessfan52021-01-29
* Clarify key_value_swap's edge case (#10799)Graham Northup2021-01-29
* Consistently use "health points" (#10868)Zughy2021-01-27
* FormSpec: Add list spacing, slot size, and noclip (#10083)Vincent Robinson2021-01-23
* Use JSON for favorites, move server list code to Lua (#10085)rubenwardy2021-01-22
* Removed some obsolete code (#10562)Zughy2021-01-21
* ObjectRef: fix some v3f checks (#10602)Zughy2021-01-21
* Fix double word "true" in minetest.is_nan explanation (#10820)M.K2021-01-18
* Document how to make nametags background disappear on players' head (#10783)Zughy2021-01-11
* Implement on_rightclickplayer callback (#10775)JDiaz2021-01-11
* ContentDB: Add overwrite dialog when content is already installed (#10768)rubenwardy2021-01-04
* Add on_deactivate callback for luaentities (#10723)hecks2021-01-02
* Clarify documentation of minetest.get_modpath and minetest.get_modnames (#10771)OgelGames2021-01-02
* Add minetest.get_objects_in_area (#10668)Elias Fleckenstein2020-12-29
* Add open user data button to main menu (#10579)rubenwardy2020-12-19
* Documentation for highest formspec_version[] and changelog (#10592)DS2020-12-18
* Formspec: Allow to specify frame loop for model[] (#10679)Thomas--S2020-12-15
* lua_api.txt: Add mod_orgin to node def (#10697)wsor40352020-12-15
* Various documentation fixes (#10692)SmallJoker2020-12-10
* Cross-reference the node level manipulation functions (#10633)Oblomov2020-12-04
* Add sound to press event of some formspecs elements (#10402)Pierre-Yves Rollo2020-11-23
* Do not set a default for description in itemdef table (#10559)DS2020-11-10
* Fix object interaction distance not being checked (#10547)rubenwardy2020-11-09
* Add model[] formspec element (#10320)SmallJoker2020-11-04
* Clean up l_object.cpp (#10512)Zughy2020-10-22
* Decouple entity minimap markers from nametags replacing with show_on_minimap ...sfan52020-10-19
* Remove all bump mapping and parallax occlusion related code.Lars2020-10-17
* Add ObjectRef:get_children() (#10480)Zughy2020-10-13
* Add a short_description to be used by mods (#8980)DS2020-10-09
* Mention texture modifier colorspace (#10112)HybridDog2020-10-08
* Add minetest.get_artificial_light and minetest.get_natural_light (#5680)HybridDog2020-10-06
* Minimap as HUD element with API controlPierre-Yves Rollo2020-10-04
* Add First Person Attachments (#10360)Jordan Snelling2020-10-04
* Deprecate get_player_velocity and add_player_velocity (#10173)rubenwardy2020-10-04
* Document builtin entities (#9453)Wuzzy2020-10-03
* Add note to docs on how to override privileges (#9792)LoneWolfHT2020-10-03
* Lua API: Add register_on_chatcommand to SSM and CSM (#7862)Elijah Duffy2020-10-03
* Chatcommand: Show help message if func returns false without messageHybridDog2020-10-03
* Ability to remove minetest.after once set (#10103)tenplus12020-09-23
* lua_api.txt: author, release and title fields when downloading from ContentDB...Zughy2020-09-16
* Fix inventory swapping not calling all callbacks (#9923)Lars Müller2020-09-04
* Mark multiply and divide with two vectors as deprecated (Schur product and qu...DS2020-09-01
* Fix dropped craftitems/tools not using light_source values (#9438)LoneWolfHT2020-08-30
"hl opt">.sdata=data.sdata and atlatc.remove_invalid_data(data.sdata) or {} self.fdata={} self.init_code=data.init_code or "" self.step_code=data.step_code or "" end, save = function(self) -- throw any function values out of the sdata table self.sdata = atlatc.remove_invalid_data(self.sdata) return {sdata = self.sdata, init_code=self.init_code, step_code=self.step_code} end, } --Environment --Code modified from mesecons_luacontroller (credit goes to Jeija and mesecons contributors) local safe_globals = { "assert", "error", "ipairs", "next", "pairs", "select", "tonumber", "tostring", "type", "unpack", "_VERSION" } --print is actually minetest.chat_send_all() --using advtrains.print_concat_table because it's cool local function safe_print(t, ...) local str=advtrains.print_concat_table({t, ...}) minetest.log("action", "[atlatc] "..str) minetest.chat_send_all(str) end local function safe_date() return(os.date("*t",os.time())) end -- string.rep(str, n) with a high value for n can be used to DoS -- the server. Therefore, limit max. length of generated string. local function safe_string_rep(str, n) if #str * n > 2000 then debug.sethook() -- Clear hook error("string.rep: string length overflow", 2) end return string.rep(str, n) end -- string.find with a pattern can be used to DoS the server. -- Therefore, limit string.find to patternless matching. -- Note: Disabled security since there are enough security leaks and this would be unneccessary anyway to DoS the server local function safe_string_find(...) --if (select(4, ...)) ~= true then -- debug.sethook() -- Clear hook -- error("string.find: 'plain' (fourth parameter) must always be true for security reasons.") --end return string.find(...) end local mp=minetest.get_modpath("advtrains_luaautomation") local static_env = { --core LUA functions print = safe_print, string = { byte = string.byte, char = string.char, format = string.format, len = string.len, lower = string.lower, upper = string.upper, rep = safe_string_rep, reverse = string.reverse, sub = string.sub, find = safe_string_find, }, math = { abs = math.abs, acos = math.acos, asin = math.asin, atan = math.atan, atan2 = math.atan2, ceil = math.ceil, cos = math.cos, cosh = math.cosh, deg = math.deg, exp = math.exp, floor = math.floor, fmod = math.fmod, frexp = math.frexp, huge = math.huge, ldexp = math.ldexp, log = math.log, log10 = math.log10, max = math.max, min = math.min, modf = math.modf, pi = math.pi, pow = math.pow, rad = math.rad, random = math.random, sin = math.sin, sinh = math.sinh, sqrt = math.sqrt, tan = math.tan, tanh = math.tanh, }, table = { concat = table.concat, insert = table.insert, maxn = table.maxn, remove = table.remove, sort = table.sort, }, os = { clock = os.clock, difftime = os.difftime, time = os.time, date = safe_date, }, POS = function(x,y,z) return {x=x, y=y, z=z} end, getstate = advtrains.getstate, setstate = advtrains.setstate, is_passive = advtrains.is_passive, --interrupts are handled per node, position unknown. (same goes for digilines) --however external interrupts can be set here. interrupt_pos = function(parpos, imesg) local pos=atlatc.pcnaming.resolve_pos(parpos) atlatc.interrupt.add(0, pos, {type="ext_int", ext_int=true, message=imesg}) end, } -- If interlocking is present, enable route setting functions if advtrains.interlocking then local function gen_checks(signal, route_name, noroutesearch) assertt(route_name, "string") local pos = atlatc.pcnaming.resolve_pos(signal) local sigd = advtrains.interlocking.db.get_sigd_for_signal(pos) if not sigd then error("There's no signal at "..minetest.pos_to_string(pos)) end local tcbs = advtrains.interlocking.db.get_tcbs(sigd) if not tcbs then error("Inconsistent configuration, no tcbs for signal at "..minetest.pos_to_string(pos)) end local routeid, route if not noroutesearch then for routeidt, routet in ipairs(tcbs.routes) do if routet.name == route_name then routeid = routeidt route = routet break end end if not route then error("No route called "..route_name.." at "..minetest.pos_to_string(pos)) end end return pos, sigd, tcbs, routeid, route end static_env.can_set_route = function(signal, route_name) local pos, sigd, tcbs, routeid, route = gen_checks(signal, route_name) -- if route is already set on signal, return whether it's committed if tcbs.routeset == routeid then return tcbs.route_committed end -- actually try setting route (parameter 'true' designates try-run local ok = advtrains.interlocking.route.set_route(sigd, route, true) return ok end static_env.set_route = function(signal, route_name) local pos, sigd, tcbs, routeid, route = gen_checks(signal, route_name) return advtrains.interlocking.route.update_route(sigd, tcbs, routeid) end static_env.cancel_route = function(signal) local pos, sigd, tcbs, routeid, route = gen_checks(signal, "", true) return advtrains.interlocking.route.update_route(sigd, tcbs, nil, true) end static_env.get_aspect = function(signal) local pos = atlatc.pcnaming.resolve_pos(signal) return advtrains.interlocking.signal_get_aspect(pos) end end for _, name in pairs(safe_globals) do static_env[name] = _G[name] end --The environment all code calls get is a table that has set static_env as metatable. --In general, every variable is local to a single code chunk, but kept persistent over code re-runs. Data is also saved, but functions and userdata and circular references are removed --Init code and step code's environments are not saved -- S - Table that can contain any save data global to the environment. Will be saved statically. Can't contain functions or userdata or circular references. -- F - Table global to the environment, can contain volatile data that is deleted when server quits. -- The init code should populate this table with functions and other definitions. local proxy_env={} --proxy_env gets a new metatable in every run, but is the shared environment of all functions ever defined. -- returns: true, fenv if successful; nil, error if error function env_proto:execute_code(localenv, code, evtdata, customfct) local metatbl ={ __index = function(t, i) if i=="S" then return self.sdata elseif i=="F" then return self.fdata elseif i=="event" then return evtdata elseif customfct and customfct[i] then return customfct[i] elseif localenv and localenv[i] then return localenv[i] end return static_env[i] end, __newindex = function(t, i, v) if i=="S" or i=="F" or i=="event" or (customfct and customfct[i]) or static_env[i] then debug.sethook() error("Trying to overwrite environment contents") end localenv[i]=v end, } setmetatable(proxy_env, metatbl) local fun, err=loadstring(code) if not fun then return false, err end setfenv(fun, proxy_env) local succ, data = pcall(fun) if succ then data=localenv end return succ, data end function env_proto:run_initcode() if self.init_code and self.init_code~="" then local old_fdata=self.fdata self.fdata = {} atprint("[atlatc]Running initialization code for environment '"..self.name.."'") local succ, err = self:execute_code({}, self.init_code, {type="init", init=true}) if not succ then atwarn("[atlatc]Executing InitCode for '"..self.name.."' failed:"..err) self.init_err=err if old_fdata then self.fdata=old_fdata atwarn("[atlatc]The 'F' table has been restored to the previous state.") end end end end function env_proto:run_stepcode() if self.step_code and self.step_code~="" then local succ, err = self:execute_code({}, self.step_code, nil, {}) if not succ then --TODO end end end --- class interface function atlatc.env_new(name) local newenv={ name=name, init_code="", step_code="", sdata={} } setmetatable(newenv, {__index=env_proto}) return newenv end function atlatc.env_load(name, data) local newenv={} setmetatable(newenv, {__index=env_proto}) newenv:load(name, data) return newenv end function atlatc.run_initcode() for envname, env in pairs(atlatc.envs) do env:run_initcode() end end function atlatc.run_stepcode() for envname, env in pairs(atlatc.envs) do env:run_stepcode() end end