aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
Commit message (Expand)AuthorAge
* Add LuaSecureRandomest312015-11-08
* Add server side ncurses terminalest312015-11-06
* Schematics: Add core.place_schematic_on_vmanip APIkwolekr2015-11-05
* Add callback parameter for core.emerge_area()kwolekr2015-11-02
* SAPI: Fix seed parameter truncation for LuaPseudoRandom constructorkwolekr2015-10-26
* SAPI: Move core.get_us_time() to Util modulekwolekr2015-10-26
* SAPI: Throw runtime error instead of if l_get_mapgen_object called in incorre...kwolekr2015-10-25
* SAPI: Mark all Lua API functions requiring envlockkwolekr2015-10-25
* Correct comment in l_util.cppest312015-10-26
* ABMs: Make catch-up behaviour optionalparamat2015-10-18
* Remove wstrgettextest312015-10-18
* Rename macros with two leading underscoresShadowNinja2015-10-14
* Refactor loggingShadowNinja2015-10-14
* Allow setting chunksize in core.set_mapgen_paramskwolekr2015-10-04
* Hide mapgens from main menu not intended for end userskwolekr2015-10-04
* Add emerge completion callback mechanismkwolekr2015-10-04
* Define and use limit constants for Irrlicht fixed-width typeskwolekr2015-10-04
* Add get_biome_id(biome_name) callbackDuane Robertson2015-10-02
* Add /emergeblocks command and core.emerge_area() Lua APIkwolekr2015-09-23
* Various style cleanups + unused code removalest312015-09-19
* Ore: Add puff ore typekwolekr2015-09-17
* Ore: Add ore sheet column height range selectionkwolekr2015-09-13
* Areastore: fix "attempt to index a number value"est312015-09-03
* l_mainmenu.h: remove unused l_get_dirlist functionest312015-08-30
* Push error handler afresh each time lua_pcall is usedKahrl2015-08-27
* Use numeric indices and raw table access with LUA_REGISTRYINDEXKahrl2015-08-27
* SAPI: Disable unlockable time profilingkwolekr2015-08-18
* SEnv: Remove static_exists from ActiveObjects in deleted blockskwolekr2015-08-16
* minimap: Add ability to disable from serverkwolekr2015-08-13
* SAPI: Track last executed mod and include in error messageskwolekr2015-08-12
* Improve Script CPP API diagnosticskwolekr2015-08-05
* Biome API: Make fallback biome stone and water, disable fillerparamat2015-08-03
* Add AreaStore data structureest312015-07-27
* Fix MSVC number conversion warningSmallJoker2015-07-25
* Fix minetest.get_(all)_craft_recipe(s) regressionest312015-07-25
* Cleanup server addparticle(spawner) by merge two identical functions.Loic Blot2015-07-25
* Optional reconnect functionalityest312015-07-23
* Added get_player_velocity() method. Fixes #1176Elia Argentieri2015-07-20
* Refactor particle code to remove the while loopsTeTpaAka2015-07-18
* Make acc and vel deprecated in add_particle and search for acceleration and v...TeTpaAka2015-07-18
* Fix invisible player when the attached entity is removedTeTpaAka2015-07-18
* Fix damage flash when damage disabledkwolekr2015-07-10
* Use UTF-8 instead of narrowest312015-07-08
* Fix bug when craft input isn't replacedTeTpaAka2015-06-22
* Fix some issues with animations, and allow non-looped animations to be definedMirceaKitsune2015-06-22
* Mapgen objects: Enable heatmap and humidmap for all biome api mapgensparamat2015-06-20
* Use utf-8 in formspecsIlya Zhuravlev2015-06-13
* Add return list of individual counts to find_node_in_areaTeTpaAka2015-06-13
* Make get_biome_list() error message more helpfulkwolekr2015-05-28
* Add some missing getter functions to the lua APITeTpaAka2015-05-28
ss="hl kwd">notify_authentication_modified() end local function save_auth_file() local newtable = {} -- Check table for validness before attempting to save for name, stuff in pairs(core.auth_table) do assert(type(name) == "string") assert(name ~= "") assert(type(stuff) == "table") assert(type(stuff.password) == "string") assert(type(stuff.privileges) == "table") assert(stuff.last_login == nil or type(stuff.last_login) == "number") end local file, errmsg = io.open(core.auth_file_path, 'w+b') if not file then error(core.auth_file_path.." could not be opened for writing: "..errmsg) end for name, stuff in pairs(core.auth_table) do local priv_string = core.privs_to_string(stuff.privileges) local parts = {name, stuff.password, priv_string, stuff.last_login or ""} file:write(table.concat(parts, ":").."\n") end io.close(file) end read_auth_file() core.builtin_auth_handler = { get_auth = function(name) assert(type(name) == "string") -- Figure out what password to use for a new player (singleplayer -- always has an empty password, otherwise use default, which is -- usually empty too) local new_password_hash = "" -- If not in authentication table, return nil if not core.auth_table[name] then return nil end -- Figure out what privileges the player should have. -- Take a copy of the privilege table local privileges = {} for priv, _ in pairs(core.auth_table[name].privileges) do privileges[priv] = true end -- If singleplayer, give all privileges except those marked as give_to_singleplayer = false if core.is_singleplayer() then for priv, def in pairs(core.registered_privileges) do if def.give_to_singleplayer then privileges[priv] = true end end -- For the admin, give everything elseif name == core.setting_get("name") then for priv, def in pairs(core.registered_privileges) do privileges[priv] = true end end -- All done return { password = core.auth_table[name].password, privileges = privileges, -- Is set to nil if unknown last_login = core.auth_table[name].last_login, } end, create_auth = function(name, password) assert(type(name) == "string") assert(type(password) == "string") core.log('info', "Built-in authentication handler adding player '"..name.."'") core.auth_table[name] = { password = password, privileges = core.string_to_privs(core.setting_get("default_privs")), last_login = os.time(), } save_auth_file() end, set_password = function(name, password) assert(type(name) == "string") assert(type(password) == "string") if not core.auth_table[name] then core.builtin_auth_handler.create_auth(name, password) else core.log('info', "Built-in authentication handler setting password of player '"..name.."'") core.auth_table[name].password = password save_auth_file() end return true end, set_privileges = function(name, privileges) assert(type(name) == "string") assert(type(privileges) == "table") if not core.auth_table[name] then core.builtin_auth_handler.create_auth(name, core.get_password_hash(name, core.setting_get("default_password"))) end core.auth_table[name].privileges = privileges core.notify_authentication_modified(name) save_auth_file() end, reload = function() read_auth_file() return true end, record_login = function(name) assert(type(name) == "string") assert(core.auth_table[name]).last_login = os.time() save_auth_file() end, } function core.register_authentication_handler(handler) if core.registered_auth_handler then error("Add-on authentication handler already registered by "..core.registered_auth_handler_modname) end core.registered_auth_handler = handler core.registered_auth_handler_modname = core.get_current_modname() handler.mod_origin = core.registered_auth_handler_modname end function core.get_auth_handler() return core.registered_auth_handler or core.builtin_auth_handler end local function auth_pass(name) return function(...) local auth_handler = core.get_auth_handler() if auth_handler[name] then return auth_handler[name](...) end return false end end core.set_player_password = auth_pass("set_password") core.set_player_privs = auth_pass("set_privileges") core.auth_reload = auth_pass("reload") local record_login = auth_pass("record_login") core.register_on_joinplayer(function(player) record_login(player:get_player_name()) end) core.register_on_prejoinplayer(function(name, ip) local auth = core.auth_table if auth[name] ~= nil then return end local name_lower = name:lower() for k in pairs(auth) do if k:lower() == name_lower then return string.format("\nCannot create new player called '%s'. ".. "Another account called '%s' is already registered. ".. "Please check the spelling if it's your account ".. "or use a different nickname.", name, k) end end end)