update 5.0 minetest engine
|
@ -1,2 +0,0 @@
|
|||
# BlockColor
|
||||
BlockColor is a creative sandbox with only 8 colors. Only a limit : Your Imagination. (Made with Minetest Engine)
|
After Width: | Height: | Size: 898 KiB |
After Width: | Height: | Size: 514 KiB |
|
@ -1,7 +1,7 @@
|
|||
-- Minetest: builtin/client/chatcommands.lua
|
||||
|
||||
|
||||
core.register_on_sending_chat_messages(function(message)
|
||||
core.register_on_sending_chat_message(function(message)
|
||||
if message:sub(1,2) == ".." then
|
||||
return false
|
||||
end
|
||||
|
@ -40,8 +40,13 @@ end)
|
|||
core.register_chatcommand("list_players", {
|
||||
description = core.gettext("List online players"),
|
||||
func = function(param)
|
||||
local players = table.concat(core.get_player_names(), ", ")
|
||||
core.display_chat_message(core.gettext("Online players: ") .. players)
|
||||
local player_names = core.get_player_names()
|
||||
if not player_names then
|
||||
return false, core.gettext("This command is disabled by server.")
|
||||
end
|
||||
|
||||
local players = table.concat(player_names, ", ")
|
||||
return true, core.gettext("Online players: ") .. players
|
||||
end
|
||||
})
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
-- CSM death formspec. Only used when clientside modding is enabled, otherwise
|
||||
-- handled by the engine.
|
||||
|
||||
core.register_on_death(function()
|
||||
core.display_chat_message("You died.")
|
||||
local formspec = "size[11,5.5]bgcolor[#320000b4;true]" ..
|
||||
"label[4.85,1.35;" .. fgettext("You died") ..
|
||||
"]button_exit[4,3;3,0.5;btn_respawn;".. fgettext("Respawn") .."]"
|
||||
core.show_formspec("bultin:death", formspec)
|
||||
end)
|
||||
|
||||
core.register_on_formspec_input(function(formname, fields)
|
||||
if formname == "bultin:death" then
|
||||
core.send_respawn()
|
||||
end
|
||||
end)
|
|
@ -1,5 +1,5 @@
|
|||
-- Minetest: builtin/client/init.lua
|
||||
local scriptpath = core.get_builtin_path()..DIR_DELIM
|
||||
local scriptpath = core.get_builtin_path()
|
||||
local clientpath = scriptpath.."client"..DIR_DELIM
|
||||
local commonpath = scriptpath.."common"..DIR_DELIM
|
||||
|
||||
|
@ -8,16 +8,4 @@ dofile(commonpath .. "after.lua")
|
|||
dofile(commonpath .. "chatcommands.lua")
|
||||
dofile(clientpath .. "chatcommands.lua")
|
||||
dofile(commonpath .. "vector.lua")
|
||||
|
||||
core.register_on_death(function()
|
||||
core.display_chat_message("You died.")
|
||||
local formspec = "size[11,5.5]bgcolor[#320000b4;true]" ..
|
||||
"label[4.85,1.35;" .. fgettext("You died.") .. "]button_exit[4,3;3,0.5;btn_respawn;".. fgettext("Respawn") .."]"
|
||||
core.show_formspec("bultin:death", formspec)
|
||||
end)
|
||||
|
||||
core.register_on_formspec_input(function(formname, fields)
|
||||
if formname == "bultin:death" then
|
||||
core.send_respawn()
|
||||
end
|
||||
end)
|
||||
dofile(clientpath .. "death_formspec.lua")
|
||||
|
|
|
@ -59,10 +59,10 @@ local function make_registration()
|
|||
end
|
||||
|
||||
core.registered_globalsteps, core.register_globalstep = make_registration()
|
||||
core.registered_on_mods_loaded, core.register_on_mods_loaded = make_registration()
|
||||
core.registered_on_shutdown, core.register_on_shutdown = make_registration()
|
||||
core.registered_on_connect, core.register_on_connect = make_registration()
|
||||
core.registered_on_receiving_chat_messages, core.register_on_receiving_chat_messages = make_registration()
|
||||
core.registered_on_sending_chat_messages, core.register_on_sending_chat_messages = make_registration()
|
||||
core.registered_on_receiving_chat_message, core.register_on_receiving_chat_message = make_registration()
|
||||
core.registered_on_sending_chat_message, core.register_on_sending_chat_message = make_registration()
|
||||
core.registered_on_death, core.register_on_death = make_registration()
|
||||
core.registered_on_hp_modification, core.register_on_hp_modification = make_registration()
|
||||
core.registered_on_damage_taken, core.register_on_damage_taken = make_registration()
|
||||
|
@ -71,3 +71,6 @@ core.registered_on_dignode, core.register_on_dignode = make_registration()
|
|||
core.registered_on_punchnode, core.register_on_punchnode = make_registration()
|
||||
core.registered_on_placenode, core.register_on_placenode = make_registration()
|
||||
core.registered_on_item_use, core.register_on_item_use = make_registration()
|
||||
core.registered_on_modchannel_message, core.register_on_modchannel_message = make_registration()
|
||||
core.registered_on_modchannel_signal, core.register_on_modchannel_signal = make_registration()
|
||||
core.registered_on_inventory_open, core.register_on_inventory_open = make_registration()
|
||||
|
|
|
@ -97,7 +97,7 @@ end
|
|||
|
||||
if INIT == "client" then
|
||||
core.register_chatcommand("help", {
|
||||
params = gettext("[all/<cmd>]"),
|
||||
params = gettext("[all | <cmd>]"),
|
||||
description = gettext("Get help for commands"),
|
||||
func = function(param)
|
||||
return do_help_cmd(nil, param)
|
||||
|
@ -105,7 +105,7 @@ if INIT == "client" then
|
|||
})
|
||||
else
|
||||
core.register_chatcommand("help", {
|
||||
params = "[all/privs/<cmd>]",
|
||||
params = "[all | privs | <cmd>]",
|
||||
description = "Get help for commands or list privileges",
|
||||
func = do_help_cmd,
|
||||
})
|
||||
|
|
|
@ -47,17 +47,17 @@ function filterlist.create(raw_fct,compare_fct,uid_match_fct,filter_fct,fetch_pa
|
|||
|
||||
assert((raw_fct ~= nil) and (type(raw_fct) == "function"))
|
||||
assert((compare_fct ~= nil) and (type(compare_fct) == "function"))
|
||||
|
||||
|
||||
local self = {}
|
||||
|
||||
|
||||
self.m_raw_list_fct = raw_fct
|
||||
self.m_compare_fct = compare_fct
|
||||
self.m_filter_fct = filter_fct
|
||||
self.m_uid_match_fct = uid_match_fct
|
||||
|
||||
|
||||
self.m_filtercriteria = nil
|
||||
self.m_fetch_param = fetch_param
|
||||
|
||||
|
||||
self.m_sortmode = "none"
|
||||
self.m_sort_list = {}
|
||||
|
||||
|
@ -79,7 +79,7 @@ function filterlist.create(raw_fct,compare_fct,uid_match_fct,filter_fct,fetch_pa
|
|||
self.refresh = filterlist.refresh
|
||||
|
||||
filterlist.process(self)
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
@ -128,49 +128,49 @@ function filterlist.get_raw_element(self,idx)
|
|||
if type(idx) ~= "number" then
|
||||
idx = tonumber(idx)
|
||||
end
|
||||
|
||||
|
||||
if idx ~= nil and idx > 0 and idx <= #self.m_raw_list then
|
||||
return self.m_raw_list[idx]
|
||||
end
|
||||
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function filterlist.get_raw_index(self,listindex)
|
||||
assert(self.m_processed_list ~= nil)
|
||||
|
||||
|
||||
if listindex ~= nil and listindex > 0 and
|
||||
listindex <= #self.m_processed_list then
|
||||
local entry = self.m_processed_list[listindex]
|
||||
|
||||
|
||||
for i,v in ipairs(self.m_raw_list) do
|
||||
|
||||
|
||||
if self.m_compare_fct(v,entry) then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function filterlist.get_current_index(self,listindex)
|
||||
assert(self.m_processed_list ~= nil)
|
||||
|
||||
|
||||
if listindex ~= nil and listindex > 0 and
|
||||
listindex <= #self.m_raw_list then
|
||||
local entry = self.m_raw_list[listindex]
|
||||
|
||||
|
||||
for i,v in ipairs(self.m_processed_list) do
|
||||
|
||||
|
||||
if self.m_compare_fct(v,entry) then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
|
@ -183,23 +183,23 @@ function filterlist.process(self)
|
|||
self.m_processed_list = self.m_raw_list
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
self.m_processed_list = {}
|
||||
|
||||
|
||||
for k,v in pairs(self.m_raw_list) do
|
||||
if self.m_filtercriteria == nil or
|
||||
self.m_filter_fct(v,self.m_filtercriteria) then
|
||||
self.m_processed_list[#self.m_processed_list + 1] = v
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if self.m_sortmode == "none" then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if self.m_sort_list[self.m_sortmode] ~= nil and
|
||||
type(self.m_sort_list[self.m_sortmode]) == "function" then
|
||||
|
||||
|
||||
self.m_sort_list[self.m_sortmode](self)
|
||||
end
|
||||
end
|
||||
|
@ -209,7 +209,7 @@ function filterlist.size(self)
|
|||
if self.m_processed_list == nil then
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
return #self.m_processed_list
|
||||
end
|
||||
|
||||
|
@ -233,8 +233,8 @@ function filterlist.raw_index_by_uid(self, uid)
|
|||
elementidx = i
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- If there are more elements than one with same name uid can't decide which
|
||||
-- one is meant. self shouldn't be possible but just for sure.
|
||||
if elementcount > 1 then
|
||||
|
@ -254,11 +254,11 @@ function compare_worlds(world1,world2)
|
|||
if world1.path ~= world2.path then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
if world1.name ~= world2.name then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
if world1.gameid ~= world2.gameid then
|
||||
return false
|
||||
end
|
||||
|
@ -288,11 +288,11 @@ function sort_mod_list(self)
|
|||
|
||||
table.sort(self.m_processed_list, function(a, b)
|
||||
-- Show game mods at bottom
|
||||
if a.typ ~= b.typ then
|
||||
if b.typ == "game" then
|
||||
return a.typ ~= "game_mod"
|
||||
if a.type ~= b.type or a.loc ~= b.loc then
|
||||
if b.type == "game" then
|
||||
return a.loc ~= "game"
|
||||
end
|
||||
return b.typ == "game_mod"
|
||||
return b.loc == "game"
|
||||
end
|
||||
-- If in same or no modpack, sort by name
|
||||
if a.modpack == b.modpack then
|
||||
|
@ -308,7 +308,7 @@ function sort_mod_list(self)
|
|||
elseif b.name == a.modpack then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
local name_a = a.modpack or a.name
|
||||
local name_b = b.modpack or b.name
|
||||
if name_a:lower() == name_b:lower() then
|
||||
|
|
|
@ -166,9 +166,9 @@ end
|
|||
--------------------------------------------------------------------------------
|
||||
function string.split(str, delim, include_empty, max_splits, sep_is_pattern)
|
||||
delim = delim or ","
|
||||
max_splits = max_splits or -1
|
||||
max_splits = max_splits or -2
|
||||
local items = {}
|
||||
local pos, len, seplen = 1, #str, #delim
|
||||
local pos, len = 1, #str
|
||||
local plain = not sep_is_pattern
|
||||
max_splits = max_splits + 1
|
||||
repeat
|
||||
|
@ -382,7 +382,7 @@ if INIT == "game" then
|
|||
param2 = dirs1[fdir + 1]
|
||||
elseif isceiling then
|
||||
if orient_flags.force_facedir then
|
||||
cparam2 = 20
|
||||
param2 = 20
|
||||
else
|
||||
param2 = dirs2[fdir + 1]
|
||||
end
|
||||
|
@ -462,6 +462,12 @@ function core.explode_scrollbar_event(evt)
|
|||
return retval
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function core.rgba(r, g, b, a)
|
||||
return a and string.format("#%02X%02X%02X%02X", r, g, b, a) or
|
||||
string.format("#%02X%02X%02X", r, g, b)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function core.pos_to_string(pos, decimal_places)
|
||||
local x = pos.x
|
||||
|
@ -489,7 +495,7 @@ function core.string_to_pos(value)
|
|||
p.z = tonumber(p.z)
|
||||
return p
|
||||
end
|
||||
local p = {}
|
||||
p = {}
|
||||
p.x, p.y, p.z = string.match(value, "^%( *([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) *%)$")
|
||||
if p.x and p.y and p.z then
|
||||
p.x = tonumber(p.x)
|
||||
|
@ -545,12 +551,22 @@ function table.copy(t, seen)
|
|||
end
|
||||
return n
|
||||
end
|
||||
|
||||
|
||||
function table.insert_all(t, other)
|
||||
for i=1, #other do
|
||||
t[#t + 1] = other[i]
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- mainmenu only functions
|
||||
--------------------------------------------------------------------------------
|
||||
if INIT == "mainmenu" then
|
||||
function core.get_game(index)
|
||||
local games = game.get_games()
|
||||
local games = core.get_games()
|
||||
|
||||
if index > 0 and index <= #games then
|
||||
return games[index]
|
||||
|
@ -625,10 +641,57 @@ function core.strip_colors(str)
|
|||
return (str:gsub(ESCAPE_CHAR .. "%([bc]@[^)]+%)", ""))
|
||||
end
|
||||
|
||||
function core.translate(textdomain, str, ...)
|
||||
local start_seq
|
||||
if textdomain == "" then
|
||||
start_seq = ESCAPE_CHAR .. "T"
|
||||
else
|
||||
start_seq = ESCAPE_CHAR .. "(T@" .. textdomain .. ")"
|
||||
end
|
||||
local arg = {n=select('#', ...), ...}
|
||||
local end_seq = ESCAPE_CHAR .. "E"
|
||||
local arg_index = 1
|
||||
local translated = str:gsub("@(.)", function(matched)
|
||||
local c = string.byte(matched)
|
||||
if string.byte("1") <= c and c <= string.byte("9") then
|
||||
local a = c - string.byte("0")
|
||||
if a ~= arg_index then
|
||||
error("Escape sequences in string given to core.translate " ..
|
||||
"are not in the correct order: got @" .. matched ..
|
||||
"but expected @" .. tostring(arg_index))
|
||||
end
|
||||
if a > arg.n then
|
||||
error("Not enough arguments provided to core.translate")
|
||||
end
|
||||
arg_index = arg_index + 1
|
||||
return ESCAPE_CHAR .. "F" .. arg[a] .. ESCAPE_CHAR .. "E"
|
||||
elseif matched == "n" then
|
||||
return "\n"
|
||||
else
|
||||
return matched
|
||||
end
|
||||
end)
|
||||
if arg_index < arg.n + 1 then
|
||||
error("Too many arguments provided to core.translate")
|
||||
end
|
||||
return start_seq .. translated .. end_seq
|
||||
end
|
||||
|
||||
function core.get_translator(textdomain)
|
||||
return function(str, ...) return core.translate(textdomain or "", str, ...) end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Returns the exact coordinate of a pointed surface
|
||||
--------------------------------------------------------------------------------
|
||||
function core.pointed_thing_to_face_pos(placer, pointed_thing)
|
||||
-- Avoid crash in some situations when player is inside a node, causing
|
||||
-- 'above' to equal 'under'.
|
||||
if vector.equals(pointed_thing.above, pointed_thing.under) then
|
||||
return pointed_thing.under
|
||||
end
|
||||
|
||||
local eye_height = placer:get_properties().eye_height
|
||||
local eye_offset_first = placer:get_eye_offset()
|
||||
local node_pos = pointed_thing.under
|
||||
local camera_pos = placer:get_pos()
|
||||
|
@ -648,7 +711,7 @@ function core.pointed_thing_to_face_pos(placer, pointed_thing)
|
|||
end
|
||||
|
||||
local fine_pos = {[nc] = node_pos[nc] + offset}
|
||||
camera_pos.y = camera_pos.y + 1.625 + eye_offset_first.y / 10
|
||||
camera_pos.y = camera_pos.y + eye_height + eye_offset_first.y / 10
|
||||
local f = (node_pos[nc] + offset - camera_pos[nc]) / look_dir[nc]
|
||||
|
||||
for i = 1, #oc do
|
||||
|
@ -656,3 +719,28 @@ function core.pointed_thing_to_face_pos(placer, pointed_thing)
|
|||
end
|
||||
return fine_pos
|
||||
end
|
||||
|
||||
function core.string_to_privs(str, delim)
|
||||
assert(type(str) == "string")
|
||||
delim = delim or ','
|
||||
local privs = {}
|
||||
for _, priv in pairs(string.split(str, delim)) do
|
||||
privs[priv:trim()] = true
|
||||
end
|
||||
return privs
|
||||
end
|
||||
|
||||
function core.privs_to_string(privs, delim)
|
||||
assert(type(privs) == "table")
|
||||
delim = delim or ','
|
||||
local list = {}
|
||||
for priv, bool in pairs(privs) do
|
||||
if bool then
|
||||
list[#list + 1] = priv
|
||||
end
|
||||
end
|
||||
return table.concat(list, delim)
|
||||
end
|
||||
|
||||
assert(core.string_to_privs("a,b").b == true)
|
||||
assert(core.privs_to_string({a=true,b=true}) == "a,b")
|
||||
|
|
|
@ -63,34 +63,13 @@ function vector.distance(a, b)
|
|||
end
|
||||
|
||||
function vector.direction(pos1, pos2)
|
||||
local x_raw = pos2.x - pos1.x
|
||||
local y_raw = pos2.y - pos1.y
|
||||
local z_raw = pos2.z - pos1.z
|
||||
local x_abs = math.abs(x_raw)
|
||||
local y_abs = math.abs(y_raw)
|
||||
local z_abs = math.abs(z_raw)
|
||||
if x_abs >= y_abs and
|
||||
x_abs >= z_abs then
|
||||
y_raw = y_raw * (1 / x_abs)
|
||||
z_raw = z_raw * (1 / x_abs)
|
||||
x_raw = x_raw / x_abs
|
||||
end
|
||||
if y_abs >= x_abs and
|
||||
y_abs >= z_abs then
|
||||
x_raw = x_raw * (1 / y_abs)
|
||||
z_raw = z_raw * (1 / y_abs)
|
||||
y_raw = y_raw / y_abs
|
||||
end
|
||||
if z_abs >= y_abs and
|
||||
z_abs >= x_abs then
|
||||
x_raw = x_raw * (1 / z_abs)
|
||||
y_raw = y_raw * (1 / z_abs)
|
||||
z_raw = z_raw / z_abs
|
||||
end
|
||||
return {x=x_raw, y=y_raw, z=z_raw}
|
||||
return vector.normalize({
|
||||
x = pos2.x - pos1.x,
|
||||
y = pos2.y - pos1.y,
|
||||
z = pos2.z - pos1.z
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
function vector.add(a, b)
|
||||
if type(b) == "table" then
|
||||
return {x = a.x + b.x,
|
||||
|
|
|
@ -1,100 +1,25 @@
|
|||
-- Minetest: builtin/auth.lua
|
||||
|
||||
--
|
||||
-- Authentication handler
|
||||
-- Builtin authentication handler
|
||||
--
|
||||
|
||||
function core.string_to_privs(str, delim)
|
||||
assert(type(str) == "string")
|
||||
delim = delim or ','
|
||||
local privs = {}
|
||||
for _, priv in pairs(string.split(str, delim)) do
|
||||
privs[priv:trim()] = true
|
||||
end
|
||||
return privs
|
||||
end
|
||||
|
||||
function core.privs_to_string(privs, delim)
|
||||
assert(type(privs) == "table")
|
||||
delim = delim or ','
|
||||
local list = {}
|
||||
for priv, bool in pairs(privs) do
|
||||
if bool then
|
||||
list[#list + 1] = priv
|
||||
end
|
||||
end
|
||||
return table.concat(list, delim)
|
||||
end
|
||||
|
||||
assert(core.string_to_privs("a,b").b == true)
|
||||
assert(core.privs_to_string({a=true,b=true}) == "a,b")
|
||||
|
||||
core.auth_file_path = core.get_worldpath().."/auth.txt"
|
||||
core.auth_table = {}
|
||||
|
||||
local function read_auth_file()
|
||||
local newtable = {}
|
||||
local file, errmsg = io.open(core.auth_file_path, 'rb')
|
||||
if not file then
|
||||
core.log("info", core.auth_file_path.." could not be opened for reading ("..errmsg.."); assuming new world")
|
||||
return
|
||||
end
|
||||
for line in file:lines() do
|
||||
if line ~= "" then
|
||||
local fields = line:split(":", true)
|
||||
local name, password, privilege_string, last_login = unpack(fields)
|
||||
last_login = tonumber(last_login)
|
||||
if not (name and password and privilege_string) then
|
||||
error("Invalid line in auth.txt: "..dump(line))
|
||||
end
|
||||
local privileges = core.string_to_privs(privilege_string)
|
||||
newtable[name] = {password=password, privileges=privileges, last_login=last_login}
|
||||
end
|
||||
end
|
||||
io.close(file)
|
||||
core.auth_table = newtable
|
||||
core.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 content = {}
|
||||
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 ""}
|
||||
content[#content + 1] = table.concat(parts, ":")
|
||||
end
|
||||
if not core.safe_file_write(core.auth_file_path, table.concat(content, "\n")) then
|
||||
error(core.auth_file_path.." could not be written to")
|
||||
end
|
||||
end
|
||||
|
||||
read_auth_file()
|
||||
-- Make the auth object private, deny access to mods
|
||||
local core_auth = core.auth
|
||||
core.auth = nil
|
||||
|
||||
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
|
||||
local auth_entry = core_auth.read(name)
|
||||
-- If no such auth found, return nil
|
||||
if not auth_entry 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
|
||||
for priv, _ in pairs(auth_entry.privileges) do
|
||||
privileges[priv] = true
|
||||
end
|
||||
-- If singleplayer, give all privileges except those marked as give_to_singleplayer = false
|
||||
|
@ -107,63 +32,125 @@ core.builtin_auth_handler = {
|
|||
-- For the admin, give everything
|
||||
elseif name == core.settings:get("name") then
|
||||
for priv, def in pairs(core.registered_privileges) do
|
||||
privileges[priv] = true
|
||||
if def.give_to_admin then
|
||||
privileges[priv] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
-- All done
|
||||
return {
|
||||
password = core.auth_table[name].password,
|
||||
password = auth_entry.password,
|
||||
privileges = privileges,
|
||||
-- Is set to nil if unknown
|
||||
last_login = core.auth_table[name].last_login,
|
||||
last_login = auth_entry.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] = {
|
||||
return core_auth.create({
|
||||
name = name,
|
||||
password = password,
|
||||
privileges = core.string_to_privs(core.settings:get("default_privs")),
|
||||
last_login = os.time(),
|
||||
}
|
||||
save_auth_file()
|
||||
})
|
||||
end,
|
||||
delete_auth = function(name)
|
||||
assert(type(name) == "string")
|
||||
local auth_entry = core_auth.read(name)
|
||||
if not auth_entry then
|
||||
return false
|
||||
end
|
||||
core.log('info', "Built-in authentication handler deleting player '"..name.."'")
|
||||
return core_auth.delete(name)
|
||||
end,
|
||||
set_password = function(name, password)
|
||||
assert(type(name) == "string")
|
||||
assert(type(password) == "string")
|
||||
if not core.auth_table[name] then
|
||||
local auth_entry = core_auth.read(name)
|
||||
if not auth_entry 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()
|
||||
auth_entry.password = password
|
||||
core_auth.save(auth_entry)
|
||||
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,
|
||||
local auth_entry = core_auth.read(name)
|
||||
if not auth_entry then
|
||||
auth_entry = core.builtin_auth_handler.create_auth(name,
|
||||
core.get_password_hash(name,
|
||||
core.settings:get("default_password")))
|
||||
end
|
||||
core.auth_table[name].privileges = privileges
|
||||
|
||||
-- Run grant callbacks
|
||||
for priv, _ in pairs(privileges) do
|
||||
if not auth_entry.privileges[priv] then
|
||||
core.run_priv_callbacks(name, priv, nil, "grant")
|
||||
end
|
||||
end
|
||||
|
||||
-- Run revoke callbacks
|
||||
for priv, _ in pairs(auth_entry.privileges) do
|
||||
if not privileges[priv] then
|
||||
core.run_priv_callbacks(name, priv, nil, "revoke")
|
||||
end
|
||||
end
|
||||
|
||||
auth_entry.privileges = privileges
|
||||
core_auth.save(auth_entry)
|
||||
core.notify_authentication_modified(name)
|
||||
save_auth_file()
|
||||
end,
|
||||
reload = function()
|
||||
read_auth_file()
|
||||
core_auth.reload()
|
||||
return true
|
||||
end,
|
||||
record_login = function(name)
|
||||
assert(type(name) == "string")
|
||||
assert(core.auth_table[name]).last_login = os.time()
|
||||
save_auth_file()
|
||||
local auth_entry = core_auth.read(name)
|
||||
assert(auth_entry)
|
||||
auth_entry.last_login = os.time()
|
||||
core_auth.save(auth_entry)
|
||||
end,
|
||||
iterate = function()
|
||||
local names = {}
|
||||
local nameslist = core_auth.list_names()
|
||||
for k,v in pairs(nameslist) do
|
||||
names[v] = true
|
||||
end
|
||||
return pairs(names)
|
||||
end,
|
||||
}
|
||||
|
||||
core.register_on_prejoinplayer(function(name, ip)
|
||||
if core.registered_auth_handler ~= nil then
|
||||
return -- Don't do anything if custom auth handler registered
|
||||
end
|
||||
local auth_entry = core_auth.read(name)
|
||||
if auth_entry ~= nil then
|
||||
return
|
||||
end
|
||||
|
||||
local name_lower = name:lower()
|
||||
for k in core.builtin_auth_handler.iterate() 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)
|
||||
|
||||
--
|
||||
-- Authentication API
|
||||
--
|
||||
|
||||
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)
|
||||
|
@ -189,28 +176,10 @@ end
|
|||
|
||||
core.set_player_password = auth_pass("set_password")
|
||||
core.set_player_privs = auth_pass("set_privileges")
|
||||
core.remove_player_auth = auth_pass("delete_auth")
|
||||
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)
|
||||
|
|
|
@ -41,7 +41,7 @@ end)
|
|||
|
||||
if core.settings:get_bool("profiler.load") then
|
||||
-- Run after register_chatcommand and its register_on_chat_message
|
||||
-- Before any chattcommands that should be profiled
|
||||
-- Before any chatcommands that should be profiled
|
||||
profiler.init_chatcommand()
|
||||
end
|
||||
|
||||
|
@ -71,7 +71,7 @@ end
|
|||
--
|
||||
core.register_chatcommand("me", {
|
||||
params = "<action>",
|
||||
description = "Display chat action (e.g., '/me orders a pizza' displays"
|
||||
description = "Show chat action (e.g., '/me orders a pizza' displays"
|
||||
.. " '<player name> orders a pizza')",
|
||||
privs = {shout=true},
|
||||
func = function(name, param)
|
||||
|
@ -82,9 +82,9 @@ core.register_chatcommand("me", {
|
|||
core.register_chatcommand("admin", {
|
||||
description = "Show the name of the server owner",
|
||||
func = function(name)
|
||||
local admin = minetest.settings:get("name")
|
||||
local admin = core.settings:get("name")
|
||||
if admin then
|
||||
return true, "The administrator of this server is "..admin.."."
|
||||
return true, "The administrator of this server is " .. admin .. "."
|
||||
else
|
||||
return false, "There's no administrator named in the config file."
|
||||
end
|
||||
|
@ -92,19 +92,47 @@ core.register_chatcommand("admin", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("privs", {
|
||||
params = "<name>",
|
||||
description = "Print privileges of player",
|
||||
params = "[<name>]",
|
||||
description = "Show privileges of yourself or another player",
|
||||
func = function(caller, param)
|
||||
param = param:trim()
|
||||
local name = (param ~= "" and param or caller)
|
||||
if not core.player_exists(name) then
|
||||
return false, "Player " .. name .. " does not exist."
|
||||
end
|
||||
return true, "Privileges of " .. name .. ": "
|
||||
.. core.privs_to_string(
|
||||
core.get_player_privs(name), ' ')
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("haspriv", {
|
||||
params = "<privilege>",
|
||||
description = "Return list of all online players with privilege.",
|
||||
privs = {basic_privs = true},
|
||||
func = function(caller, param)
|
||||
param = param:trim()
|
||||
if param == "" then
|
||||
return false, "Invalid parameters (see /help haspriv)"
|
||||
end
|
||||
if not core.registered_privileges[param] then
|
||||
return false, "Unknown privilege!"
|
||||
end
|
||||
local privs = core.string_to_privs(param)
|
||||
local players_with_priv = {}
|
||||
for _, player in pairs(core.get_connected_players()) do
|
||||
local player_name = player:get_player_name()
|
||||
if core.check_player_privs(player_name, privs) then
|
||||
table.insert(players_with_priv, player_name)
|
||||
end
|
||||
end
|
||||
return true, "Players online with the \"" .. param .. "\" privilege: " ..
|
||||
table.concat(players_with_priv, ", ")
|
||||
end
|
||||
})
|
||||
|
||||
local function handle_grant_command(caller, grantname, grantprivstr)
|
||||
local caller_privs = minetest.get_player_privs(caller)
|
||||
local caller_privs = core.get_player_privs(caller)
|
||||
if not (caller_privs.privs or caller_privs.basic_privs) then
|
||||
return false, "Your privileges are insufficient."
|
||||
end
|
||||
|
@ -132,6 +160,9 @@ local function handle_grant_command(caller, grantname, grantprivstr)
|
|||
if privs_unknown ~= "" then
|
||||
return false, privs_unknown
|
||||
end
|
||||
for priv, _ in pairs(grantprivs) do
|
||||
core.run_priv_callbacks(grantname, priv, caller, "grant")
|
||||
end
|
||||
core.set_player_privs(grantname, privs)
|
||||
core.log("action", caller..' granted ('..core.privs_to_string(grantprivs, ', ')..') privileges to '..grantname)
|
||||
if grantname ~= caller then
|
||||
|
@ -145,8 +176,8 @@ local function handle_grant_command(caller, grantname, grantprivstr)
|
|||
end
|
||||
|
||||
core.register_chatcommand("grant", {
|
||||
params = "<name> <privilege>|all",
|
||||
description = "Give privilege to player",
|
||||
params = "<name> (<privilege> | all)",
|
||||
description = "Give privileges to player",
|
||||
func = function(name, param)
|
||||
local grantname, grantprivstr = string.match(param, "([^ ]+) (.+)")
|
||||
if not grantname or not grantprivstr then
|
||||
|
@ -157,7 +188,7 @@ core.register_chatcommand("grant", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("grantme", {
|
||||
params = "<privilege>|all",
|
||||
params = "<privilege> | all",
|
||||
description = "Grant privileges to yourself",
|
||||
func = function(name, param)
|
||||
if param == "" then
|
||||
|
@ -168,8 +199,8 @@ core.register_chatcommand("grantme", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("revoke", {
|
||||
params = "<name> <privilege>|all",
|
||||
description = "Remove privilege from player",
|
||||
params = "<name> (<privilege> | all)",
|
||||
description = "Remove privileges from player",
|
||||
privs = {},
|
||||
func = function(name, param)
|
||||
if not core.check_player_privs(name, {privs=true}) and
|
||||
|
@ -193,12 +224,18 @@ core.register_chatcommand("revoke", {
|
|||
end
|
||||
end
|
||||
if revoke_priv_str == "all" then
|
||||
revoke_privs = privs
|
||||
privs = {}
|
||||
else
|
||||
for priv, _ in pairs(revoke_privs) do
|
||||
privs[priv] = nil
|
||||
end
|
||||
end
|
||||
|
||||
for priv, _ in pairs(revoke_privs) do
|
||||
core.run_priv_callbacks(revoke_name, priv, name, "revoke")
|
||||
end
|
||||
|
||||
core.set_player_privs(revoke_name, privs)
|
||||
core.log("action", name..' revoked ('
|
||||
..core.privs_to_string(revoke_privs, ', ')
|
||||
|
@ -254,7 +291,7 @@ core.register_chatcommand("setpassword", {
|
|||
|
||||
core.register_chatcommand("clearpassword", {
|
||||
params = "<name>",
|
||||
description = "Set empty password",
|
||||
description = "Set empty password for a player",
|
||||
privs = {password=true},
|
||||
func = function(name, param)
|
||||
local toname = param
|
||||
|
@ -281,7 +318,7 @@ core.register_chatcommand("auth_reload", {
|
|||
|
||||
core.register_chatcommand("remove_player", {
|
||||
params = "<name>",
|
||||
description = "Remove player data",
|
||||
description = "Remove a player's data",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
local toname = param
|
||||
|
@ -305,8 +342,8 @@ core.register_chatcommand("remove_player", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("teleport", {
|
||||
params = "<X>,<Y>,<Z> | <to_name> | <name> <X>,<Y>,<Z> | <name> <to_name>",
|
||||
description = "Teleport to player or position",
|
||||
params = "<X>,<Y>,<Z> | <to_name> | (<name> <X>,<Y>,<Z>) | (<name> <to_name>)",
|
||||
description = "Teleport to position or player",
|
||||
privs = {teleport=true},
|
||||
func = function(name, param)
|
||||
-- Returns (pos, true) if found, otherwise (pos, false)
|
||||
|
@ -343,7 +380,7 @@ core.register_chatcommand("teleport", {
|
|||
end
|
||||
teleportee = core.get_player_by_name(name)
|
||||
if teleportee then
|
||||
teleportee:setpos(p)
|
||||
teleportee:set_pos(p)
|
||||
return true, "Teleporting to "..core.pos_to_string(p)
|
||||
end
|
||||
end
|
||||
|
@ -356,12 +393,12 @@ core.register_chatcommand("teleport", {
|
|||
if target_name then
|
||||
local target = core.get_player_by_name(target_name)
|
||||
if target then
|
||||
p = target:getpos()
|
||||
p = target:get_pos()
|
||||
end
|
||||
end
|
||||
if teleportee and p then
|
||||
p = find_free_position_near(p)
|
||||
teleportee:setpos(p)
|
||||
teleportee:set_pos(p)
|
||||
return true, "Teleporting to " .. target_name
|
||||
.. " at "..core.pos_to_string(p)
|
||||
end
|
||||
|
@ -380,7 +417,7 @@ core.register_chatcommand("teleport", {
|
|||
teleportee = core.get_player_by_name(teleportee_name)
|
||||
end
|
||||
if teleportee and p.x and p.y and p.z then
|
||||
teleportee:setpos(p)
|
||||
teleportee:set_pos(p)
|
||||
return true, "Teleporting " .. teleportee_name
|
||||
.. " to " .. core.pos_to_string(p)
|
||||
end
|
||||
|
@ -396,12 +433,12 @@ core.register_chatcommand("teleport", {
|
|||
if target_name then
|
||||
local target = core.get_player_by_name(target_name)
|
||||
if target then
|
||||
p = target:getpos()
|
||||
p = target:get_pos()
|
||||
end
|
||||
end
|
||||
if teleportee and p then
|
||||
p = find_free_position_near(p)
|
||||
teleportee:setpos(p)
|
||||
teleportee:set_pos(p)
|
||||
return true, "Teleporting " .. teleportee_name
|
||||
.. " to " .. target_name
|
||||
.. " at " .. core.pos_to_string(p)
|
||||
|
@ -413,7 +450,7 @@ core.register_chatcommand("teleport", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("set", {
|
||||
params = "[-n] <name> <value> | <name>",
|
||||
params = "([-n] <name> <value>) | <name>",
|
||||
description = "Set or read server configuration setting",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
|
@ -468,9 +505,9 @@ local function emergeblocks_progress_update(ctx)
|
|||
end
|
||||
|
||||
core.register_chatcommand("emergeblocks", {
|
||||
params = "(here [radius]) | (<pos1> <pos2>)",
|
||||
params = "(here [<radius>]) | (<pos1> <pos2>)",
|
||||
description = "Load (or, if nonexistent, generate) map blocks "
|
||||
.. "contained in area pos1 to pos2",
|
||||
.. "contained in area pos1 to pos2 (<pos1> and <pos2> must be in parentheses)",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
local p1, p2 = parse_range_str(name, param)
|
||||
|
@ -494,8 +531,9 @@ core.register_chatcommand("emergeblocks", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("deleteblocks", {
|
||||
params = "(here [radius]) | (<pos1> <pos2>)",
|
||||
description = "Delete map blocks contained in area pos1 to pos2",
|
||||
params = "(here [<radius>]) | (<pos1> <pos2>)",
|
||||
description = "Delete map blocks contained in area pos1 to pos2 "
|
||||
.. "(<pos1> and <pos2> must be in parentheses)",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
local p1, p2 = parse_range_str(name, param)
|
||||
|
@ -513,8 +551,9 @@ core.register_chatcommand("deleteblocks", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("fixlight", {
|
||||
params = "(here [radius]) | (<pos1> <pos2>)",
|
||||
description = "Resets lighting in the area between pos1 and pos2",
|
||||
params = "(here [<radius>]) | (<pos1> <pos2>)",
|
||||
description = "Resets lighting in the area between pos1 and pos2 "
|
||||
.. "(<pos1> and <pos2> must be in parentheses)",
|
||||
privs = {server = true},
|
||||
func = function(name, param)
|
||||
local p1, p2 = parse_range_str(name, param)
|
||||
|
@ -546,8 +585,11 @@ local function handle_give_command(cmd, giver, receiver, stackstring)
|
|||
local itemstack = ItemStack(stackstring)
|
||||
if itemstack:is_empty() then
|
||||
return false, "Cannot give an empty item"
|
||||
elseif not itemstack:is_known() then
|
||||
elseif (not itemstack:is_known()) or (itemstack:get_name() == "unknown") then
|
||||
return false, "Cannot give an unknown item"
|
||||
-- Forbid giving 'ignore' due to unwanted side effects
|
||||
elseif itemstack:get_name() == "ignore" then
|
||||
return false, "Giving 'ignore' is not allowed"
|
||||
end
|
||||
local receiverref = core.get_player_by_name(receiver)
|
||||
if receiverref == nil then
|
||||
|
@ -566,18 +608,18 @@ local function handle_give_command(cmd, giver, receiver, stackstring)
|
|||
-- entered (e.g. big numbers are always interpreted as 2^16-1).
|
||||
stackstring = itemstack:to_string()
|
||||
if giver == receiver then
|
||||
return true, ("%q %sadded to inventory.")
|
||||
:format(stackstring, partiality)
|
||||
local msg = "%q %sadded to inventory."
|
||||
return true, msg:format(stackstring, partiality)
|
||||
else
|
||||
core.chat_send_player(receiver, ("%q %sadded to inventory.")
|
||||
:format(stackstring, partiality))
|
||||
return true, ("%q %sadded to %s's inventory.")
|
||||
:format(stackstring, partiality, receiver)
|
||||
local msg = "%q %sadded to %s's inventory."
|
||||
return true, msg:format(stackstring, partiality, receiver)
|
||||
end
|
||||
end
|
||||
|
||||
core.register_chatcommand("give", {
|
||||
params = "<name> <ItemString>",
|
||||
params = "<name> <ItemString> [<count> [<wear>]]",
|
||||
description = "Give item to player",
|
||||
privs = {give=true},
|
||||
func = function(name, param)
|
||||
|
@ -590,7 +632,7 @@ core.register_chatcommand("give", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("giveme", {
|
||||
params = "<ItemString>",
|
||||
params = "<ItemString> [<count> [<wear>]]",
|
||||
description = "Give item to yourself",
|
||||
privs = {give=true},
|
||||
func = function(name, param)
|
||||
|
@ -618,8 +660,11 @@ core.register_chatcommand("spawnentity", {
|
|||
core.log("error", "Unable to spawn entity, player is nil")
|
||||
return false, "Unable to spawn entity, player is nil"
|
||||
end
|
||||
if not core.registered_entities[entityname] then
|
||||
return false, "Cannot spawn an unknown entity"
|
||||
end
|
||||
if p == "" then
|
||||
p = player:getpos()
|
||||
p = player:get_pos()
|
||||
else
|
||||
p = core.string_to_pos(p)
|
||||
if p == nil then
|
||||
|
@ -641,10 +686,13 @@ core.register_chatcommand("pulverize", {
|
|||
core.log("error", "Unable to pulverize, no player.")
|
||||
return false, "Unable to pulverize, no player."
|
||||
end
|
||||
if player:get_wielded_item():is_empty() then
|
||||
local wielded_item = player:get_wielded_item()
|
||||
if wielded_item:is_empty() then
|
||||
return false, "Unable to pulverize, no item in hand."
|
||||
end
|
||||
player:set_wielded_item(nil)
|
||||
core.log("action", name .. " pulverized \"" ..
|
||||
wielded_item:get_name() .. " " .. wielded_item:get_count() .. "\"")
|
||||
player:set_wielded_item(nil)
|
||||
return true, "An item was pulverized."
|
||||
end,
|
||||
})
|
||||
|
@ -661,7 +709,7 @@ core.register_on_punchnode(function(pos, node, puncher)
|
|||
end)
|
||||
|
||||
core.register_chatcommand("rollback_check", {
|
||||
params = "[<range>] [<seconds>] [limit]",
|
||||
params = "[<range>] [<seconds>] [<limit>]",
|
||||
description = "Check who last touched a node or a node near it"
|
||||
.. " within the time specified by <seconds>. Default: range = 0,"
|
||||
.. " seconds = 86400 = 24h, limit = 5",
|
||||
|
@ -714,7 +762,7 @@ core.register_chatcommand("rollback_check", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("rollback", {
|
||||
params = "<player name> [<seconds>] | :<actor> [<seconds>]",
|
||||
params = "(<name> [<seconds>]) | (:<actor> [<seconds>])",
|
||||
description = "Revert actions of a player. Default for <seconds> is 60",
|
||||
privs = {rollback=true},
|
||||
func = function(name, param)
|
||||
|
@ -752,15 +800,19 @@ core.register_chatcommand("rollback", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("status", {
|
||||
description = "Print server status",
|
||||
description = "Show server status",
|
||||
func = function(name, param)
|
||||
return true, core.get_server_status()
|
||||
local status = core.get_server_status(name, false)
|
||||
if status and status ~= "" then
|
||||
return true, status
|
||||
end
|
||||
return false, "This command was disabled by a mod or game"
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("time", {
|
||||
params = "<0..23>:<0..59> | <0..24000>",
|
||||
description = "Set time of day",
|
||||
params = "[<0..23>:<0..59> | <0..24000>]",
|
||||
description = "Show or set time of day",
|
||||
privs = {},
|
||||
func = function(name, param)
|
||||
if param == "" then
|
||||
|
@ -799,24 +851,26 @@ core.register_chatcommand("time", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("days", {
|
||||
description = "Display day count",
|
||||
description = "Show day count since world creation",
|
||||
func = function(name, param)
|
||||
return true, "Current day is " .. core.get_day_count()
|
||||
end
|
||||
})
|
||||
|
||||
core.register_chatcommand("shutdown", {
|
||||
description = "Shutdown server",
|
||||
params = "[delay_in_seconds (non-negative number, or -1 to cancel)] [reconnect] [message]",
|
||||
params = "[<delay_in_seconds> | -1] [reconnect] [<message>]",
|
||||
description = "Shutdown server (-1 cancels a delayed shutdown)",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
local delay, reconnect, message = param:match("([^ ][-]?[0-9]+)([^ ]+)(.*)")
|
||||
message = message or ""
|
||||
local delay, reconnect, message
|
||||
delay, param = param:match("^%s*(%S+)(.*)")
|
||||
if param then
|
||||
reconnect, param = param:match("^%s*(%S+)(.*)")
|
||||
end
|
||||
message = param and param:match("^%s*(.+)") or ""
|
||||
delay = tonumber(delay) or 0
|
||||
|
||||
if delay ~= "" then
|
||||
delay = tonumber(delay) or 0
|
||||
else
|
||||
delay = 0
|
||||
if delay == 0 then
|
||||
core.log("action", name .. " shuts down server")
|
||||
core.chat_send_all("*** Server shutting down (operator request).")
|
||||
end
|
||||
|
@ -825,12 +879,17 @@ core.register_chatcommand("shutdown", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("ban", {
|
||||
params = "<name>",
|
||||
description = "Ban IP of player",
|
||||
params = "[<name> | <IP_address>]",
|
||||
description = "Ban player or show ban list",
|
||||
privs = {ban=true},
|
||||
func = function(name, param)
|
||||
if param == "" then
|
||||
return true, "Ban list: " .. core.get_ban_list()
|
||||
local ban_list = core.get_ban_list()
|
||||
if ban_list == "" then
|
||||
return true, "The ban list is empty."
|
||||
else
|
||||
return true, "Ban list: " .. ban_list
|
||||
end
|
||||
end
|
||||
if not core.get_player_by_name(param) then
|
||||
return false, "No such player."
|
||||
|
@ -845,8 +904,8 @@ core.register_chatcommand("ban", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("unban", {
|
||||
params = "<name/ip>",
|
||||
description = "Remove IP ban",
|
||||
params = "<name> | <IP_address>",
|
||||
description = "Remove player ban",
|
||||
privs = {ban=true},
|
||||
func = function(name, param)
|
||||
if not core.unban_player_or_ip(param) then
|
||||
|
@ -858,7 +917,7 @@ core.register_chatcommand("unban", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("kick", {
|
||||
params = "<name> [reason]",
|
||||
params = "<name> [<reason>]",
|
||||
description = "Kick a player",
|
||||
privs = {kick=true},
|
||||
func = function(name, param)
|
||||
|
@ -877,15 +936,15 @@ core.register_chatcommand("kick", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("clearobjects", {
|
||||
params = "[full|quick]",
|
||||
params = "[full | quick]",
|
||||
description = "Clear all objects in world",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
local options = {}
|
||||
if param == "" or param == "full" then
|
||||
options.mode = "full"
|
||||
elseif param == "quick" then
|
||||
if param == "" or param == "quick" then
|
||||
options.mode = "quick"
|
||||
elseif param == "full" then
|
||||
options.mode = "full"
|
||||
else
|
||||
return false, "Invalid usage, see /help clearobjects."
|
||||
end
|
||||
|
@ -923,8 +982,8 @@ core.register_chatcommand("msg", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("last-login", {
|
||||
params = "[name]",
|
||||
description = "Get the last login time of a player",
|
||||
params = "[<name>]",
|
||||
description = "Get the last login time of a player or yourself",
|
||||
func = function(name, param)
|
||||
if param == "" then
|
||||
param = name
|
||||
|
@ -940,14 +999,14 @@ core.register_chatcommand("last-login", {
|
|||
})
|
||||
|
||||
core.register_chatcommand("clearinv", {
|
||||
params = "[name]",
|
||||
params = "[<name>]",
|
||||
description = "Clear the inventory of yourself or another player",
|
||||
func = function(name, param)
|
||||
local player
|
||||
if param and param ~= "" and param ~= name then
|
||||
if not core.check_player_privs(name, {server=true}) then
|
||||
return false, "You don't have permission"
|
||||
.. " to run this command (missing privilege: server)"
|
||||
.. " to clear another player's inventory (missing privilege: server)"
|
||||
end
|
||||
player = core.get_player_by_name(param)
|
||||
core.chat_send_player(param, name.." cleared your inventory.")
|
||||
|
@ -966,3 +1025,34 @@ core.register_chatcommand("clearinv", {
|
|||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local function handle_kill_command(killer, victim)
|
||||
if core.settings:get_bool("enable_damage") == false then
|
||||
return false, "Players can't be killed, damage has been disabled."
|
||||
end
|
||||
local victimref = core.get_player_by_name(victim)
|
||||
if victimref == nil then
|
||||
return false, string.format("Player %s is not online.", victim)
|
||||
elseif victimref:get_hp() <= 0 then
|
||||
if killer == victim then
|
||||
return false, "You are already dead."
|
||||
else
|
||||
return false, string.format("%s is already dead.", victim)
|
||||
end
|
||||
end
|
||||
if not killer == victim then
|
||||
core.log("action", string.format("%s killed %s", killer, victim))
|
||||
end
|
||||
-- Kill victim
|
||||
victimref:set_hp(0)
|
||||
return true, string.format("%s has been killed.", victim)
|
||||
end
|
||||
|
||||
core.register_chatcommand("kill", {
|
||||
params = "[<name>]",
|
||||
description = "Kill player or yourself",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
return handle_kill_command(name, param == "" and name or param)
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -21,6 +21,10 @@ core.EMERGE_GENERATED = 4
|
|||
-- constants.h
|
||||
-- Size of mapblocks in nodes
|
||||
core.MAP_BLOCKSIZE = 16
|
||||
-- Default maximal HP of a player
|
||||
core.PLAYER_MAX_HP_DEFAULT = 20
|
||||
-- Default maximal breath of a player
|
||||
core.PLAYER_MAX_BREATH_DEFAULT = 11
|
||||
|
||||
-- light.h
|
||||
-- Maximum value for node 'light_source' parameter
|
||||
|
|
|
@ -18,3 +18,7 @@ function core.create_detached_inventory(name, callbacks, player_name)
|
|||
return core.create_detached_inventory_raw(name, player_name)
|
||||
end
|
||||
|
||||
function core.remove_detached_inventory(name)
|
||||
core.detached_inventories[name] = nil
|
||||
return core.remove_detached_inventory_raw(name)
|
||||
end
|
||||
|
|
|
@ -39,7 +39,7 @@ core.register_entity(":__builtin:falling_node", {
|
|||
|
||||
on_activate = function(self, staticdata)
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
|
||||
|
||||
local ds = core.deserialize(staticdata)
|
||||
if ds and ds.node then
|
||||
self:set_node(ds.node, ds.meta)
|
||||
|
@ -52,12 +52,12 @@ core.register_entity(":__builtin:falling_node", {
|
|||
|
||||
on_step = function(self, dtime)
|
||||
-- Set gravity
|
||||
local acceleration = self.object:getacceleration()
|
||||
local acceleration = self.object:get_acceleration()
|
||||
if not vector.equals(acceleration, {x = 0, y = -10, z = 0}) then
|
||||
self.object:setacceleration({x = 0, y = -10, z = 0})
|
||||
self.object:set_acceleration({x = 0, y = -10, z = 0})
|
||||
end
|
||||
-- Turn to actual node when colliding with ground, or continue to move
|
||||
local pos = self.object:getpos()
|
||||
local pos = self.object:get_pos()
|
||||
-- Position of bottom center point
|
||||
local bcp = {x = pos.x, y = pos.y - 0.7, z = pos.z}
|
||||
-- 'bcn' is nil for unloaded nodes
|
||||
|
@ -109,30 +109,41 @@ core.register_entity(":__builtin:falling_node", {
|
|||
end
|
||||
end
|
||||
-- Create node and remove entity
|
||||
if core.registered_nodes[self.node.name] then
|
||||
local def = core.registered_nodes[self.node.name]
|
||||
if def then
|
||||
core.add_node(np, self.node)
|
||||
if self.meta then
|
||||
local meta = core.get_meta(np)
|
||||
meta:from_table(self.meta)
|
||||
end
|
||||
if def.sounds and def.sounds.place and def.sounds.place.name then
|
||||
core.sound_play(def.sounds.place, {pos = np})
|
||||
end
|
||||
end
|
||||
self.object:remove()
|
||||
core.check_for_falling(np)
|
||||
return
|
||||
end
|
||||
local vel = self.object:getvelocity()
|
||||
local vel = self.object:get_velocity()
|
||||
if vector.equals(vel, {x = 0, y = 0, z = 0}) then
|
||||
local npos = self.object:getpos()
|
||||
self.object:setpos(vector.round(npos))
|
||||
local npos = self.object:get_pos()
|
||||
self.object:set_pos(vector.round(npos))
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
local function spawn_falling_node(p, node, meta)
|
||||
local obj = core.add_entity(p, "__builtin:falling_node")
|
||||
if obj then
|
||||
obj:get_luaentity():set_node(node, meta)
|
||||
local function convert_to_falling_node(pos, node)
|
||||
local obj = core.add_entity(pos, "__builtin:falling_node")
|
||||
if not obj then
|
||||
return false
|
||||
end
|
||||
node.level = core.get_node_level(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local metatable = meta and meta:to_table() or {}
|
||||
|
||||
obj:get_luaentity():set_node(node, metatable)
|
||||
core.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
|
||||
function core.spawn_falling_node(pos)
|
||||
|
@ -140,19 +151,27 @@ function core.spawn_falling_node(pos)
|
|||
if node.name == "air" or node.name == "ignore" then
|
||||
return false
|
||||
end
|
||||
local obj = core.add_entity(pos, "__builtin:falling_node")
|
||||
if obj then
|
||||
obj:get_luaentity():set_node(node)
|
||||
core.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return convert_to_falling_node(pos, node)
|
||||
end
|
||||
|
||||
local function drop_attached_node(p)
|
||||
local n = core.get_node(p)
|
||||
local drops = core.get_node_drops(n, "")
|
||||
local def = core.registered_items[n.name]
|
||||
if def and def.preserve_metadata then
|
||||
local oldmeta = core.get_meta(p):to_table().fields
|
||||
-- Copy pos and node because the callback can modify them.
|
||||
local pos_copy = {x=p.x, y=p.y, z=p.z}
|
||||
local node_copy = {name=n.name, param1=n.param1, param2=n.param2}
|
||||
local drop_stacks = {}
|
||||
for k, v in pairs(drops) do
|
||||
drop_stacks[k] = ItemStack(v)
|
||||
end
|
||||
drops = drop_stacks
|
||||
def.preserve_metadata(pos_copy, node_copy, oldmeta, drops)
|
||||
end
|
||||
core.remove_node(p)
|
||||
for _, item in pairs(core.get_node_drops(n, "")) do
|
||||
for _, item in pairs(drops) do
|
||||
local pos = {
|
||||
x = p.x + math.random()/2 - 0.25,
|
||||
y = p.y + math.random()/2 - 0.25,
|
||||
|
@ -205,14 +224,7 @@ function core.check_single_for_falling(p)
|
|||
core.get_node_max_level(p_bottom))) and
|
||||
|
||||
(not d_bottom.walkable or d_bottom.buildable_to) then
|
||||
n.level = core.get_node_level(p)
|
||||
local meta = core.get_meta(p)
|
||||
local metatable = {}
|
||||
if meta ~= nil then
|
||||
metatable = meta:to_table()
|
||||
end
|
||||
core.remove_node(p)
|
||||
spawn_falling_node(p, n, metatable)
|
||||
convert_to_falling_node(p, n)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@ -313,19 +325,3 @@ local function on_punchnode(p, node)
|
|||
core.check_for_falling(p)
|
||||
end
|
||||
core.register_on_punchnode(on_punchnode)
|
||||
|
||||
--
|
||||
-- Globally exported functions
|
||||
--
|
||||
|
||||
-- TODO remove this function after the 0.4.15 release
|
||||
function nodeupdate(p)
|
||||
core.log("deprecated", "nodeupdate: deprecated, please use core.check_for_falling instead")
|
||||
core.check_for_falling(p)
|
||||
end
|
||||
|
||||
-- TODO remove this function after the 0.4.15 release
|
||||
function nodeupdate_single(p)
|
||||
core.log("deprecated", "nodeupdate_single: deprecated, please use core.check_single_for_falling instead")
|
||||
core.check_single_for_falling(p)
|
||||
end
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
core.features = {
|
||||
glasslike_framed = true,
|
||||
nodebox_as_selectionbox = true,
|
||||
chat_send_player_param3 = true,
|
||||
get_all_craft_recipes_works = true,
|
||||
use_texture_alpha = true,
|
||||
no_legacy_abms = true,
|
||||
|
@ -11,6 +10,8 @@ core.features = {
|
|||
area_store_custom_ids = true,
|
||||
add_entity_with_staticdata = true,
|
||||
no_chat_message_prediction = true,
|
||||
object_use_texture_alpha = true,
|
||||
object_independent_selectionbox = true,
|
||||
}
|
||||
|
||||
function core.has_feature(arg)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
local scriptpath = core.get_builtin_path()..DIR_DELIM
|
||||
local scriptpath = core.get_builtin_path()
|
||||
local commonpath = scriptpath.."common"..DIR_DELIM
|
||||
local gamepath = scriptpath.."game"..DIR_DELIM
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ function core.get_pointed_thing_position(pointed_thing, above)
|
|||
-- The position where a node would be dug
|
||||
return pointed_thing.under
|
||||
elseif pointed_thing.type == "object" then
|
||||
return pointed_thing.ref and pointed_thing.ref:getpos()
|
||||
return pointed_thing.ref and pointed_thing.ref:get_pos()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -197,7 +197,7 @@ function core.get_node_drops(node, toolname)
|
|||
return {nodename}
|
||||
elseif type(drop) == "string" then
|
||||
-- itemstring drop
|
||||
return {drop}
|
||||
return drop ~= "" and {drop} or {}
|
||||
elseif drop.items == nil then
|
||||
-- drop = {} to disable default drop
|
||||
return {}
|
||||
|
@ -331,7 +331,7 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
|
|||
-- Calculate the direction for furnaces and chests and stuff
|
||||
elseif (def.paramtype2 == "facedir" or
|
||||
def.paramtype2 == "colorfacedir") and not param2 then
|
||||
local placer_pos = placer and placer:getpos()
|
||||
local placer_pos = placer and placer:get_pos()
|
||||
if placer_pos then
|
||||
local dir = {
|
||||
x = above.x - placer_pos.x,
|
||||
|
@ -441,9 +441,6 @@ function core.item_drop(itemstack, dropper, pos)
|
|||
local cnt = itemstack:get_count()
|
||||
if dropper_is_player then
|
||||
p.y = p.y + 1.2
|
||||
if dropper:get_player_control().sneak then
|
||||
cnt = 1
|
||||
end
|
||||
end
|
||||
local item = itemstack:take_item(cnt)
|
||||
local obj = core.add_item(p, item)
|
||||
|
@ -472,6 +469,11 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed
|
|||
if itemstack:take_item() ~= nil then
|
||||
user:set_hp(user:get_hp() + hp_change)
|
||||
|
||||
local def = itemstack:get_definition()
|
||||
if def and def.sound and def.sound.eat then
|
||||
minetest.sound_play(def.sound.eat, { pos = user:get_pos(), max_hear_distance = 16 })
|
||||
end
|
||||
|
||||
if replace_with_item then
|
||||
if itemstack:is_empty() then
|
||||
itemstack:add_item(replace_with_item)
|
||||
|
@ -481,7 +483,7 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed
|
|||
if inv and inv:room_for_item("main", {name=replace_with_item}) then
|
||||
inv:add_item("main", replace_with_item)
|
||||
else
|
||||
local pos = user:getpos()
|
||||
local pos = user:get_pos()
|
||||
pos.y = math.floor(pos.y + 0.5)
|
||||
core.add_item(pos, replace_with_item)
|
||||
end
|
||||
|
@ -583,6 +585,20 @@ function core.node_dig(pos, node, digger)
|
|||
digger:set_wielded_item(wielded)
|
||||
end
|
||||
|
||||
-- Check to see if metadata should be preserved.
|
||||
if def and def.preserve_metadata then
|
||||
local oldmeta = core.get_meta(pos):to_table().fields
|
||||
-- Copy pos and node because the callback can modify them.
|
||||
local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
|
||||
local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
|
||||
local drop_stacks = {}
|
||||
for k, v in pairs(drops) do
|
||||
drop_stacks[k] = ItemStack(v)
|
||||
end
|
||||
drops = drop_stacks
|
||||
def.preserve_metadata(pos_copy, node_copy, oldmeta, drops)
|
||||
end
|
||||
|
||||
-- Handle drops
|
||||
core.handle_node_drops(pos, drops, digger)
|
||||
|
||||
|
@ -621,6 +637,18 @@ function core.node_dig(pos, node, digger)
|
|||
end
|
||||
end
|
||||
|
||||
function core.itemstring_with_palette(item, palette_index)
|
||||
local stack = ItemStack(item) -- convert to ItemStack
|
||||
stack:get_meta():set_int("palette_index", palette_index)
|
||||
return stack:to_string()
|
||||
end
|
||||
|
||||
function core.itemstring_with_color(item, colorstring)
|
||||
local stack = ItemStack(item) -- convert to ItemStack
|
||||
stack:get_meta():set_string("color", colorstring)
|
||||
return stack:to_string()
|
||||
end
|
||||
|
||||
-- This is used to allow mods to redefine core.item_place and so on
|
||||
-- NOTE: This is not the preferred way. Preferred way is to provide enough
|
||||
-- callbacks to not require redefining global functions. -celeron55
|
||||
|
|
|
@ -14,10 +14,9 @@ end
|
|||
-- If item_entity_ttl is not set, enity will have default life time
|
||||
-- Setting it to -1 disables the feature
|
||||
|
||||
local time_to_live = tonumber(core.settings:get("item_entity_ttl"))
|
||||
if not time_to_live then
|
||||
time_to_live = 900
|
||||
end
|
||||
local time_to_live = tonumber(core.settings:get("item_entity_ttl")) or 900
|
||||
local gravity = tonumber(core.settings:get("movement_gravity")) or 9.81
|
||||
|
||||
|
||||
core.register_entity(":__builtin:item", {
|
||||
initial_properties = {
|
||||
|
@ -33,50 +32,45 @@ core.register_entity(":__builtin:item", {
|
|||
is_visible = false,
|
||||
},
|
||||
|
||||
itemstring = '',
|
||||
physical_state = true,
|
||||
itemstring = "",
|
||||
moving_state = true,
|
||||
slippery_state = false,
|
||||
age = 0,
|
||||
|
||||
set_item = function(self, itemstring)
|
||||
self.itemstring = itemstring
|
||||
local stack = ItemStack(itemstring)
|
||||
local count = stack:get_count()
|
||||
local max_count = stack:get_stack_max()
|
||||
if count > max_count then
|
||||
count = max_count
|
||||
self.itemstring = stack:get_name().." "..max_count
|
||||
end
|
||||
local s = 0.2 + 0.1 * (count / max_count)
|
||||
local c = s
|
||||
local itemtable = stack:to_table()
|
||||
local itemname = nil
|
||||
if itemtable then
|
||||
itemname = stack:to_table().name
|
||||
set_item = function(self, item)
|
||||
local stack = ItemStack(item or self.itemstring)
|
||||
self.itemstring = stack:to_string()
|
||||
if self.itemstring == "" then
|
||||
-- item not yet known
|
||||
return
|
||||
end
|
||||
|
||||
-- Backwards compatibility: old clients use the texture
|
||||
-- to get the type of the item
|
||||
local item_texture = nil
|
||||
local item_type = ""
|
||||
if core.registered_items[itemname] then
|
||||
item_texture = core.registered_items[itemname].inventory_image
|
||||
item_type = core.registered_items[itemname].type
|
||||
end
|
||||
local prop = {
|
||||
local itemname = stack:is_known() and stack:get_name() or "unknown"
|
||||
|
||||
local max_count = stack:get_stack_max()
|
||||
local count = math.min(stack:get_count(), max_count)
|
||||
local size = 0.2 + 0.1 * (count / max_count) ^ (1 / 3)
|
||||
local coll_height = size * 0.75
|
||||
|
||||
self.object:set_properties({
|
||||
is_visible = true,
|
||||
visual = "wielditem",
|
||||
textures = {itemname},
|
||||
visual_size = {x = s, y = s},
|
||||
collisionbox = {-c, -c, -c, c, c, c},
|
||||
automatic_rotate = math.pi * 0.5,
|
||||
wield_item = itemstring,
|
||||
}
|
||||
self.object:set_properties(prop)
|
||||
visual_size = {x = size, y = size},
|
||||
collisionbox = {-size, -coll_height, -size,
|
||||
size, coll_height, size},
|
||||
selectionbox = {-size, -size, -size, size, size, size},
|
||||
automatic_rotate = math.pi * 0.5 * 0.2 / size,
|
||||
wield_item = self.itemstring,
|
||||
})
|
||||
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
return core.serialize({
|
||||
itemstring = self.itemstring,
|
||||
always_collect = self.always_collect,
|
||||
age = self.age,
|
||||
dropped_by = self.dropped_by
|
||||
})
|
||||
|
@ -87,93 +81,70 @@ core.register_entity(":__builtin:item", {
|
|||
local data = core.deserialize(staticdata)
|
||||
if data and type(data) == "table" then
|
||||
self.itemstring = data.itemstring
|
||||
self.always_collect = data.always_collect
|
||||
if data.age then
|
||||
self.age = data.age + dtime_s
|
||||
else
|
||||
self.age = dtime_s
|
||||
end
|
||||
self.age = (data.age or 0) + dtime_s
|
||||
self.dropped_by = data.dropped_by
|
||||
end
|
||||
else
|
||||
self.itemstring = staticdata
|
||||
end
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
self.object:setvelocity({x = 0, y = 2, z = 0})
|
||||
self.object:setacceleration({x = 0, y = -10, z = 0})
|
||||
self:set_item(self.itemstring)
|
||||
self.object:set_velocity({x = 0, y = 2, z = 0})
|
||||
self.object:set_acceleration({x = 0, y = -gravity, z = 0})
|
||||
self:set_item()
|
||||
end,
|
||||
|
||||
-- moves items from this stack to an other stack
|
||||
try_merge_with = function(self, own_stack, object, obj)
|
||||
-- other item's stack
|
||||
local stack = ItemStack(obj.itemstring)
|
||||
-- only merge if items are the same
|
||||
if own_stack:get_name() == stack:get_name() and
|
||||
own_stack:get_meta() == stack:get_meta() and
|
||||
own_stack:get_wear() == stack:get_wear() and
|
||||
stack:get_free_space() > 0 then
|
||||
local overflow = false
|
||||
local count = stack:get_count() + own_stack:get_count()
|
||||
local max_count = stack:get_stack_max()
|
||||
if count > max_count then
|
||||
overflow = true
|
||||
stack:set_count(max_count)
|
||||
count = count - max_count
|
||||
own_stack:set_count(count)
|
||||
else
|
||||
self.itemstring = ''
|
||||
stack:set_count(count)
|
||||
end
|
||||
local pos = object:getpos()
|
||||
pos.y = pos.y + (count - stack:get_count()) / max_count * 0.15
|
||||
object:moveto(pos, false)
|
||||
local s, c
|
||||
if not overflow then
|
||||
obj.itemstring = stack:to_string()
|
||||
s = 0.2 + 0.1 * (count / max_count)
|
||||
c = s
|
||||
object:set_properties({
|
||||
visual_size = {x = s, y = s},
|
||||
collisionbox = {-c, -c, -c, c, c, c},
|
||||
wield_item = obj.itemstring
|
||||
})
|
||||
self.object:remove()
|
||||
-- merging succeeded
|
||||
return true
|
||||
else
|
||||
s = 0.4
|
||||
c = 0.3
|
||||
obj.itemstring = stack:to_string()
|
||||
object:set_properties({
|
||||
visual_size = {x = s, y = s},
|
||||
collisionbox = {-c, -c, -c, c, c, c},
|
||||
wield_item = obj.itemstring
|
||||
})
|
||||
s = 0.2 + 0.1 * (count / max_count)
|
||||
c = s
|
||||
self.itemstring = own_stack:to_string()
|
||||
self.object:set_properties({
|
||||
visual_size = {x = s, y = s},
|
||||
collisionbox = {-c, -c, -c, c, c, c},
|
||||
wield_item = self.itemstring
|
||||
})
|
||||
end
|
||||
try_merge_with = function(self, own_stack, object, entity)
|
||||
if self.age == entity.age then
|
||||
-- Can not merge with itself
|
||||
return false
|
||||
end
|
||||
-- merging didn't succeed
|
||||
return false
|
||||
|
||||
local stack = ItemStack(entity.itemstring)
|
||||
local name = stack:get_name()
|
||||
if own_stack:get_name() ~= name or
|
||||
own_stack:get_meta() ~= stack:get_meta() or
|
||||
own_stack:get_wear() ~= stack:get_wear() or
|
||||
own_stack:get_free_space() == 0 then
|
||||
-- Can not merge different or full stack
|
||||
return false
|
||||
end
|
||||
|
||||
local count = own_stack:get_count()
|
||||
local total_count = stack:get_count() + count
|
||||
local max_count = stack:get_stack_max()
|
||||
|
||||
if total_count > max_count then
|
||||
return false
|
||||
end
|
||||
-- Merge the remote stack into this one
|
||||
|
||||
local pos = object:get_pos()
|
||||
pos.y = pos.y + ((total_count - count) / max_count) * 0.15
|
||||
self.object:move_to(pos)
|
||||
|
||||
self.age = 0 -- Handle as new entity
|
||||
own_stack:set_count(total_count)
|
||||
self:set_item(own_stack)
|
||||
|
||||
entity.itemstring = ""
|
||||
object:remove()
|
||||
return true
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
self.age = self.age + dtime
|
||||
if time_to_live > 0 and self.age > time_to_live then
|
||||
self.itemstring = ''
|
||||
self.itemstring = ""
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
local p = self.object:getpos()
|
||||
p.y = p.y - 0.5
|
||||
local node = core.get_node_or_nil(p)
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
local node = core.get_node_or_nil({
|
||||
x = pos.x,
|
||||
y = pos.y + self.object:get_properties().collisionbox[2] - 0.05,
|
||||
z = pos.z
|
||||
})
|
||||
-- Delete in 'ignore' nodes
|
||||
if node and node.name == "ignore" then
|
||||
self.itemstring = ""
|
||||
|
@ -181,48 +152,77 @@ core.register_entity(":__builtin:item", {
|
|||
return
|
||||
end
|
||||
|
||||
-- If node is nil (unloaded area), or node is not registered, or node is
|
||||
-- walkably solid and item is resting on nodebox
|
||||
local v = self.object:getvelocity()
|
||||
if not node or not core.registered_nodes[node.name] or
|
||||
core.registered_nodes[node.name].walkable and v.y == 0 then
|
||||
if self.physical_state then
|
||||
local own_stack = ItemStack(self.object:get_luaentity().itemstring)
|
||||
-- Merge with close entities of the same item
|
||||
for _, object in ipairs(core.get_objects_inside_radius(p, 0.8)) do
|
||||
local obj = object:get_luaentity()
|
||||
if obj and obj.name == "__builtin:item"
|
||||
and obj.physical_state == false then
|
||||
if self:try_merge_with(own_stack, object, obj) then
|
||||
return
|
||||
end
|
||||
local vel = self.object:get_velocity()
|
||||
local def = node and core.registered_nodes[node.name]
|
||||
local is_moving = (def and not def.walkable) or
|
||||
vel.x ~= 0 or vel.y ~= 0 or vel.z ~= 0
|
||||
local is_slippery = false
|
||||
|
||||
if def and def.walkable then
|
||||
local slippery = core.get_item_group(node.name, "slippery")
|
||||
is_slippery = slippery ~= 0
|
||||
if is_slippery and (math.abs(vel.x) > 0.2 or math.abs(vel.z) > 0.2) then
|
||||
-- Horizontal deceleration
|
||||
local slip_factor = 4.0 / (slippery + 4)
|
||||
self.object:set_acceleration({
|
||||
x = -vel.x * slip_factor,
|
||||
y = 0,
|
||||
z = -vel.z * slip_factor
|
||||
})
|
||||
elseif vel.y == 0 then
|
||||
is_moving = false
|
||||
end
|
||||
end
|
||||
|
||||
if self.moving_state == is_moving and
|
||||
self.slippery_state == is_slippery then
|
||||
-- Do not update anything until the moving state changes
|
||||
return
|
||||
end
|
||||
|
||||
self.moving_state = is_moving
|
||||
self.slippery_state = is_slippery
|
||||
|
||||
if is_moving then
|
||||
self.object:set_acceleration({x = 0, y = -gravity, z = 0})
|
||||
else
|
||||
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
||||
self.object:set_velocity({x = 0, y = 0, z = 0})
|
||||
end
|
||||
|
||||
--Only collect items if not moving
|
||||
if is_moving then
|
||||
return
|
||||
end
|
||||
-- Collect the items around to merge with
|
||||
local own_stack = ItemStack(self.itemstring)
|
||||
if own_stack:get_free_space() == 0 then
|
||||
return
|
||||
end
|
||||
local objects = core.get_objects_inside_radius(pos, 1.0)
|
||||
for k, obj in pairs(objects) do
|
||||
local entity = obj:get_luaentity()
|
||||
if entity and entity.name == "__builtin:item" then
|
||||
if self:try_merge_with(own_stack, obj, entity) then
|
||||
own_stack = ItemStack(self.itemstring)
|
||||
if own_stack:get_free_space() == 0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
self.object:setvelocity({x = 0, y = 0, z = 0})
|
||||
self.object:setacceleration({x = 0, y = 0, z = 0})
|
||||
self.physical_state = false
|
||||
self.object:set_properties({physical = false})
|
||||
end
|
||||
else
|
||||
if not self.physical_state then
|
||||
self.object:setvelocity({x = 0, y = 0, z = 0})
|
||||
self.object:setacceleration({x = 0, y = -10, z = 0})
|
||||
self.physical_state = true
|
||||
self.object:set_properties({physical = true})
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
on_punch = function(self, hitter)
|
||||
local inv = hitter:get_inventory()
|
||||
if inv and self.itemstring ~= '' then
|
||||
if inv and self.itemstring ~= "" then
|
||||
local left = inv:add_item("main", self.itemstring)
|
||||
if left and not left:is_empty() then
|
||||
self.itemstring = left:to_string()
|
||||
self:set_item(left)
|
||||
return
|
||||
end
|
||||
end
|
||||
self.itemstring = ''
|
||||
self.itemstring = ""
|
||||
self.object:remove()
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -39,26 +39,46 @@ function core.check_player_privs(name, ...)
|
|||
return true, ""
|
||||
end
|
||||
|
||||
|
||||
local player_list = {}
|
||||
|
||||
core.register_on_joinplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
player_list[player_name] = player
|
||||
if not minetest.is_singleplayer() then
|
||||
|
||||
function core.send_join_message(player_name)
|
||||
if not core.is_singleplayer() then
|
||||
core.chat_send_all("*** " .. player_name .. " joined the game.")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
core.register_on_leaveplayer(function(player, timed_out)
|
||||
local player_name = player:get_player_name()
|
||||
player_list[player_name] = nil
|
||||
|
||||
function core.send_leave_message(player_name, timed_out)
|
||||
local announcement = "*** " .. player_name .. " left the game."
|
||||
if timed_out then
|
||||
announcement = announcement .. " (timed out)"
|
||||
end
|
||||
core.chat_send_all(announcement)
|
||||
end
|
||||
|
||||
|
||||
core.register_on_joinplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
player_list[player_name] = player
|
||||
if not minetest.is_singleplayer() then
|
||||
local status = core.get_server_status(player_name, true)
|
||||
if status and status ~= "" then
|
||||
core.chat_send_player(player_name, status)
|
||||
end
|
||||
end
|
||||
core.send_join_message(player_name)
|
||||
end)
|
||||
|
||||
|
||||
core.register_on_leaveplayer(function(player, timed_out)
|
||||
local player_name = player:get_player_name()
|
||||
player_list[player_name] = nil
|
||||
core.send_leave_message(player_name, timed_out)
|
||||
end)
|
||||
|
||||
|
||||
function core.get_connected_players()
|
||||
local temp_table = {}
|
||||
for index, value in pairs(player_list) do
|
||||
|
@ -79,19 +99,21 @@ function core.is_player(player)
|
|||
end
|
||||
|
||||
|
||||
function minetest.player_exists(name)
|
||||
return minetest.get_auth_handler().get_auth(name) ~= nil
|
||||
function core.player_exists(name)
|
||||
return core.get_auth_handler().get_auth(name) ~= nil
|
||||
end
|
||||
|
||||
|
||||
-- Returns two position vectors representing a box of `radius` in each
|
||||
-- direction centered around the player corresponding to `player_name`
|
||||
|
||||
function core.get_player_radius_area(player_name, radius)
|
||||
local player = core.get_player_by_name(player_name)
|
||||
if player == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
local p1 = player:getpos()
|
||||
local p1 = player:get_pos()
|
||||
local p2 = p1
|
||||
|
||||
if radius then
|
||||
|
@ -102,20 +124,25 @@ function core.get_player_radius_area(player_name, radius)
|
|||
return p1, p2
|
||||
end
|
||||
|
||||
|
||||
function core.hash_node_position(pos)
|
||||
return (pos.z+32768)*65536*65536 + (pos.y+32768)*65536 + pos.x+32768
|
||||
return (pos.z + 32768) * 65536 * 65536
|
||||
+ (pos.y + 32768) * 65536
|
||||
+ pos.x + 32768
|
||||
end
|
||||
|
||||
|
||||
function core.get_position_from_hash(hash)
|
||||
local pos = {}
|
||||
pos.x = (hash%65536) - 32768
|
||||
hash = math.floor(hash/65536)
|
||||
pos.y = (hash%65536) - 32768
|
||||
hash = math.floor(hash/65536)
|
||||
pos.z = (hash%65536) - 32768
|
||||
pos.x = (hash % 65536) - 32768
|
||||
hash = math.floor(hash / 65536)
|
||||
pos.y = (hash % 65536) - 32768
|
||||
hash = math.floor(hash / 65536)
|
||||
pos.z = (hash % 65536) - 32768
|
||||
return pos
|
||||
end
|
||||
|
||||
|
||||
function core.get_item_group(name, group)
|
||||
if not core.registered_items[name] or not
|
||||
core.registered_items[name].groups[group] then
|
||||
|
@ -124,11 +151,13 @@ function core.get_item_group(name, group)
|
|||
return core.registered_items[name].groups[group]
|
||||
end
|
||||
|
||||
|
||||
function core.get_node_group(name, group)
|
||||
core.log("deprecated", "Deprecated usage of get_node_group, use get_item_group instead")
|
||||
return core.get_item_group(name, group)
|
||||
end
|
||||
|
||||
|
||||
function core.setting_get_pos(name)
|
||||
local value = core.settings:get(name)
|
||||
if not value then
|
||||
|
@ -137,17 +166,68 @@ function core.setting_get_pos(name)
|
|||
return core.string_to_pos(value)
|
||||
end
|
||||
|
||||
|
||||
-- To be overriden by protection mods
|
||||
|
||||
function core.is_protected(pos, name)
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function core.record_protection_violation(pos, name)
|
||||
for _, func in pairs(core.registered_on_protection_violation) do
|
||||
func(pos, name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Checks if specified volume intersects a protected volume
|
||||
|
||||
function core.is_area_protected(minp, maxp, player_name, interval)
|
||||
-- 'interval' is the largest allowed interval for the 3D lattice of checks.
|
||||
|
||||
-- Compute the optimal float step 'd' for each axis so that all corners and
|
||||
-- borders are checked. 'd' will be smaller or equal to 'interval'.
|
||||
-- Subtracting 1e-4 ensures that the max co-ordinate will be reached by the
|
||||
-- for loop (which might otherwise not be the case due to rounding errors).
|
||||
|
||||
-- Default to 4
|
||||
interval = interval or 4
|
||||
local d = {}
|
||||
|
||||
for _, c in pairs({"x", "y", "z"}) do
|
||||
if minp[c] > maxp[c] then
|
||||
-- Repair positions: 'minp' > 'maxp'
|
||||
local tmp = maxp[c]
|
||||
maxp[c] = minp[c]
|
||||
minp[c] = tmp
|
||||
end
|
||||
|
||||
if maxp[c] > minp[c] then
|
||||
d[c] = (maxp[c] - minp[c]) /
|
||||
math.ceil((maxp[c] - minp[c]) / interval) - 1e-4
|
||||
else
|
||||
d[c] = 1 -- Any value larger than 0 to avoid division by zero
|
||||
end
|
||||
end
|
||||
|
||||
for zf = minp.z, maxp.z, d.z do
|
||||
local z = math.floor(zf + 0.5)
|
||||
for yf = minp.y, maxp.y, d.y do
|
||||
local y = math.floor(yf + 0.5)
|
||||
for xf = minp.x, maxp.x, d.x do
|
||||
local x = math.floor(xf + 0.5)
|
||||
local pos = {x = x, y = y, z = z}
|
||||
if core.is_protected(pos, player_name) then
|
||||
return pos
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
local raillike_ids = {}
|
||||
local raillike_cur_id = 0
|
||||
function core.raillike_group(name)
|
||||
|
@ -160,7 +240,9 @@ function core.raillike_group(name)
|
|||
return id
|
||||
end
|
||||
|
||||
|
||||
-- HTTP callback interface
|
||||
|
||||
function core.http_add_fetch(httpenv)
|
||||
httpenv.fetch = function(req, callback)
|
||||
local handle = httpenv.fetch_async(req)
|
||||
|
@ -179,11 +261,12 @@ function core.http_add_fetch(httpenv)
|
|||
return httpenv
|
||||
end
|
||||
|
||||
|
||||
function core.close_formspec(player_name, formname)
|
||||
return minetest.show_formspec(player_name, formname, "")
|
||||
return core.show_formspec(player_name, formname, "")
|
||||
end
|
||||
|
||||
|
||||
function core.cancel_shutdown_requests()
|
||||
core.request_shutdown("", false, -1)
|
||||
end
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ function core.register_privilege(name, param)
|
|||
if def.give_to_singleplayer == nil then
|
||||
def.give_to_singleplayer = true
|
||||
end
|
||||
if def.give_to_admin == nil then
|
||||
def.give_to_admin = def.give_to_singleplayer
|
||||
end
|
||||
if def.description == nil then
|
||||
def.description = "(no description)"
|
||||
end
|
||||
|
@ -31,7 +34,7 @@ core.register_privilege("basic_privs", "Can modify 'shout' and 'interact' privil
|
|||
core.register_privilege("privs", "Can modify privileges")
|
||||
|
||||
core.register_privilege("teleport", {
|
||||
description = "Can use /teleport command",
|
||||
description = "Can teleport self",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("bring", {
|
||||
|
@ -39,12 +42,13 @@ core.register_privilege("bring", {
|
|||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("settime", {
|
||||
description = "Can use /time",
|
||||
description = "Can set the time of day using /time",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("server", {
|
||||
description = "Can do server maintenance stuff",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = true,
|
||||
})
|
||||
core.register_privilege("protection_bypass", {
|
||||
description = "Can bypass node protection in the world",
|
||||
|
@ -53,10 +57,12 @@ core.register_privilege("protection_bypass", {
|
|||
core.register_privilege("ban", {
|
||||
description = "Can ban and unban players",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = true,
|
||||
})
|
||||
core.register_privilege("kick", {
|
||||
description = "Can kick players",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = true,
|
||||
})
|
||||
core.register_privilege("give", {
|
||||
description = "Can use /give and /giveme",
|
||||
|
@ -65,28 +71,31 @@ core.register_privilege("give", {
|
|||
core.register_privilege("password", {
|
||||
description = "Can use /setpassword and /clearpassword",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = true,
|
||||
})
|
||||
core.register_privilege("fly", {
|
||||
description = "Can fly using the free_move mode",
|
||||
description = "Can use fly mode",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("fast", {
|
||||
description = "Can walk fast using the fast_move mode",
|
||||
description = "Can use fast mode",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("noclip", {
|
||||
description = "Can fly through walls",
|
||||
description = "Can fly through solid nodes using noclip mode",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("rollback", {
|
||||
description = "Can use the rollback functionality",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("zoom", {
|
||||
description = "Can zoom the camera",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("debug", {
|
||||
description = "Allows enabling various debug options that may affect gameplay",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = true,
|
||||
})
|
||||
|
||||
core.register_can_bypass_userlimit(function(name, ip)
|
||||
local privs = core.get_player_privs(name)
|
||||
return privs["server"] or privs["ban"] or privs["privs"] or privs["password"]
|
||||
end)
|
||||
|
|
|
@ -65,14 +65,14 @@ local function check_modname_prefix(name)
|
|||
error("Name " .. name .. " does not follow naming conventions: " ..
|
||||
"\"" .. expected_prefix .. "\" or \":\" prefix required")
|
||||
end
|
||||
|
||||
|
||||
-- Enforce that the name only contains letters, numbers and underscores.
|
||||
local subname = name:sub(#expected_prefix+1)
|
||||
if subname:find("[^%w_]") then
|
||||
error("Name " .. name .. " does not follow naming conventions: " ..
|
||||
"contains unallowed characters")
|
||||
end
|
||||
|
||||
|
||||
return name
|
||||
end
|
||||
end
|
||||
|
@ -116,8 +116,6 @@ function core.register_item(name, itemdef)
|
|||
end
|
||||
itemdef.name = name
|
||||
|
||||
local is_overriding = core.registered_items[name]
|
||||
|
||||
-- Apply defaults and add to registered_* table
|
||||
if itemdef.type == "node" then
|
||||
-- Use the nodebox as selection box if it's not set manually
|
||||
|
@ -179,13 +177,7 @@ function core.register_item(name, itemdef)
|
|||
--core.log("Registering item: " .. itemdef.name)
|
||||
core.registered_items[itemdef.name] = itemdef
|
||||
core.registered_aliases[itemdef.name] = nil
|
||||
|
||||
-- Used to allow builtin to register ignore to registered_items
|
||||
if name ~= "ignore" then
|
||||
register_item_raw(itemdef)
|
||||
elseif is_overriding then
|
||||
core.log("warning", "Attempted redefinition of \"ignore\"")
|
||||
end
|
||||
register_item_raw(itemdef)
|
||||
end
|
||||
|
||||
function core.unregister_item(name)
|
||||
|
@ -338,7 +330,7 @@ core.register_item(":unknown", {
|
|||
})
|
||||
|
||||
core.register_node(":air", {
|
||||
description = "Air (you hacker you!)",
|
||||
description = "Air",
|
||||
inventory_image = "air.png",
|
||||
wield_image = "air.png",
|
||||
drawtype = "airlike",
|
||||
|
@ -355,7 +347,7 @@ core.register_node(":air", {
|
|||
})
|
||||
|
||||
core.register_node(":ignore", {
|
||||
description = "Ignore (you hacker you!)",
|
||||
description = "Ignore",
|
||||
inventory_image = "ignore.png",
|
||||
wield_image = "ignore.png",
|
||||
drawtype = "airlike",
|
||||
|
@ -368,6 +360,13 @@ core.register_node(":ignore", {
|
|||
air_equivalent = true,
|
||||
drop = "",
|
||||
groups = {not_in_creative_inventory=1},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
minetest.chat_send_player(
|
||||
placer:get_player_name(),
|
||||
minetest.colorize("#FF0000",
|
||||
"You can't place 'ignore' nodes!"))
|
||||
return ""
|
||||
end,
|
||||
})
|
||||
|
||||
-- The hand (bare definition)
|
||||
|
@ -443,6 +442,18 @@ function core.run_callbacks(callbacks, mode, ...)
|
|||
return ret
|
||||
end
|
||||
|
||||
function core.run_priv_callbacks(name, priv, caller, method)
|
||||
local def = core.registered_privileges[priv]
|
||||
if not def or not def["on_" .. method] or
|
||||
not def["on_" .. method](name, caller) then
|
||||
for _, func in ipairs(core["registered_on_priv_" .. method]) do
|
||||
if not func(name, caller, priv) then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Callback registration
|
||||
--
|
||||
|
@ -502,13 +513,26 @@ local function make_registration_wrap(reg_fn_name, clear_fn_name)
|
|||
return list
|
||||
end
|
||||
|
||||
local function make_wrap_deregistration(reg_fn, clear_fn, list)
|
||||
local unregister = function (unregistered_key)
|
||||
local temporary_list = table.copy(list)
|
||||
clear_fn()
|
||||
for k,v in pairs(temporary_list) do
|
||||
if unregistered_key ~= k then
|
||||
reg_fn(v)
|
||||
end
|
||||
end
|
||||
end
|
||||
return unregister
|
||||
end
|
||||
|
||||
core.registered_on_player_hpchanges = { modifiers = { }, loggers = { } }
|
||||
|
||||
function core.registered_on_player_hpchange(player, hp_change)
|
||||
function core.registered_on_player_hpchange(player, hp_change, reason)
|
||||
local last = false
|
||||
for i = #core.registered_on_player_hpchanges.modifiers, 1, -1 do
|
||||
local func = core.registered_on_player_hpchanges.modifiers[i]
|
||||
hp_change, last = func(player, hp_change)
|
||||
hp_change, last = func(player, hp_change, reason)
|
||||
if type(hp_change) ~= "number" then
|
||||
local debuginfo = debug.getinfo(func)
|
||||
error("The register_on_hp_changes function has to return a number at " ..
|
||||
|
@ -519,7 +543,7 @@ function core.registered_on_player_hpchange(player, hp_change)
|
|||
end
|
||||
end
|
||||
for i, func in ipairs(core.registered_on_player_hpchanges.loggers) do
|
||||
func(player, hp_change)
|
||||
func(player, hp_change, reason)
|
||||
end
|
||||
return hp_change
|
||||
end
|
||||
|
@ -540,9 +564,12 @@ core.registered_biomes = make_registration_wrap("register_biome", "cle
|
|||
core.registered_ores = make_registration_wrap("register_ore", "clear_registered_ores")
|
||||
core.registered_decorations = make_registration_wrap("register_decoration", "clear_registered_decorations")
|
||||
|
||||
core.unregister_biome = make_wrap_deregistration(core.register_biome, core.clear_registered_biomes, core.registered_biomes)
|
||||
|
||||
core.registered_on_chat_messages, core.register_on_chat_message = make_registration()
|
||||
core.registered_globalsteps, core.register_globalstep = make_registration()
|
||||
core.registered_playerevents, core.register_playerevent = make_registration()
|
||||
core.registered_on_mods_loaded, core.register_on_mods_loaded = make_registration()
|
||||
core.registered_on_shutdown, core.register_on_shutdown = make_registration()
|
||||
core.registered_on_punchnodes, core.register_on_punchnode = make_registration()
|
||||
core.registered_on_placenodes, core.register_on_placenode = make_registration()
|
||||
|
@ -561,10 +588,16 @@ core.registered_craft_predicts, core.register_craft_predict = make_registration(
|
|||
core.registered_on_protection_violation, core.register_on_protection_violation = make_registration()
|
||||
core.registered_on_item_eats, core.register_on_item_eat = make_registration()
|
||||
core.registered_on_punchplayers, core.register_on_punchplayer = make_registration()
|
||||
core.registered_on_priv_grant, core.register_on_priv_grant = make_registration()
|
||||
core.registered_on_priv_revoke, core.register_on_priv_revoke = make_registration()
|
||||
core.registered_can_bypass_userlimit, core.register_can_bypass_userlimit = make_registration()
|
||||
core.registered_on_modchannel_message, core.register_on_modchannel_message = make_registration()
|
||||
core.registered_on_auth_fail, core.register_on_auth_fail = make_registration()
|
||||
core.registered_on_player_inventory_actions, core.register_on_player_inventory_action = make_registration()
|
||||
core.registered_allow_player_inventory_actions, core.register_allow_player_inventory_action = make_registration()
|
||||
|
||||
--
|
||||
-- Compatibility for on_mapgen_init()
|
||||
--
|
||||
|
||||
core.register_on_mapgen_init = function(func) func(core.get_mapgen_params()) end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ local health_bar_definition =
|
|||
hud_elem_type = "statbar",
|
||||
position = { x=0.5, y=1 },
|
||||
text = "heart.png",
|
||||
number = 20,
|
||||
number = core.PLAYER_MAX_HP_DEFAULT,
|
||||
direction = 0,
|
||||
size = { x=24, y=24 },
|
||||
offset = { x=(-10*24)-25, y=-(48+24+16)},
|
||||
|
@ -17,7 +17,7 @@ local breath_bar_definition =
|
|||
hud_elem_type = "statbar",
|
||||
position = { x=0.5, y=1 },
|
||||
text = "bubble.png",
|
||||
number = 20,
|
||||
number = core.PLAYER_MAX_BREATH_DEFAULT,
|
||||
direction = 0,
|
||||
size = { x=24, y=24 },
|
||||
offset = {x=25,y=-(48+24+16)},
|
||||
|
@ -25,60 +25,63 @@ local breath_bar_definition =
|
|||
|
||||
local hud_ids = {}
|
||||
|
||||
local function initialize_builtin_statbars(player)
|
||||
|
||||
if not player:is_player() then
|
||||
return
|
||||
end
|
||||
local function scaleToDefault(player, field)
|
||||
-- Scale "hp" or "breath" to the default dimensions
|
||||
local current = player["get_" .. field](player)
|
||||
local nominal = core["PLAYER_MAX_".. field:upper() .. "_DEFAULT"]
|
||||
local max_display = math.max(nominal,
|
||||
math.max(player:get_properties()[field .. "_max"], current))
|
||||
return current / max_display * nominal
|
||||
end
|
||||
|
||||
local function update_builtin_statbars(player)
|
||||
local name = player:get_player_name()
|
||||
|
||||
if name == "" then
|
||||
return
|
||||
end
|
||||
|
||||
if (hud_ids[name] == nil) then
|
||||
local flags = player:hud_get_flags()
|
||||
if not hud_ids[name] then
|
||||
hud_ids[name] = {}
|
||||
-- flags are not transmitted to client on connect, we need to make sure
|
||||
-- our current flags are transmitted by sending them actively
|
||||
player:hud_set_flags(player:hud_get_flags())
|
||||
player:hud_set_flags(flags)
|
||||
end
|
||||
local hud = hud_ids[name]
|
||||
|
||||
if player:hud_get_flags().healthbar and enable_damage then
|
||||
if hud_ids[name].id_healthbar == nil then
|
||||
health_bar_definition.number = player:get_hp()
|
||||
hud_ids[name].id_healthbar = player:hud_add(health_bar_definition)
|
||||
end
|
||||
else
|
||||
if hud_ids[name].id_healthbar ~= nil then
|
||||
player:hud_remove(hud_ids[name].id_healthbar)
|
||||
hud_ids[name].id_healthbar = nil
|
||||
end
|
||||
end
|
||||
|
||||
if (player:get_breath() < 11) then
|
||||
if player:hud_get_flags().breathbar and enable_damage then
|
||||
if hud_ids[name].id_breathbar == nil then
|
||||
hud_ids[name].id_breathbar = player:hud_add(breath_bar_definition)
|
||||
end
|
||||
if flags.healthbar and enable_damage then
|
||||
local number = scaleToDefault(player, "hp")
|
||||
if hud.id_healthbar == nil then
|
||||
local hud_def = table.copy(health_bar_definition)
|
||||
hud_def.number = number
|
||||
hud.id_healthbar = player:hud_add(hud_def)
|
||||
else
|
||||
if hud_ids[name].id_breathbar ~= nil then
|
||||
player:hud_remove(hud_ids[name].id_breathbar)
|
||||
hud_ids[name].id_breathbar = nil
|
||||
end
|
||||
player:hud_change(hud.id_healthbar, "number", number)
|
||||
end
|
||||
elseif hud_ids[name].id_breathbar ~= nil then
|
||||
player:hud_remove(hud_ids[name].id_breathbar)
|
||||
hud_ids[name].id_breathbar = nil
|
||||
elseif hud.id_healthbar then
|
||||
player:hud_remove(hud.id_healthbar)
|
||||
hud.id_healthbar = nil
|
||||
end
|
||||
|
||||
local breath_max = player:get_properties().breath_max
|
||||
if flags.breathbar and enable_damage and
|
||||
player:get_breath() < breath_max then
|
||||
local number = 2 * scaleToDefault(player, "breath")
|
||||
if hud.id_breathbar == nil then
|
||||
local hud_def = table.copy(breath_bar_definition)
|
||||
hud_def.number = number
|
||||
hud.id_breathbar = player:hud_add(hud_def)
|
||||
else
|
||||
player:hud_change(hud.id_breathbar, "number", number)
|
||||
end
|
||||
elseif hud.id_breathbar then
|
||||
player:hud_remove(hud.id_breathbar)
|
||||
hud.id_breathbar = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function cleanup_builtin_statbars(player)
|
||||
|
||||
if not player:is_player() then
|
||||
return
|
||||
end
|
||||
|
||||
local name = player:get_player_name()
|
||||
|
||||
if name == "" then
|
||||
|
@ -93,30 +96,28 @@ local function player_event_handler(player,eventname)
|
|||
|
||||
local name = player:get_player_name()
|
||||
|
||||
if name == "" then
|
||||
if name == "" or not hud_ids[name] then
|
||||
return
|
||||
end
|
||||
|
||||
if eventname == "health_changed" then
|
||||
initialize_builtin_statbars(player)
|
||||
update_builtin_statbars(player)
|
||||
|
||||
if hud_ids[name].id_healthbar ~= nil then
|
||||
player:hud_change(hud_ids[name].id_healthbar,"number",player:get_hp())
|
||||
if hud_ids[name].id_healthbar then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
if eventname == "breath_changed" then
|
||||
initialize_builtin_statbars(player)
|
||||
update_builtin_statbars(player)
|
||||
|
||||
if hud_ids[name].id_breathbar ~= nil then
|
||||
player:hud_change(hud_ids[name].id_breathbar,"number",player:get_breath()*2)
|
||||
if hud_ids[name].id_breathbar then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
if eventname == "hud_changed" then
|
||||
initialize_builtin_statbars(player)
|
||||
update_builtin_statbars(player)
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -125,20 +126,20 @@ end
|
|||
|
||||
function core.hud_replace_builtin(name, definition)
|
||||
|
||||
if definition == nil or
|
||||
type(definition) ~= "table" or
|
||||
definition.hud_elem_type ~= "statbar" then
|
||||
if type(definition) ~= "table" or
|
||||
definition.hud_elem_type ~= "statbar" then
|
||||
return false
|
||||
end
|
||||
|
||||
if name == "health" then
|
||||
health_bar_definition = definition
|
||||
|
||||
for name,ids in pairs(hud_ids) do
|
||||
for name, ids in pairs(hud_ids) do
|
||||
local player = core.get_player_by_name(name)
|
||||
if player and hud_ids[name].id_healthbar then
|
||||
player:hud_remove(hud_ids[name].id_healthbar)
|
||||
initialize_builtin_statbars(player)
|
||||
if player and ids.id_healthbar then
|
||||
player:hud_remove(ids.id_healthbar)
|
||||
ids.id_healthbar = nil
|
||||
update_builtin_statbars(player)
|
||||
end
|
||||
end
|
||||
return true
|
||||
|
@ -147,11 +148,12 @@ function core.hud_replace_builtin(name, definition)
|
|||
if name == "breath" then
|
||||
breath_bar_definition = definition
|
||||
|
||||
for name,ids in pairs(hud_ids) do
|
||||
for name, ids in pairs(hud_ids) do
|
||||
local player = core.get_player_by_name(name)
|
||||
if player and hud_ids[name].id_breathbar then
|
||||
player:hud_remove(hud_ids[name].id_breathbar)
|
||||
initialize_builtin_statbars(player)
|
||||
if player and ids.id_breathbar then
|
||||
player:hud_remove(ids.id_breathbar)
|
||||
ids.id_breathbar = nil
|
||||
update_builtin_statbars(player)
|
||||
end
|
||||
end
|
||||
return true
|
||||
|
@ -160,6 +162,10 @@ function core.hud_replace_builtin(name, definition)
|
|||
return false
|
||||
end
|
||||
|
||||
core.register_on_joinplayer(initialize_builtin_statbars)
|
||||
-- Append "update_builtin_statbars" as late as possible
|
||||
-- This ensures that the HUD is hidden when the flags are updated in this callback
|
||||
core.register_on_mods_loaded(function()
|
||||
core.register_on_joinplayer(update_builtin_statbars)
|
||||
end)
|
||||
core.register_on_leaveplayer(cleanup_builtin_statbars)
|
||||
core.register_playerevent(player_event_handler)
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
-- Minetest: builtin/static_spawn.lua
|
||||
|
||||
local function warn_invalid_static_spawnpoint()
|
||||
if core.settings:get("static_spawnpoint") and
|
||||
not core.setting_get_pos("static_spawnpoint") then
|
||||
core.log("error", "The static_spawnpoint setting is invalid: \""..
|
||||
core.settings:get("static_spawnpoint").."\"")
|
||||
end
|
||||
local static_spawnpoint_string = core.settings:get("static_spawnpoint")
|
||||
if static_spawnpoint_string and
|
||||
static_spawnpoint_string ~= "" and
|
||||
not core.setting_get_pos("static_spawnpoint") then
|
||||
error('The static_spawnpoint setting is invalid: "' ..
|
||||
static_spawnpoint_string .. '"')
|
||||
end
|
||||
|
||||
warn_invalid_static_spawnpoint()
|
||||
|
||||
local function put_player_in_spawn(player_obj)
|
||||
local static_spawnpoint = core.setting_get_pos("static_spawnpoint")
|
||||
if not static_spawnpoint then
|
||||
|
@ -17,7 +15,7 @@ local function put_player_in_spawn(player_obj)
|
|||
end
|
||||
core.log("action", "Moving " .. player_obj:get_player_name() ..
|
||||
" to static spawnpoint at " .. core.pos_to_string(static_spawnpoint))
|
||||
player_obj:setpos(static_spawnpoint)
|
||||
player_obj:set_pos(static_spawnpoint)
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ math.randomseed(os.time())
|
|||
minetest = core
|
||||
|
||||
-- Load other files
|
||||
local scriptdir = core.get_builtin_path() .. DIR_DELIM
|
||||
local scriptdir = core.get_builtin_path()
|
||||
local gamepath = scriptdir .. "game" .. DIR_DELIM
|
||||
local clientpath = scriptdir .. "client" .. DIR_DELIM
|
||||
local commonpath = scriptdir .. "common" .. DIR_DELIM
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
--------------------------------------------------------------------------------
|
||||
|
||||
local engine = {
|
||||
"Minetest 0.4.17.1 : celeron55, Core Devs and Community Minetest",
|
||||
"Minetest 5.0.1 : celeron55, Core Devs and Community Minetest",
|
||||
}
|
||||
|
||||
local developers = {
|
||||
|
|
|
@ -33,27 +33,27 @@ local function get_formspec(tabview, name, tabdata)
|
|||
|
||||
local retval =
|
||||
-- Search
|
||||
"field[0.15,0.35;6.05,0.27;te_search;;"..core.formspec_escape(tabdata.search_for).."]"..
|
||||
"button[5.8,0.1;2,0.1;btn_mp_search;" .. fgettext("Search") .. "]" ..
|
||||
--"field[0.15,0.35;6.05,0.27;te_search;;"..core.formspec_escape(tabdata.search_for).."]"..
|
||||
--"button[5.8,0.1;2,0.1;btn_mp_search;" .. fgettext("Search") .. "]" ..
|
||||
|
||||
-- Address / Port
|
||||
"label[7.75,-0.25;" .. fgettext("Address / Port") .. "]" ..
|
||||
"field[8,0.65;3.25,0.5;te_address;;" ..
|
||||
"label[0.75,0.25;" .. fgettext("Address / Port") .. "]" ..
|
||||
"field[1,1.15;3.25,0.5;te_address;;" ..
|
||||
core.formspec_escape(core.settings:get("address")) .. "]" ..
|
||||
"field[11.1,0.65;1.4,0.5;te_port;;" ..
|
||||
"field[4.1,1.15;1.4,0.5;te_port;;" ..
|
||||
core.formspec_escape(core.settings:get("remote_port")) .. "]" ..
|
||||
|
||||
-- Name / Password
|
||||
"label[7.75,0.95;" .. fgettext("Name / Password") .. "]" ..
|
||||
"field[8,1.85;2.9,0.5;te_name;;" ..
|
||||
"label[0.75,1.65;" .. fgettext("Name / Password") .. " : ]" ..
|
||||
"field[1,2.55;2.9,0.5;te_name;;" ..
|
||||
core.formspec_escape(core.settings:get("name")) .. "]" ..
|
||||
"pwdfield[10.73,1.85;1.77,0.5;te_pwd;]" ..
|
||||
"pwdfield[3.73,2.55;1.77,0.5;te_pwd;]" ..
|
||||
|
||||
-- Description Background
|
||||
"box[7.73,2.25;4.25,2.6;#999999]"..
|
||||
"box[0,0;11.5,5.5;#999999]"..
|
||||
|
||||
-- Connect
|
||||
"button[10.1,5.15;2,0.5;btn_mp_connect;" .. fgettext("Connect") .. "]"
|
||||
"button[9,4;2,0.5;btn_mp_connect;" .. fgettext("Connect") .. "]"
|
||||
|
||||
if tabdata.fav_selected and fav_selected then
|
||||
if gamedata.fav then
|
||||
|
@ -66,20 +66,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||
end
|
||||
end
|
||||
|
||||
--favourites
|
||||
retval = retval .. "tablecolumns[" ..
|
||||
image_column(fgettext("Favorite"), "favorite") .. ";" ..
|
||||
image_column(fgettext("Ping")) .. ",padding=0.25;" ..
|
||||
"color,span=3;" ..
|
||||
"text,align=right;" .. -- clients
|
||||
"text,align=center,padding=0.25;" .. -- "/"
|
||||
"text,align=right,padding=0.25;" .. -- clients_max
|
||||
image_column(fgettext("Creative mode"), "creative") .. ",padding=1;" ..
|
||||
image_column(fgettext("Damage enabled"), "damage") .. ",padding=0.25;" ..
|
||||
image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" ..
|
||||
"color,span=1;" ..
|
||||
"text,padding=1]" ..
|
||||
"table[-0.15,0.6;7.75,5.15;favourites;"
|
||||
|
||||
|
||||
if menudata.search_result then
|
||||
for i = 1, #menudata.search_result do
|
||||
|
@ -235,7 +222,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
|||
asyncOnlineFavourites()
|
||||
tabdata.fav_selected = nil
|
||||
|
||||
core.settings:set("address", "")
|
||||
core.settings:set("address", "Blockcolor.net")
|
||||
core.settings:set("remote_port", "30000")
|
||||
return true
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ local function get_bool_default(name, default)
|
|||
return val
|
||||
end
|
||||
|
||||
local profiler_path = core.get_builtin_path()..DIR_DELIM.."profiler"..DIR_DELIM
|
||||
local profiler_path = core.get_builtin_path().."profiler"..DIR_DELIM
|
||||
local profiler = {}
|
||||
local sampler = assert(loadfile(profiler_path .. "sampling.lua"))(profiler)
|
||||
local instrumentation = assert(loadfile(profiler_path .. "instrumentation.lua"))(profiler, sampler, get_bool_default)
|
||||
|
|
|
@ -88,7 +88,7 @@ local function instrument(def)
|
|||
if not def or not def.func then
|
||||
return
|
||||
end
|
||||
def.mod = def.mod or get_current_modname()
|
||||
def.mod = def.mod or get_current_modname() or "??"
|
||||
local modname = def.mod
|
||||
local instrument_name = generate_name(def)
|
||||
local func = def.func
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[server]
|
||||
BlockColor
|
||||
BlockColor Server
|
||||
blockcolor.net
|
||||
30000
|
||||
BlockColor is a creative sandbox with only 8 colors. Only a limit : Your Imagination.
|
||||
BlockColor is a creative sandbox with only 8 colors. Only a limit : Your Imagination - http://blockcolor.net/
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
uniform sampler2D baseTexture;
|
||||
uniform sampler2D normalTexture;
|
||||
uniform sampler2D textureFlags;
|
||||
|
||||
#define leftImage baseTexture
|
||||
#define rightImage normalTexture
|
||||
#define maskImage textureFlags
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 uv = gl_TexCoord[0].st;
|
||||
vec4 left = texture2D(leftImage, uv).rgba;
|
||||
vec4 right = texture2D(rightImage, uv).rgba;
|
||||
vec4 mask = texture2D(maskImage, uv).rgba;
|
||||
vec4 color;
|
||||
if (mask.r > 0.5)
|
||||
color = right;
|
||||
else
|
||||
color = left;
|
||||
gl_FragColor = color;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
void main(void)
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = gl_Vertex;
|
||||
gl_FrontColor = gl_BackColor = gl_Color;
|
||||
}
|
|
@ -135,7 +135,7 @@ float disp_z;
|
|||
color.a = 1;
|
||||
|
||||
// Emphase blue a bit in darker places
|
||||
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
|
||||
// See C++ implementation in mapblock_mesh.cpp final_color_blend()
|
||||
float brightness = (color.r + color.g + color.b) / 3;
|
||||
color.b += max(0.0, 0.021 - abs(0.2 * brightness - 0.021) +
|
||||
0.07 * brightness);
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
load_mod_preview = false
|
|
@ -0,0 +1,2 @@
|
|||
print("Loaded example file!, loading more examples")
|
||||
dofile("preview:examples/first.lua")
|
|
@ -0,0 +1 @@
|
|||
print("loaded first.lua example file")
|
|
@ -1,18 +1,57 @@
|
|||
local modname = core.get_current_modname() or "??"
|
||||
local modstorage = core.get_mod_storage()
|
||||
local mod_channel
|
||||
|
||||
dofile("preview:example.lua")
|
||||
-- This is an example function to ensure it's working properly, should be removed before merge
|
||||
core.register_on_shutdown(function()
|
||||
print("[PREVIEW] shutdown client")
|
||||
end)
|
||||
local id = nil
|
||||
|
||||
core.register_on_connect(function()
|
||||
print("[PREVIEW] Player connection completed")
|
||||
local server_info = core.get_server_info()
|
||||
print("Server version: " .. server_info.protocol_version)
|
||||
print("Server ip: " .. server_info.ip)
|
||||
print("Server address: " .. server_info.address)
|
||||
print("Server port: " .. server_info.port)
|
||||
local server_info = core.get_server_info()
|
||||
print("Server version: " .. server_info.protocol_version)
|
||||
print("Server ip: " .. server_info.ip)
|
||||
print("Server address: " .. server_info.address)
|
||||
print("Server port: " .. server_info.port)
|
||||
mod_channel = core.mod_channel_join("experimental_preview")
|
||||
|
||||
core.after(4, function()
|
||||
if mod_channel:is_writeable() then
|
||||
mod_channel:send_all("preview talk to experimental")
|
||||
end
|
||||
end)
|
||||
|
||||
core.after(1, function()
|
||||
id = core.localplayer:hud_add({
|
||||
hud_elem_type = "text",
|
||||
name = "example",
|
||||
number = 0xff0000,
|
||||
position = {x=0, y=1},
|
||||
offset = {x=8, y=-8},
|
||||
text = "You are using the preview mod",
|
||||
scale = {x=200, y=60},
|
||||
alignment = {x=1, y=-1},
|
||||
})
|
||||
end)
|
||||
|
||||
core.register_on_modchannel_message(function(channel, sender, message)
|
||||
print("[PREVIEW][modchannels] Received message `" .. message .. "` on channel `"
|
||||
.. channel .. "` from sender `" .. sender .. "`")
|
||||
core.after(1, function()
|
||||
mod_channel:send_all("CSM preview received " .. message)
|
||||
end)
|
||||
end)
|
||||
|
||||
core.register_on_modchannel_signal(function(channel, signal)
|
||||
print("[PREVIEW][modchannels] Received signal id `" .. signal .. "` on channel `"
|
||||
.. channel)
|
||||
end)
|
||||
|
||||
core.register_on_inventory_open(function(inventory)
|
||||
print("INVENTORY OPEN")
|
||||
print(dump(inventory))
|
||||
return false
|
||||
end)
|
||||
|
||||
core.register_on_placenode(function(pointed_thing, node)
|
||||
|
@ -30,13 +69,13 @@ core.register_on_item_use(function(itemstack, pointed_thing)
|
|||
end)
|
||||
|
||||
-- This is an example function to ensure it's working properly, should be removed before merge
|
||||
core.register_on_receiving_chat_messages(function(message)
|
||||
core.register_on_receiving_chat_message(function(message)
|
||||
print("[PREVIEW] Received message " .. message)
|
||||
return false
|
||||
end)
|
||||
|
||||
-- This is an example function to ensure it's working properly, should be removed before merge
|
||||
core.register_on_sending_chat_messages(function(message)
|
||||
core.register_on_sending_chat_message(function(message)
|
||||
print("[PREVIEW] Sending message " .. message)
|
||||
return false
|
||||
end)
|
||||
|
@ -150,3 +189,19 @@ core.register_on_punchnode(function(pos, node)
|
|||
return false
|
||||
end)
|
||||
|
||||
core.register_chatcommand("privs", {
|
||||
func = function(param)
|
||||
return true, core.privs_to_string(minetest.get_privilege_list())
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("text", {
|
||||
func = function(param)
|
||||
return core.localplayer:hud_change(id, "text", param)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
core.register_on_mods_loaded(function()
|
||||
core.log("Yeah preview mod is loaded with other CSM mods.")
|
||||
end)
|
||||
|
|
|
@ -0,0 +1,500 @@
|
|||
Minetest
|
||||
========
|
||||
|
||||
[![Build Status](https://travis-ci.org/minetest/minetest.svg?branch=master)](https://travis-ci.org/minetest/minetest)
|
||||
[![Translation status](https://hosted.weblate.org/widgets/minetest/-/svg-badge.svg)](https://hosted.weblate.org/engage/minetest/?utm_source=widget)
|
||||
[![License](https://img.shields.io/badge/license-LGPLv2.1%2B-blue.svg)](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
|
||||
|
||||
Minetest is a free open-source voxel game engine with easy modding and game creation.
|
||||
|
||||
Copyright (C) 2010-2018 Perttu Ahola <celeron55@gmail.com>
|
||||
and contributors (see source file comments and the version control log)
|
||||
|
||||
In case you downloaded the source code:
|
||||
---------------------------------------
|
||||
If you downloaded the Minetest Engine source code in which this file is
|
||||
contained, you probably want to download the [Minetest Game](https://github.com/minetest/minetest_game/)
|
||||
project too. See its README.txt for more information.
|
||||
|
||||
Table of Contents
|
||||
------------------
|
||||
|
||||
1. [Further Documentation](#further-documentation)
|
||||
2. [Default Controls](#default-controls)
|
||||
3. [Paths](#paths)
|
||||
4. [Configuration File](#configuration-file)
|
||||
5. [Command-line Options](#command-line-options)
|
||||
6. [Compiling](#compiling)
|
||||
7. [Docker](#docker)
|
||||
8. [Version Scheme](#version-scheme)
|
||||
|
||||
|
||||
Further documentation
|
||||
----------------------
|
||||
- Website: http://minetest.net/
|
||||
- Wiki: http://wiki.minetest.net/
|
||||
- Developer wiki: http://dev.minetest.net/
|
||||
- Forum: http://forum.minetest.net/
|
||||
- GitHub: https://github.com/minetest/minetest/
|
||||
- [doc/](doc/) directory of source distribution
|
||||
|
||||
Default controls
|
||||
----------------
|
||||
All controls are re-bindable using settings.
|
||||
Some can be changed in the key config dialog in the settings tab.
|
||||
|
||||
| Button | Action |
|
||||
|-------------------------------|----------------------------------------------------------------|
|
||||
| Move mouse | Look around |
|
||||
| W, A, S, D | Move |
|
||||
| Space | Jump/move up |
|
||||
| Shift | Sneak/move down |
|
||||
| Q | Drop itemstack |
|
||||
| Shift + Q | Drop single item |
|
||||
| Left mouse button | Dig/punch/take item |
|
||||
| Right mouse button | Place/use |
|
||||
| Shift + right mouse button | Build (without using) |
|
||||
| I | Inventory menu |
|
||||
| Mouse wheel | Select item |
|
||||
| 0-9 | Select item |
|
||||
| Z | Zoom (needs zoom privilege) |
|
||||
| T | Chat |
|
||||
| / | Command |
|
||||
| Esc | Pause menu/abort/exit (pauses only singleplayer game) |
|
||||
| R | Enable/disable full range view |
|
||||
| + | Increase view range |
|
||||
| - | Decrease view range |
|
||||
| K | Enable/disable fly mode (needs fly privilege) |
|
||||
| L | Enable/disable pitch move mode |
|
||||
| J | Enable/disable fast mode (needs fast privilege) |
|
||||
| H | Enable/disable noclip mode (needs noclip privilege) |
|
||||
| E | Move fast in fast mode |
|
||||
| F1 | Hide/show HUD |
|
||||
| F2 | Hide/show chat |
|
||||
| F3 | Disable/enable fog |
|
||||
| F4 | Disable/enable camera update (Mapblocks are not updated anymore when disabled, disabled in release builds) |
|
||||
| F5 | Cycle through debug information screens |
|
||||
| F6 | Cycle through profiler info screens |
|
||||
| F7 | Cycle through camera modes |
|
||||
| F9 | Cycle through minimap modes |
|
||||
| Shift + F9 | Change minimap orientation |
|
||||
| F10 | Show/hide console |
|
||||
| F12 | Take screenshot |
|
||||
|
||||
Paths
|
||||
-----
|
||||
Locations:
|
||||
|
||||
* `bin` - Compiled binaries
|
||||
* `share` - Distributed read-only data
|
||||
* `user` - User-created modifiable data
|
||||
|
||||
Where each location is on each platform:
|
||||
|
||||
* Windows .zip / RUN_IN_PLACE source:
|
||||
* bin = `bin`
|
||||
* share = `.`
|
||||
* user = `.`
|
||||
* Windows installed:
|
||||
* $bin = `C:\Program Files\Minetest\bin (Depends on the install location)`
|
||||
* $share = `C:\Program Files\Minetest (Depends on the install location)`
|
||||
* $user = `%Appdata%\Minetest`
|
||||
* Linux installed:
|
||||
* `bin` = `/usr/bin`
|
||||
* `share` = `/usr/share/minetest`
|
||||
* `user` = `~/.minetest`
|
||||
* macOS:
|
||||
* `bin` = `Contents/MacOS`
|
||||
* `share` = `Contents/Resources`
|
||||
* `user` = `Contents/User OR ~/Library/Application Support/minetest`
|
||||
|
||||
Worlds can be found as separate folders in: `user/worlds/`
|
||||
|
||||
Configuration file:
|
||||
-------------------
|
||||
- Default location:
|
||||
`user/minetest.conf`
|
||||
- It is created by Minetest when it is ran the first time.
|
||||
- A specific file can be specified on the command line:
|
||||
`--config <path-to-file>`
|
||||
- A run-in-place build will look for the configuration file in
|
||||
`location_of_exe/../minetest.conf` and also `location_of_exe/../../minetest.conf`
|
||||
|
||||
Command-line options:
|
||||
---------------------
|
||||
- Use `--help`
|
||||
|
||||
Compiling
|
||||
---------
|
||||
### Compiling on GNU/Linux
|
||||
|
||||
#### Dependencies
|
||||
|
||||
| Dependency | Version | Commentary |
|
||||
|------------|---------|------------|
|
||||
| GCC | 4.9+ | Can be replaced with Clang 3.4+ |
|
||||
| CMake | 2.6+ | |
|
||||
| Irrlicht | 1.7.3+ | |
|
||||
| SQLite3 | 3.0+ | |
|
||||
| LuaJIT | 2.0+ | Bundled Lua 5.1 is used if not present |
|
||||
| GMP | 5.0.0+ | Bundled mini-GMP is used if not present |
|
||||
| JsonCPP | 1.0.0+ | Bundled JsonCPP is used if not present |
|
||||
|
||||
For Debian/Ubuntu:
|
||||
|
||||
sudo apt install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev
|
||||
|
||||
For Fedora users:
|
||||
|
||||
sudo dnf install make automake gcc gcc-c++ kernel-devel cmake libcurl-devel openal-soft-devel libvorbis-devel libXxf86vm-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel irrlicht-devel bzip2-libs gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel doxygen spatialindex-devel bzip2-devel
|
||||
|
||||
#### Download
|
||||
|
||||
You can install Git for easily keeping your copy up to date.
|
||||
If you don’t want Git, read below on how to get the source without Git.
|
||||
This is an example for installing Git on Debian/Ubuntu:
|
||||
|
||||
sudo apt install git
|
||||
|
||||
For Fedora users:
|
||||
|
||||
sudo dnf install git
|
||||
|
||||
Download source (this is the URL to the latest of source repository, which might not work at all times) using Git:
|
||||
|
||||
git clone --depth 1 https://github.com/minetest/minetest.git
|
||||
cd minetest
|
||||
|
||||
Download minetest_game (otherwise only the "Minimal development test" game is available) using Git:
|
||||
|
||||
git clone --depth 1 https://github.com/minetest/minetest_game.git games/minetest_game
|
||||
|
||||
Download source, without using Git:
|
||||
|
||||
wget https://github.com/minetest/minetest/archive/master.tar.gz
|
||||
tar xf master.tar.gz
|
||||
cd minetest-master
|
||||
|
||||
Download minetest_game, without using Git:
|
||||
|
||||
cd games/
|
||||
wget https://github.com/minetest/minetest_game/archive/master.tar.gz
|
||||
tar xf master.tar.gz
|
||||
mv minetest_game-master minetest_game
|
||||
cd ..
|
||||
|
||||
#### Build
|
||||
|
||||
Build a version that runs directly from the source directory:
|
||||
|
||||
cmake . -DRUN_IN_PLACE=TRUE
|
||||
make -j <number of processors>
|
||||
|
||||
Run it:
|
||||
|
||||
./bin/minetest
|
||||
|
||||
- Use `cmake . -LH` to see all CMake options and their current state
|
||||
- If you want to install it system-wide (or are making a distribution package),
|
||||
you will want to use `-DRUN_IN_PLACE=FALSE`
|
||||
- You can build a bare server by specifying `-DBUILD_SERVER=TRUE`
|
||||
- You can disable the client build by specifying `-DBUILD_CLIENT=FALSE`
|
||||
- You can select between Release and Debug build by `-DCMAKE_BUILD_TYPE=<Debug or Release>`
|
||||
- Debug build is slower, but gives much more useful output in a debugger
|
||||
- If you build a bare server, you don't need to have Irrlicht installed.
|
||||
- In that case use `-DIRRLICHT_SOURCE_DIR=/the/irrlicht/source`
|
||||
|
||||
### CMake options
|
||||
|
||||
General options and their default values:
|
||||
|
||||
BUILD_CLIENT=TRUE - Build Minetest client
|
||||
BUILD_SERVER=FALSE - Build Minetest server
|
||||
CMAKE_BUILD_TYPE=Release - Type of build (Release vs. Debug)
|
||||
Release - Release build
|
||||
Debug - Debug build
|
||||
SemiDebug - Partially optimized debug build
|
||||
RelWithDebInfo - Release build with debug information
|
||||
MinSizeRel - Release build with -Os passed to compiler to make executable as small as possible
|
||||
ENABLE_CURL=ON - Build with cURL; Enables use of online mod repo, public serverlist and remote media fetching via http
|
||||
ENABLE_CURSES=ON - Build with (n)curses; Enables a server side terminal (command line option: --terminal)
|
||||
ENABLE_FREETYPE=ON - Build with FreeType2; Allows using TTF fonts
|
||||
ENABLE_GETTEXT=ON - Build with Gettext; Allows using translations
|
||||
ENABLE_GLES=OFF - Search for Open GLES headers & libraries and use them
|
||||
ENABLE_LEVELDB=ON - Build with LevelDB; Enables use of LevelDB map backend
|
||||
ENABLE_POSTGRESQL=ON - Build with libpq; Enables use of PostgreSQL map backend (PostgreSQL 9.5 or greater recommended)
|
||||
ENABLE_REDIS=ON - Build with libhiredis; Enables use of Redis map backend
|
||||
ENABLE_SPATIAL=ON - Build with LibSpatial; Speeds up AreaStores
|
||||
ENABLE_SOUND=ON - Build with OpenAL, libogg & libvorbis; in-game sounds
|
||||
ENABLE_LUAJIT=ON - Build with LuaJIT (much faster than non-JIT Lua)
|
||||
ENABLE_SYSTEM_GMP=ON - Use GMP from system (much faster than bundled mini-gmp)
|
||||
ENABLE_SYSTEM_JSONCPP=OFF - Use JsonCPP from system
|
||||
OPENGL_GL_PREFERENCE=LEGACY - Linux client build only; See CMake Policy CMP0072 for reference
|
||||
RUN_IN_PLACE=FALSE - Create a portable install (worlds, settings etc. in current directory)
|
||||
USE_GPROF=FALSE - Enable profiling using GProf
|
||||
VERSION_EXTRA= - Text to append to version (e.g. VERSION_EXTRA=foobar -> Minetest 0.4.9-foobar)
|
||||
|
||||
Library specific options:
|
||||
|
||||
BZIP2_INCLUDE_DIR - Linux only; directory where bzlib.h is located
|
||||
BZIP2_LIBRARY - Linux only; path to libbz2.a/libbz2.so
|
||||
CURL_DLL - Only if building with cURL on Windows; path to libcurl.dll
|
||||
CURL_INCLUDE_DIR - Only if building with cURL; directory where curl.h is located
|
||||
CURL_LIBRARY - Only if building with cURL; path to libcurl.a/libcurl.so/libcurl.lib
|
||||
EGL_INCLUDE_DIR - Only if building with GLES; directory that contains egl.h
|
||||
EGL_LIBRARY - Only if building with GLES; path to libEGL.a/libEGL.so
|
||||
FREETYPE_INCLUDE_DIR_freetype2 - Only if building with FreeType 2; directory that contains an freetype directory with files such as ftimage.h in it
|
||||
FREETYPE_INCLUDE_DIR_ft2build - Only if building with FreeType 2; directory that contains ft2build.h
|
||||
FREETYPE_LIBRARY - Only if building with FreeType 2; path to libfreetype.a/libfreetype.so/freetype.lib
|
||||
FREETYPE_DLL - Only if building with FreeType 2 on Windows; path to libfreetype.dll
|
||||
GETTEXT_DLL - Only when building with gettext on Windows; path to libintl3.dll
|
||||
GETTEXT_ICONV_DLL - Only when building with gettext on Windows; path to libiconv2.dll
|
||||
GETTEXT_INCLUDE_DIR - Only when building with gettext; directory that contains iconv.h
|
||||
GETTEXT_LIBRARY - Only when building with gettext on Windows; path to libintl.dll.a
|
||||
GETTEXT_MSGFMT - Only when building with gettext; path to msgfmt/msgfmt.exe
|
||||
IRRLICHT_DLL - Only on Windows; path to Irrlicht.dll
|
||||
IRRLICHT_INCLUDE_DIR - Directory that contains IrrCompileConfig.h
|
||||
IRRLICHT_LIBRARY - Path to libIrrlicht.a/libIrrlicht.so/libIrrlicht.dll.a/Irrlicht.lib
|
||||
LEVELDB_INCLUDE_DIR - Only when building with LevelDB; directory that contains db.h
|
||||
LEVELDB_LIBRARY - Only when building with LevelDB; path to libleveldb.a/libleveldb.so/libleveldb.dll.a
|
||||
LEVELDB_DLL - Only when building with LevelDB on Windows; path to libleveldb.dll
|
||||
PostgreSQL_INCLUDE_DIR - Only when building with PostgreSQL; directory that contains libpq-fe.h
|
||||
POSTGRESQL_LIBRARY - Only when building with PostgreSQL; path to libpq.a/libpq.so
|
||||
REDIS_INCLUDE_DIR - Only when building with Redis; directory that contains hiredis.h
|
||||
REDIS_LIBRARY - Only when building with Redis; path to libhiredis.a/libhiredis.so
|
||||
SPATIAL_INCLUDE_DIR - Only when building with LibSpatial; directory that contains spatialindex/SpatialIndex.h
|
||||
SPATIAL_LIBRARY - Only when building with LibSpatial; path to libspatialindex_c.so/spatialindex-32.lib
|
||||
LUA_INCLUDE_DIR - Only if you want to use LuaJIT; directory where luajit.h is located
|
||||
LUA_LIBRARY - Only if you want to use LuaJIT; path to libluajit.a/libluajit.so
|
||||
MINGWM10_DLL - Only if compiling with MinGW; path to mingwm10.dll
|
||||
OGG_DLL - Only if building with sound on Windows; path to libogg.dll
|
||||
OGG_INCLUDE_DIR - Only if building with sound; directory that contains an ogg directory which contains ogg.h
|
||||
OGG_LIBRARY - Only if building with sound; path to libogg.a/libogg.so/libogg.dll.a
|
||||
OPENAL_DLL - Only if building with sound on Windows; path to OpenAL32.dll
|
||||
OPENAL_INCLUDE_DIR - Only if building with sound; directory where al.h is located
|
||||
OPENAL_LIBRARY - Only if building with sound; path to libopenal.a/libopenal.so/OpenAL32.lib
|
||||
OPENGLES2_INCLUDE_DIR - Only if building with GLES; directory that contains gl2.h
|
||||
OPENGLES2_LIBRARY - Only if building with GLES; path to libGLESv2.a/libGLESv2.so
|
||||
SQLITE3_INCLUDE_DIR - Directory that contains sqlite3.h
|
||||
SQLITE3_LIBRARY - Path to libsqlite3.a/libsqlite3.so/sqlite3.lib
|
||||
VORBISFILE_DLL - Only if building with sound on Windows; path to libvorbisfile-3.dll
|
||||
VORBISFILE_LIBRARY - Only if building with sound; path to libvorbisfile.a/libvorbisfile.so/libvorbisfile.dll.a
|
||||
VORBIS_DLL - Only if building with sound on Windows; path to libvorbis-0.dll
|
||||
VORBIS_INCLUDE_DIR - Only if building with sound; directory that contains a directory vorbis with vorbisenc.h inside
|
||||
VORBIS_LIBRARY - Only if building with sound; path to libvorbis.a/libvorbis.so/libvorbis.dll.a
|
||||
XXF86VM_LIBRARY - Only on Linux; path to libXXf86vm.a/libXXf86vm.so
|
||||
ZLIB_DLL - Only on Windows; path to zlib1.dll
|
||||
ZLIBWAPI_DLL - Only on Windows; path to zlibwapi.dll
|
||||
ZLIB_INCLUDE_DIR - Directory that contains zlib.h
|
||||
ZLIB_LIBRARY - Path to libz.a/libz.so/zlibwapi.lib
|
||||
|
||||
### Compiling on Windows
|
||||
|
||||
* This section is outdated. In addition to what is described here:
|
||||
* In addition to minetest, you need to download [minetest_game](https://github.com/minetest/minetest_game).
|
||||
* If you wish to have sound support, you need libogg, libvorbis and libopenal
|
||||
|
||||
* You need:
|
||||
* CMake:
|
||||
http://www.cmake.org/cmake/resources/software.html
|
||||
* A compiler
|
||||
* MinGW: http://www.mingw.org/
|
||||
* or Visual Studio: http://msdn.microsoft.com/en-us/vstudio/default
|
||||
* Irrlicht SDK 1.7:
|
||||
http://irrlicht.sourceforge.net/downloads.html
|
||||
* Zlib headers (zlib125.zip)
|
||||
http://www.winimage.com/zLibDll/index.html
|
||||
* Zlib library (zlibwapi.lib and zlibwapi.dll from zlib125dll.zip):
|
||||
http://www.winimage.com/zLibDll/index.html
|
||||
* SQLite3 headers and library
|
||||
https://www.sqlite.org/download.html
|
||||
* Optional: gettext library and tools:
|
||||
http://gnuwin32.sourceforge.net/downlinks/gettext.php
|
||||
* This is used for other UI languages. Feel free to leave it out.
|
||||
* And, of course, Minetest:
|
||||
http://minetest.net/download
|
||||
* Steps:
|
||||
* Select a directory called DIR hereafter in which you will operate.
|
||||
* Make sure you have CMake and a compiler installed.
|
||||
* Download all the other stuff to DIR and extract them into there.
|
||||
("extract here", not "extract to packagename/")
|
||||
* NOTE: zlib125dll.zip needs to be extracted into zlib125dll
|
||||
* NOTE: You need to extract sqlite3.h & sqlite3ext.h from the SQLite 3
|
||||
source and sqlite3.dll & sqlite3.def from the SQLite 3 precompiled
|
||||
binaries into "sqlite3" directory, and generate sqlite3.lib using
|
||||
command "LIB /DEF:sqlite3.def /OUT:sqlite3.lib"
|
||||
* All those packages contain a nice base directory in them, which
|
||||
should end up being the direct subdirectories of DIR.
|
||||
* You will end up with a directory structure like this (+=dir, -=file):
|
||||
-----------------
|
||||
+ DIR
|
||||
* zlib-1.2.5.tar.gz
|
||||
* zlib125dll.zip
|
||||
* irrlicht-1.8.3.zip
|
||||
* sqlite-amalgamation-3130000.zip (SQLite3 headers)
|
||||
* sqlite-dll-win32-x86-3130000.zip (SQLite3 library for 32bit system)
|
||||
* 110214175330.zip (or whatever, this is the minetest source)
|
||||
+ zlib-1.2.5
|
||||
* zlib.h
|
||||
+ win32
|
||||
...
|
||||
+ zlib125dll
|
||||
* readme.txt
|
||||
+ dll32
|
||||
...
|
||||
+ irrlicht-1.8.3
|
||||
+ lib
|
||||
+ include
|
||||
...
|
||||
+ sqlite3
|
||||
sqlite3.h
|
||||
sqlite3ext.h
|
||||
sqlite3.lib
|
||||
sqlite3.dll
|
||||
+ gettext (optional)
|
||||
+bin
|
||||
+include
|
||||
+lib
|
||||
+ minetest
|
||||
+ src
|
||||
+ doc
|
||||
* CMakeLists.txt
|
||||
...
|
||||
-----------------
|
||||
* Start up the CMake GUI
|
||||
* Select "Browse Source..." and select DIR/minetest
|
||||
* Now, if using MSVC:
|
||||
* Select "Browse Build..." and select DIR/minetest-build
|
||||
* Else if using MinGW:
|
||||
* Select "Browse Build..." and select DIR/minetest
|
||||
* Select "Configure"
|
||||
* Select your compiler
|
||||
* It will warn about missing stuff, ignore that at this point. (later don't)
|
||||
* Make sure the configuration is as follows
|
||||
(note that the versions may differ for you):
|
||||
|
||||
BUILD_CLIENT [X]
|
||||
BUILD_SERVER [ ]
|
||||
CMAKE_BUILD_TYPE Release
|
||||
CMAKE_INSTALL_PREFIX DIR/minetest-install
|
||||
IRRLICHT_SOURCE_DIR DIR/irrlicht-1.8.3
|
||||
RUN_IN_PLACE [X]
|
||||
WARN_ALL [ ]
|
||||
ZLIB_DLL DIR/zlib125dll/dll32/zlibwapi.dll
|
||||
ZLIB_INCLUDE_DIR DIR/zlib-1.2.5
|
||||
ZLIB_LIBRARIES DIR/zlib125dll/dll32/zlibwapi.lib
|
||||
GETTEXT_BIN_DIR DIR/gettext/bin
|
||||
GETTEXT_INCLUDE_DIR DIR/gettext/include
|
||||
GETTEXT_LIBRARIES DIR/gettext/lib/intl.lib
|
||||
GETTEXT_MSGFMT DIR/gettext/bin/msgfmt
|
||||
|
||||
* If CMake complains it couldn't find SQLITE3, choose "Advanced" box on the
|
||||
right top corner, then specify the location of SQLITE3_INCLUDE_DIR and
|
||||
SQLITE3_LIBRARY manually.
|
||||
* If you want to build 64-bit minetest, you will need to build 64-bit version
|
||||
of irrlicht engine manually, as only 32-bit pre-built library is provided.
|
||||
* Hit "Configure"
|
||||
* Hit "Configure" once again 8)
|
||||
* If something is still coloured red, you have a problem.
|
||||
* Hit "Generate"
|
||||
If using MSVC:
|
||||
* Open the generated minetest.sln
|
||||
* The project defaults to the "Debug" configuration. Make very sure to
|
||||
select "Release", unless you want to debug some stuff (it's slower
|
||||
and might not even work at all)
|
||||
* Build the ALL_BUILD project
|
||||
* Build the INSTALL project
|
||||
* You should now have a working game with the executable in
|
||||
DIR/minetest-install/bin/minetest.exe
|
||||
* Additionally you may create a zip package by building the PACKAGE
|
||||
project.
|
||||
If using MinGW:
|
||||
* Using the command line, browse to the build directory and run 'make'
|
||||
(or mingw32-make or whatever it happens to be)
|
||||
* You may need to copy some of the downloaded DLLs into bin/, see what
|
||||
running the produced executable tells you it doesn't have.
|
||||
* You should now have a working game with the executable in
|
||||
DIR/minetest/bin/minetest.exe
|
||||
|
||||
### Bat script to build Windows releases of Minetest
|
||||
|
||||
This is how we build Windows releases.
|
||||
|
||||
set sourcedir=%CD%
|
||||
set installpath="C:\tmp\minetest_install"
|
||||
set irrlichtpath="C:\tmp\irrlicht-1.7.2"
|
||||
|
||||
set builddir=%sourcedir%\bvc10
|
||||
mkdir %builddir%
|
||||
pushd %builddir%
|
||||
cmake %sourcedir% -G "Visual Studio 10" -DIRRLICHT_SOURCE_DIR=%irrlichtpath% -DRUN_IN_PLACE=TRUE -DCMAKE_INSTALL_PREFIX=%installpath%
|
||||
if %errorlevel% neq 0 goto fail
|
||||
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration=Release
|
||||
if %errorlevel% neq 0 goto fail
|
||||
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" INSTALL.vcxproj /p:Configuration=Release
|
||||
if %errorlevel% neq 0 goto fail
|
||||
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" PACKAGE.vcxproj /p:Configuration=Release
|
||||
if %errorlevel% neq 0 goto fail
|
||||
popd
|
||||
echo Finished.
|
||||
exit /b 0
|
||||
|
||||
:fail
|
||||
popd
|
||||
echo Failed.
|
||||
exit /b 1
|
||||
|
||||
### Windows Installer using WIX Toolset
|
||||
|
||||
Requirements:
|
||||
* Visual Studio 2017
|
||||
* Wix Toolset
|
||||
|
||||
In Visual Studio 2017 Installer select "Optional Features" -> "Wix Toolset"
|
||||
|
||||
Build the binaries like described above, but make sure you unselect "RUN_IN_PLACE".
|
||||
|
||||
Open the generated Project file with VS. Right click "PACKAGE" and choose "Generate".
|
||||
It may take some minutes to generate the installer.
|
||||
|
||||
|
||||
Docker
|
||||
------
|
||||
We provide Minetest server docker images using the Gitlab mirror registry.
|
||||
|
||||
Images are built on each commit and available using the following tag scheme:
|
||||
|
||||
* `registry.gitlab.com/minetest/minetest/server:latest` (latest build)
|
||||
* `registry.gitlab.com/minetest/minetest/server:<branch/tag>` (current branch or current tag)
|
||||
* `registry.gitlab.com/minetest/minetest/server:<commit-id>` (current commit id)
|
||||
|
||||
If you want to test it on a docker server, you can easily run:
|
||||
|
||||
sudo docker run registry.gitlab.com/minetest/minetest/server:<docker tag>
|
||||
|
||||
If you want to use it in a production environment you should use volumes bound to the docker host
|
||||
to persist data and modify the configuration:
|
||||
|
||||
sudo docker create -v /home/minetest/data/:/var/lib/minetest/ -v /home/minetest/conf/:/etc/minetest/ registry.gitlab.com/minetest/minetest/server:master
|
||||
|
||||
Data will be written to `/home/minetest/data` on the host, and configuration will be read from `/home/minetest/conf/minetest.conf`.
|
||||
|
||||
Note: If you don't understand the previous commands, please read the official Docker documentation before use.
|
||||
|
||||
You can also host your minetest server inside a Kubernetes cluster. See our example implementation in `misc/kubernetes.yml`.
|
||||
|
||||
|
||||
Version scheme
|
||||
--------------
|
||||
We use `major.minor.patch` since 5.0.0-dev. Prior to that we used `0.major.minor`.
|
||||
|
||||
- Major is incremented when the release contains breaking changes, all other
|
||||
numbers are set to 0.
|
||||
- Minor is incremented when the release contains new non-breaking features,
|
||||
patch is set to 0.
|
||||
- Patch is incremented when the release only contains bugfixes and very
|
||||
minor/trivial features considered necessary.
|
||||
|
||||
Since 5.0.0-dev and 0.4.17-dev, the dev notation refers to the next release,
|
||||
i.e.: 5.0.0-dev is the development version leading to 5.0.0.
|
||||
Prior to that we used `previous_version-dev`.
|
557
doc/README.txt
|
@ -1,557 +0,0 @@
|
|||
Minetest
|
||||
========
|
||||
|
||||
An InfiniMiner/Minecraft inspired game.
|
||||
|
||||
Copyright (c) 2010-2017 Perttu Ahola <celeron55@gmail.com>
|
||||
and contributors (see source file comments and the version control log)
|
||||
|
||||
In case you downloaded the source code:
|
||||
---------------------------------------
|
||||
If you downloaded the Minetest Engine source code in which this file is
|
||||
contained, you probably want to download the minetest_game project too:
|
||||
https://github.com/minetest/minetest_game/
|
||||
See the README.txt in it.
|
||||
|
||||
Further documentation
|
||||
----------------------
|
||||
- Website: http://minetest.net/
|
||||
- Wiki: http://wiki.minetest.net/
|
||||
- Developer wiki: http://dev.minetest.net/
|
||||
- Forum: http://forum.minetest.net/
|
||||
- Github: https://github.com/minetest/minetest/
|
||||
- doc/ directory of source distribution
|
||||
|
||||
This game is not finished
|
||||
--------------------------
|
||||
- Don't expect it to work as well as a finished game will.
|
||||
- Please report any bugs. When doing that, debug.txt is useful.
|
||||
|
||||
Default controls
|
||||
-----------------
|
||||
- Move mouse: Look around
|
||||
- W, A, S, D: Move
|
||||
- Space: Jump/move up
|
||||
- Shift: Sneak/move down
|
||||
- Q: Drop itemstack
|
||||
- Shift + Q: Drop single item
|
||||
- Left mouse button: Dig/punch/take item
|
||||
- Right mouse button: Place/use
|
||||
- Shift + right mouse button: Build (without using)
|
||||
- I: Inventory menu
|
||||
- Mouse wheel: Select item
|
||||
- 0-9: Select item
|
||||
- Z: Zoom (needs zoom privilege)
|
||||
- T: Chat
|
||||
- /: Command
|
||||
|
||||
- Esc: Pause menu/abort/exit (pauses only singleplayer game)
|
||||
- R: Enable/disable full range view
|
||||
- +: Increase view range
|
||||
- -: Decrease view range
|
||||
- K: Enable/disable fly mode (needs fly privilege)
|
||||
- J: Enable/disable fast mode (needs fast privilege)
|
||||
- H: Enable/disable noclip mode (needs noclip privilege)
|
||||
|
||||
- F1: Hide/show HUD
|
||||
- F2: Hide/show chat
|
||||
- F3: Disable/enable fog
|
||||
- F4: Disable/enable camera update (Mapblocks are not updated anymore when disabled, disabled in release builds)
|
||||
- F5: Cycle through debug info screens
|
||||
- F6: Cycle through profiler info screens
|
||||
- F7: Cycle through camera modes
|
||||
- F8: Toggle cinematic mode
|
||||
- F9: Cycle through minimap modes
|
||||
- Shift + F9: Change minimap orientation
|
||||
- F10: Show/hide console
|
||||
- F12: Take screenshot
|
||||
- P: Write stack traces into debug.txt
|
||||
|
||||
Most controls are settable in the configuration file, see the section below.
|
||||
|
||||
Paths
|
||||
------
|
||||
$bin - Compiled binaries
|
||||
$share - Distributed read-only data
|
||||
$user - User-created modifiable data
|
||||
|
||||
Windows .zip / RUN_IN_PLACE source:
|
||||
$bin = bin
|
||||
$share = .
|
||||
$user = .
|
||||
|
||||
Linux installed:
|
||||
$bin = /usr/bin
|
||||
$share = /usr/share/minetest
|
||||
$user = ~/.minetest
|
||||
|
||||
macOS:
|
||||
$bin = Contents/MacOS
|
||||
$share = Contents/Resources
|
||||
$user = Contents/User OR ~/Library/Application Support/minetest
|
||||
|
||||
World directory
|
||||
----------------
|
||||
- Worlds can be found as separate folders in:
|
||||
$user/worlds/
|
||||
|
||||
Configuration file:
|
||||
-------------------
|
||||
- Default location:
|
||||
$user/minetest.conf
|
||||
- It is created by Minetest when it is ran the first time.
|
||||
- A specific file can be specified on the command line:
|
||||
--config <path-to-file>
|
||||
- A run-in-place build will look for the configuration file in
|
||||
$location_of_exe/../minetest.conf and also $location_of_exe/../../minetest.conf
|
||||
|
||||
Command-line options:
|
||||
---------------------
|
||||
- Use --help
|
||||
|
||||
Compiling on GNU/Linux:
|
||||
-----------------------
|
||||
|
||||
Install dependencies. Here's an example for Debian/Ubuntu:
|
||||
$ sudo apt-get install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev
|
||||
|
||||
For Fedora users:
|
||||
$ sudo dnf install make automake gcc gcc-c++ kernel-devel cmake libcurl* openal* libvorbis* libXxf86vm-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel irrlicht-devel bzip2-libs gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel doxygen spatialindex-devel bzip2-devel
|
||||
|
||||
You can install git for easily keeping your copy up to date.
|
||||
If you don’t want git, read below on how to get the source without git.
|
||||
This is an example for installing git on Debian/Ubuntu:
|
||||
$ sudo apt-get install git
|
||||
|
||||
For Fedora users:
|
||||
$ sudo dnf install git
|
||||
|
||||
Download source (this is the URL to the latest of source repository, which might not work at all times) using git:
|
||||
$ git clone --depth 1 https://github.com/minetest/minetest.git
|
||||
$ cd minetest
|
||||
|
||||
Download minetest_game (otherwise only the "Minimal development test" game is available) using git:
|
||||
$ git clone --depth 1 https://github.com/minetest/minetest_game.git games/minetest_game
|
||||
|
||||
Download source, without using git:
|
||||
$ wget https://github.com/minetest/minetest/archive/master.tar.gz
|
||||
$ tar xf master.tar.gz
|
||||
$ cd minetest-master
|
||||
|
||||
Download minetest_game, without using git:
|
||||
$ cd games/
|
||||
$ wget https://github.com/minetest/minetest_game/archive/master.tar.gz
|
||||
$ tar xf master.tar.gz
|
||||
$ mv minetest_game-master minetest_game
|
||||
$ cd ..
|
||||
|
||||
Build a version that runs directly from the source directory:
|
||||
$ cmake . -DRUN_IN_PLACE=TRUE
|
||||
$ make -j <number of processors>
|
||||
|
||||
Run it:
|
||||
$ ./bin/minetest
|
||||
|
||||
- Use cmake . -LH to see all CMake options and their current state
|
||||
- If you want to install it system-wide (or are making a distribution package),
|
||||
you will want to use -DRUN_IN_PLACE=FALSE
|
||||
- You can build a bare server by specifying -DBUILD_SERVER=TRUE
|
||||
- You can disable the client build by specifying -DBUILD_CLIENT=FALSE
|
||||
- You can select between Release and Debug build by -DCMAKE_BUILD_TYPE=<Debug or Release>
|
||||
- Debug build is slower, but gives much more useful output in a debugger
|
||||
- If you build a bare server, you don't need to have Irrlicht installed.
|
||||
In that case use -DIRRLICHT_SOURCE_DIR=/the/irrlicht/source
|
||||
|
||||
CMake options
|
||||
-------------
|
||||
General options:
|
||||
|
||||
BUILD_CLIENT - Build Minetest client
|
||||
BUILD_SERVER - Build Minetest server
|
||||
CMAKE_BUILD_TYPE - Type of build (Release vs. Debug)
|
||||
Release - Release build
|
||||
Debug - Debug build
|
||||
SemiDebug - Partially optimized debug build
|
||||
RelWithDebInfo - Release build with Debug information
|
||||
MinSizeRel - Release build with -Os passed to compiler to make executable as small as possible
|
||||
ENABLE_CURL - Build with cURL; Enables use of online mod repo, public serverlist and remote media fetching via http
|
||||
ENABLE_CURSES - Build with (n)curses; Enables a server side terminal (command line option: --terminal)
|
||||
ENABLE_FREETYPE - Build with FreeType2; Allows using TTF fonts
|
||||
ENABLE_GETTEXT - Build with Gettext; Allows using translations
|
||||
ENABLE_GLES - Search for Open GLES headers & libraries and use them
|
||||
ENABLE_LEVELDB - Build with LevelDB; Enables use of LevelDB map backend
|
||||
ENABLE_POSTGRESQL - Build with libpq; Enables use of PostgreSQL map backend (PostgreSQL 9.5 or greater recommended)
|
||||
ENABLE_REDIS - Build with libhiredis; Enables use of Redis map backend
|
||||
ENABLE_SPATIAL - Build with LibSpatial; Speeds up AreaStores
|
||||
ENABLE_SOUND - Build with OpenAL, libogg & libvorbis; in-game Sounds
|
||||
ENABLE_LUAJIT - Build with LuaJIT (much faster than non-JIT Lua)
|
||||
ENABLE_SYSTEM_GMP - Use GMP from system (much faster than bundled mini-gmp)
|
||||
RUN_IN_PLACE - Create a portable install (worlds, settings etc. in current directory)
|
||||
USE_GPROF - Enable profiling using GProf
|
||||
VERSION_EXTRA - Text to append to version (e.g. VERSION_EXTRA=foobar -> Minetest 0.4.9-foobar)
|
||||
|
||||
Library specific options:
|
||||
|
||||
BZIP2_INCLUDE_DIR - Linux only; directory where bzlib.h is located
|
||||
BZIP2_LIBRARY - Linux only; path to libbz2.a/libbz2.so
|
||||
CURL_DLL - Only if building with cURL on Windows; path to libcurl.dll
|
||||
CURL_INCLUDE_DIR - Only if building with cURL; directory where curl.h is located
|
||||
CURL_LIBRARY - Only if building with cURL; path to libcurl.a/libcurl.so/libcurl.lib
|
||||
EGL_INCLUDE_DIR - Only if building with GLES; directory that contains egl.h
|
||||
EGL_LIBRARY - Only if building with GLES; path to libEGL.a/libEGL.so
|
||||
FREETYPE_INCLUDE_DIR_freetype2 - Only if building with Freetype2; directory that contains an freetype directory with files such as ftimage.h in it
|
||||
FREETYPE_INCLUDE_DIR_ft2build - Only if building with Freetype2; directory that contains ft2build.h
|
||||
FREETYPE_LIBRARY - Only if building with Freetype2; path to libfreetype.a/libfreetype.so/freetype.lib
|
||||
FREETYPE_DLL - Only if building with Freetype2 on Windows; path to libfreetype.dll
|
||||
GETTEXT_DLL - Only when building with Gettext on Windows; path to libintl3.dll
|
||||
GETTEXT_ICONV_DLL - Only when building with Gettext on Windows; path to libiconv2.dll
|
||||
GETTEXT_INCLUDE_DIR - Only when building with Gettext; directory that contains iconv.h
|
||||
GETTEXT_LIBRARY - Only when building with Gettext on Windows; path to libintl.dll.a
|
||||
GETTEXT_MSGFMT - Only when building with Gettext; path to msgfmt/msgfmt.exe
|
||||
IRRLICHT_DLL - Only on Windows; path to Irrlicht.dll
|
||||
IRRLICHT_INCLUDE_DIR - Directory that contains IrrCompileConfig.h
|
||||
IRRLICHT_LIBRARY - Path to libIrrlicht.a/libIrrlicht.so/libIrrlicht.dll.a/Irrlicht.lib
|
||||
LEVELDB_INCLUDE_DIR - Only when building with LevelDB; directory that contains db.h
|
||||
LEVELDB_LIBRARY - Only when building with LevelDB; path to libleveldb.a/libleveldb.so/libleveldb.dll.a
|
||||
LEVELDB_DLL - Only when building with LevelDB on Windows; path to libleveldb.dll
|
||||
PostgreSQL_INCLUDE_DIR - Only when building with PostgreSQL; directory that contains libpq-fe.h
|
||||
POSTGRESQL_LIBRARY - Only when building with PostgreSQL; path to libpq.a/libpq.so
|
||||
REDIS_INCLUDE_DIR - Only when building with Redis; directory that contains hiredis.h
|
||||
REDIS_LIBRARY - Only when building with Redis; path to libhiredis.a/libhiredis.so
|
||||
SPATIAL_INCLUDE_DIR - Only when building with LibSpatial; directory that contains spatialindex/SpatialIndex.h
|
||||
SPATIAL_LIBRARY - Only when building with LibSpatial; path to libspatialindex_c.so/spatialindex-32.lib
|
||||
LUA_INCLUDE_DIR - Only if you want to use LuaJIT; directory where luajit.h is located
|
||||
LUA_LIBRARY - Only if you want to use LuaJIT; path to libluajit.a/libluajit.so
|
||||
MINGWM10_DLL - Only if compiling with MinGW; path to mingwm10.dll
|
||||
OGG_DLL - Only if building with sound on Windows; path to libogg.dll
|
||||
OGG_INCLUDE_DIR - Only if building with sound; directory that contains an ogg directory which contains ogg.h
|
||||
OGG_LIBRARY - Only if building with sound; path to libogg.a/libogg.so/libogg.dll.a
|
||||
OPENAL_DLL - Only if building with sound on Windows; path to OpenAL32.dll
|
||||
OPENAL_INCLUDE_DIR - Only if building with sound; directory where al.h is located
|
||||
OPENAL_LIBRARY - Only if building with sound; path to libopenal.a/libopenal.so/OpenAL32.lib
|
||||
OPENGLES2_INCLUDE_DIR - Only if building with GLES; directory that contains gl2.h
|
||||
OPENGLES2_LIBRARY - Only if building with GLES; path to libGLESv2.a/libGLESv2.so
|
||||
SQLITE3_INCLUDE_DIR - Directory that contains sqlite3.h
|
||||
SQLITE3_LIBRARY - Path to libsqlite3.a/libsqlite3.so/sqlite3.lib
|
||||
VORBISFILE_DLL - Only if building with sound on Windows; path to libvorbisfile-3.dll
|
||||
VORBISFILE_LIBRARY - Only if building with sound; path to libvorbisfile.a/libvorbisfile.so/libvorbisfile.dll.a
|
||||
VORBIS_DLL - Only if building with sound on Windows; path to libvorbis-0.dll
|
||||
VORBIS_INCLUDE_DIR - Only if building with sound; directory that contains a directory vorbis with vorbisenc.h inside
|
||||
VORBIS_LIBRARY - Only if building with sound; path to libvorbis.a/libvorbis.so/libvorbis.dll.a
|
||||
XXF86VM_LIBRARY - Only on Linux; path to libXXf86vm.a/libXXf86vm.so
|
||||
ZLIB_DLL - Only on Windows; path to zlib1.dll
|
||||
ZLIBWAPI_DLL - Only on Windows; path to zlibwapi.dll
|
||||
ZLIB_INCLUDE_DIR - Directory that contains zlib.h
|
||||
ZLIB_LIBRARY - Path to libz.a/libz.so/zlibwapi.lib
|
||||
|
||||
Compiling on Windows:
|
||||
---------------------
|
||||
- This section is outdated. In addition to what is described here:
|
||||
- In addition to minetest, you need to download minetest_game.
|
||||
- If you wish to have sound support, you need libogg, libvorbis and libopenal
|
||||
|
||||
- You need:
|
||||
* CMake:
|
||||
http://www.cmake.org/cmake/resources/software.html
|
||||
* MinGW or Visual Studio
|
||||
http://www.mingw.org/
|
||||
http://msdn.microsoft.com/en-us/vstudio/default
|
||||
* Irrlicht SDK 1.7:
|
||||
http://irrlicht.sourceforge.net/downloads.html
|
||||
* Zlib headers (zlib125.zip)
|
||||
http://www.winimage.com/zLibDll/index.html
|
||||
* Zlib library (zlibwapi.lib and zlibwapi.dll from zlib125dll.zip):
|
||||
http://www.winimage.com/zLibDll/index.html
|
||||
* SQLite3 headers and library
|
||||
https://www.sqlite.org/download.html
|
||||
* Optional: gettext library and tools:
|
||||
http://gnuwin32.sourceforge.net/downlinks/gettext.php
|
||||
- This is used for other UI languages. Feel free to leave it out.
|
||||
* And, of course, Minetest:
|
||||
http://minetest.net/download
|
||||
- Steps:
|
||||
- Select a directory called DIR hereafter in which you will operate.
|
||||
- Make sure you have CMake and a compiler installed.
|
||||
- Download all the other stuff to DIR and extract them into there.
|
||||
("extract here", not "extract to packagename/")
|
||||
NOTE: zlib125dll.zip needs to be extracted into zlib125dll
|
||||
NOTE: You need to extract sqlite3.h & sqlite3ext.h from sqlite3 source
|
||||
and sqlite3.dll & sqlite3.def from sqlite3 precompiled binaries
|
||||
into "sqlite3" directory, and generate sqlite3.lib using command
|
||||
"LIB /DEF:sqlite3.def /OUT:sqlite3.lib"
|
||||
- All those packages contain a nice base directory in them, which
|
||||
should end up being the direct subdirectories of DIR.
|
||||
- You will end up with a directory structure like this (+=dir, -=file):
|
||||
-----------------
|
||||
+ DIR
|
||||
- zlib-1.2.5.tar.gz
|
||||
- zlib125dll.zip
|
||||
- irrlicht-1.8.3.zip
|
||||
- sqlite-amalgamation-3130000.zip (SQLite3 headers)
|
||||
- sqlite-dll-win32-x86-3130000.zip (SQLite3 library for 32bit system)
|
||||
- 110214175330.zip (or whatever, this is the minetest source)
|
||||
+ zlib-1.2.5
|
||||
- zlib.h
|
||||
+ win32
|
||||
...
|
||||
+ zlib125dll
|
||||
- readme.txt
|
||||
+ dll32
|
||||
...
|
||||
+ irrlicht-1.8.3
|
||||
+ lib
|
||||
+ include
|
||||
...
|
||||
+ sqlite3
|
||||
sqlite3.h
|
||||
sqlite3ext.h
|
||||
sqlite3.lib
|
||||
sqlite3.dll
|
||||
+ gettext (optional)
|
||||
+bin
|
||||
+include
|
||||
+lib
|
||||
+ minetest
|
||||
+ src
|
||||
+ doc
|
||||
- CMakeLists.txt
|
||||
...
|
||||
-----------------
|
||||
- Start up the CMake GUI
|
||||
- Select "Browse Source..." and select DIR/minetest
|
||||
- Now, if using MSVC:
|
||||
- Select "Browse Build..." and select DIR/minetest-build
|
||||
- Else if using MinGW:
|
||||
- Select "Browse Build..." and select DIR/minetest
|
||||
- Select "Configure"
|
||||
- Select your compiler
|
||||
- It will warn about missing stuff, ignore that at this point. (later don't)
|
||||
- Make sure the configuration is as follows
|
||||
(note that the versions may differ for you):
|
||||
-----------------
|
||||
BUILD_CLIENT [X]
|
||||
BUILD_SERVER [ ]
|
||||
CMAKE_BUILD_TYPE Release
|
||||
CMAKE_INSTALL_PREFIX DIR/minetest-install
|
||||
IRRLICHT_SOURCE_DIR DIR/irrlicht-1.8.3
|
||||
RUN_IN_PLACE [X]
|
||||
WARN_ALL [ ]
|
||||
ZLIB_DLL DIR/zlib125dll/dll32/zlibwapi.dll
|
||||
ZLIB_INCLUDE_DIR DIR/zlib-1.2.5
|
||||
ZLIB_LIBRARIES DIR/zlib125dll/dll32/zlibwapi.lib
|
||||
GETTEXT_BIN_DIR DIR/gettext/bin
|
||||
GETTEXT_INCLUDE_DIR DIR/gettext/include
|
||||
GETTEXT_LIBRARIES DIR/gettext/lib/intl.lib
|
||||
GETTEXT_MSGFMT DIR/gettext/bin/msgfmt
|
||||
-----------------
|
||||
- If CMake complains it couldn't find SQLITE3, choose "Advanced" box on the
|
||||
right top corner, then specify the location of SQLITE3_INCLUDE_DIR and
|
||||
SQLITE3_LIBRARY manually.
|
||||
- If you want to build 64-bit minetest, you will need to build 64-bit version
|
||||
of irrlicht engine manually, as only 32-bit pre-built library is provided.
|
||||
- Hit "Configure"
|
||||
- Hit "Configure" once again 8)
|
||||
- If something is still coloured red, you have a problem.
|
||||
- Hit "Generate"
|
||||
If using MSVC:
|
||||
- Open the generated minetest.sln
|
||||
- The project defaults to the "Debug" configuration. Make very sure to
|
||||
select "Release", unless you want to debug some stuff (it's slower
|
||||
and might not even work at all)
|
||||
- Build the ALL_BUILD project
|
||||
- Build the INSTALL project
|
||||
- You should now have a working game with the executable in
|
||||
DIR/minetest-install/bin/minetest.exe
|
||||
- Additionally you may create a zip package by building the PACKAGE
|
||||
project.
|
||||
If using MinGW:
|
||||
- Using the command line, browse to the build directory and run 'make'
|
||||
(or mingw32-make or whatever it happens to be)
|
||||
- You may need to copy some of the downloaded DLLs into bin/, see what
|
||||
running the produced executable tells you it doesn't have.
|
||||
- You should now have a working game with the executable in
|
||||
DIR/minetest/bin/minetest.exe
|
||||
|
||||
Windows releases of minetest are built using a bat script like this:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
set sourcedir=%CD%
|
||||
set installpath="C:\tmp\minetest_install"
|
||||
set irrlichtpath="C:\tmp\irrlicht-1.7.2"
|
||||
|
||||
set builddir=%sourcedir%\bvc10
|
||||
mkdir %builddir%
|
||||
pushd %builddir%
|
||||
cmake %sourcedir% -G "Visual Studio 10" -DIRRLICHT_SOURCE_DIR=%irrlichtpath% -DRUN_IN_PLACE=TRUE -DCMAKE_INSTALL_PREFIX=%installpath%
|
||||
if %errorlevel% neq 0 goto fail
|
||||
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration=Release
|
||||
if %errorlevel% neq 0 goto fail
|
||||
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" INSTALL.vcxproj /p:Configuration=Release
|
||||
if %errorlevel% neq 0 goto fail
|
||||
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" PACKAGE.vcxproj /p:Configuration=Release
|
||||
if %errorlevel% neq 0 goto fail
|
||||
popd
|
||||
echo Finished.
|
||||
exit /b 0
|
||||
|
||||
:fail
|
||||
popd
|
||||
echo Failed.
|
||||
exit /b 1
|
||||
|
||||
License of Minetest textures and sounds
|
||||
---------------------------------------
|
||||
|
||||
This applies to textures and sounds contained in the main Minetest
|
||||
distribution.
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
Everything not listed in here:
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
ShadowNinja:
|
||||
textures/base/pack/smoke_puff.png
|
||||
|
||||
Paramat:
|
||||
textures/base/pack/menu_header.png
|
||||
|
||||
erlehmann:
|
||||
misc/minetest-icon-24x24.png
|
||||
misc/minetest-icon.ico
|
||||
misc/minetest.svg
|
||||
textures/base/pack/logo.png
|
||||
|
||||
License of Minetest source code
|
||||
-------------------------------
|
||||
|
||||
Minetest
|
||||
Copyright (C) 2010-2017 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Irrlicht
|
||||
---------------
|
||||
|
||||
This program uses the Irrlicht Engine. http://irrlicht.sourceforge.net/
|
||||
|
||||
The Irrlicht Engine License
|
||||
|
||||
Copyright © 2002-2005 Nikolaus Gebhardt
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute
|
||||
it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
|
||||
JThread
|
||||
---------------
|
||||
|
||||
This program uses the JThread library. License for JThread follows:
|
||||
|
||||
Copyright (c) 2000-2006 Jori Liesenborgs (jori.liesenborgs@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
|
||||
Lua
|
||||
---------------
|
||||
|
||||
Lua is licensed under the terms of the MIT license reproduced below.
|
||||
This means that Lua is free software and can be used for both academic
|
||||
and commercial purposes at absolutely no cost.
|
||||
|
||||
For details and rationale, see https://www.lua.org/license.html .
|
||||
|
||||
Copyright (C) 1994-2008 Lua.org, PUC-Rio.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
Fonts
|
||||
---------------
|
||||
|
||||
Bitstream Vera Fonts Copyright:
|
||||
|
||||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
|
||||
a trademark of Bitstream, Inc.
|
||||
|
||||
Arimo - Apache License, version 2.0
|
||||
Digitized data copyright (c) 2010-2012 Google Corporation.
|
||||
|
||||
Cousine - Apache License, version 2.0
|
||||
Digitized data copyright (c) 2010-2012 Google Corporation.
|
||||
|
||||
DroidSansFallBackFull:
|
||||
|
||||
Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
7000
doc/lua_api.txt
|
@ -1,5 +1,5 @@
|
|||
Minetest Lua Mainmenu API Reference 0.4.17
|
||||
========================================
|
||||
Minetest Lua Mainmenu API Reference 5.0.1
|
||||
=========================================
|
||||
|
||||
Introduction
|
||||
-------------
|
||||
|
@ -33,32 +33,6 @@ core.close()
|
|||
Filesystem:
|
||||
core.get_builtin_path()
|
||||
^ returns path to builtin root
|
||||
core.get_modpath() (possible in async calls)
|
||||
^ returns path to global modpath
|
||||
core.get_modstore_details(modid) (possible in async calls)
|
||||
^ modid numeric id of mod in modstore
|
||||
^ returns {
|
||||
id = <numeric id of mod in modstore>,
|
||||
title = <human readable title>,
|
||||
basename = <basename for mod>,
|
||||
description = <description of mod>,
|
||||
author = <author of mod>,
|
||||
download_url= <best match download url>,
|
||||
license = <short description of license>,
|
||||
rating = <float value of current rating>
|
||||
}
|
||||
core.get_modstore_list() (possible in async calls)
|
||||
^ returns {
|
||||
[1] = {
|
||||
id = <numeric id of mod in modstore>,
|
||||
title = <human readable title>,
|
||||
basename = <basename for mod>
|
||||
}
|
||||
}
|
||||
core.get_gamepath() (possible in async calls)
|
||||
^ returns path to global gamepath
|
||||
core.get_texturepath() (possible in async calls)
|
||||
^ returns path to default textures
|
||||
core.create_dir(absolute_path) (possible in async calls)
|
||||
^ absolute_path to directory to create (needs to be absolute)
|
||||
^ returns true/false
|
||||
|
@ -89,6 +63,9 @@ core.get_video_drivers()
|
|||
^ returns list of available video drivers' settings name and 'friendly' display name
|
||||
^ e.g. { {name="opengl", friendly_name="OpenGL"}, {name="software", friendly_name="Software Renderer"} }
|
||||
^ first element of returned list is guaranteed to be the NULL driver
|
||||
core.get_mapgen_names([include_hidden=false]) -> table of map generator algorithms
|
||||
registered in the core (possible in async calls)
|
||||
core.get_cache_path() -> path of cache
|
||||
|
||||
Formspec:
|
||||
core.update_formspec(formspec)
|
||||
|
@ -129,20 +106,47 @@ core.get_screen_info()
|
|||
window_height = <current window height>
|
||||
}
|
||||
|
||||
Games:
|
||||
core.get_game(index)
|
||||
^ returns {
|
||||
id = <id>,
|
||||
path = <full path to game>,
|
||||
gamemods_path = <path>,
|
||||
name = <name of game>,
|
||||
menuicon_path = <full path to menuicon>,
|
||||
DEPRECATED:
|
||||
addon_mods_paths = {[1] = <path>,},
|
||||
}
|
||||
core.get_games() -> table of all games in upper format (possible in async calls)
|
||||
core.get_mapgen_names([include_hidden=false]) -> table of map generator algorithms
|
||||
registered in the core (possible in async calls)
|
||||
### Content and Packages
|
||||
|
||||
Content - an installed mod, modpack, game, or texture pack (txt)
|
||||
Package - content which is downloadable from the content db, may or may not be installed.
|
||||
|
||||
* core.get_modpath() (possible in async calls)
|
||||
* returns path to global modpath
|
||||
* core.get_clientmodpath() (possible in async calls)
|
||||
* returns path to global client-side modpath
|
||||
* core.get_gamepath() (possible in async calls)
|
||||
* returns path to global gamepath
|
||||
* core.get_texturepath() (possible in async calls)
|
||||
* returns path to default textures
|
||||
* core.get_game(index)
|
||||
* returns:
|
||||
|
||||
{
|
||||
id = <id>,
|
||||
path = <full path to game>,
|
||||
gamemods_path = <path>,
|
||||
name = <name of game>,
|
||||
menuicon_path = <full path to menuicon>,
|
||||
author = "author",
|
||||
DEPRECATED:
|
||||
addon_mods_paths = {[1] = <path>,},
|
||||
}
|
||||
|
||||
* core.get_games() -> table of all games in upper format (possible in async calls)
|
||||
* core.get_content_info(path)
|
||||
* returns
|
||||
|
||||
{
|
||||
name = "name of content",
|
||||
type = "mod" or "modpack" or "game" or "txp",
|
||||
description = "description",
|
||||
author = "author",
|
||||
path = "path/to/content",
|
||||
depends = {"mod", "names"}, -- mods only
|
||||
optional_depends = {"mod", "names"}, -- mods only
|
||||
}
|
||||
|
||||
|
||||
Favorites:
|
||||
core.get_favorites(location) -> list of favorites (possible in async calls)
|
||||
|
@ -172,11 +176,14 @@ core.log(loglevel, line) (possible in async calls)
|
|||
^ loglevel one of "error", "action", "info", "verbose"
|
||||
|
||||
Settings:
|
||||
core.setting_set(name, value)
|
||||
core.setting_get(name) -> string or nil (possible in async calls)
|
||||
core.setting_setbool(name, value)
|
||||
core.setting_getbool(name) -> bool or nil (possible in async calls)
|
||||
core.setting_save() -> nil, save all settings to config file
|
||||
core.settings:set(name, value)
|
||||
core.settings:get(name) -> string or nil (possible in async calls)
|
||||
core.settings:set_bool(name, value)
|
||||
core.settings:get_bool(name) -> bool or nil (possible in async calls)
|
||||
core.settings:save() -> nil, save all settings to config file
|
||||
|
||||
For a complete list of methods of the Settings object see
|
||||
[lua_api.txt](https://github.com/minetest/minetest/blob/master/doc/lua_api.txt)
|
||||
|
||||
Worlds:
|
||||
core.get_worlds() -> list of worlds (possible in async calls)
|
||||
|
@ -234,8 +241,3 @@ Limitations of Async operations
|
|||
-Limited set of available functions
|
||||
e.g. No access to functions modifying menu like core.start,core.close,
|
||||
core.file_open_dialog
|
||||
|
||||
|
||||
Class reference
|
||||
----------------
|
||||
Settings: see lua_api.txt
|
||||
|
|
|
@ -9,6 +9,7 @@ Texture pack directory structure
|
|||
|
||||
textures
|
||||
|-- Texture Pack
|
||||
| |-- texture_pack.conf
|
||||
| |-- screenshot.png
|
||||
| |-- description.txt
|
||||
| |-- override.txt
|
||||
|
@ -21,9 +22,17 @@ This is a directory containing the entire contents of a single texture pack.
|
|||
It can be chosen more or less freely and will also become the name of the
|
||||
texture pack. The name must not be “base”.
|
||||
|
||||
### `texture_pack.conf`
|
||||
A key-value config file with the following keys:
|
||||
|
||||
* `title` - human readable title
|
||||
* `description` - short description, shown in the content tab
|
||||
|
||||
### `description.txt`
|
||||
**Deprecated**, you should use texture_pack.conf instead.
|
||||
|
||||
A file containing a short description of the texture pack to be shown in the
|
||||
texture packs tab.
|
||||
content tab.
|
||||
|
||||
### `screenshot.png`
|
||||
A preview image showing an in-game screenshot of this texture pack; it will be
|
||||
|
@ -159,3 +168,44 @@ Here are face selectors you can choose from:
|
|||
| bottom | y- |
|
||||
| sides | x-, x+, z-, z+ |
|
||||
| all | All faces. You can also use '*' instead of 'all'. |
|
||||
|
||||
Designing leaves textures for the leaves rendering options
|
||||
----------------------------------------------------------
|
||||
|
||||
Minetest has three modes for rendering leaves nodes if the node has the
|
||||
`allfaces_optional` drawtype.
|
||||
|
||||
### Fancy
|
||||
|
||||
Uses the texture specified in the `tiles` nodedef field.
|
||||
The texture should have some transparent pixels and be in the RGBA format so
|
||||
that the transparent pixels can have color information.
|
||||
Faces of every leaves node are rendered even if they are inside a solid volume
|
||||
of leaves; this gives a dense appearance.
|
||||
|
||||
### Opaque
|
||||
|
||||
Uses the texture specified in `tiles` but makes it opaque by converting each
|
||||
transparent pixel into an opaque pixel that uses the color information of that
|
||||
transparent pixel.
|
||||
Due to this the `tiles` texture format must be RGBA not 'indexed alpha' to allow
|
||||
each transparent pixel to have color information.
|
||||
|
||||
The colors of the transparent pixels should be set for a good appearance in
|
||||
`opaque` mode. This can be done by painting the pixels the desired colors then
|
||||
erasing them. Then when saving the texture, use the 'save color information from
|
||||
transparent pixels' option (or equivalent).
|
||||
|
||||
### Simple
|
||||
|
||||
Uses the texture specified in the `special_tiles` nodedef field if it exists, if
|
||||
not, the `tiles` texture.
|
||||
The `special_tiles` texture should have fewer transparent pixels than the
|
||||
`tiles` texture and be in the 'indexed alpha' format.
|
||||
|
||||
This mode is between the other two in terms of appearance and rendering load.
|
||||
The nodes are rendered using the `glasslike` drawtype, only showing the surface
|
||||
faces for any solid volume of leaves, not the internal faces.
|
||||
Due to this the `tiles` texture might appear lacking in density, so optionally a
|
||||
`special_tiles` texture can be used to provide a texture with fewer transparent
|
||||
pixels for a denser appearance.
|
||||
|
|
|
@ -29,6 +29,7 @@ It can be copied over from an old world to a newly created world.
|
|||
|
||||
World
|
||||
|-- auth.txt ----- Authentication data
|
||||
|-- auth.sqlite -- Authentication data (SQLite alternative)
|
||||
|-- env_meta.txt - Environment metadata
|
||||
|-- ipban.txt ---- Banned ips/users
|
||||
|-- map_meta.txt - Map metadata
|
||||
|
@ -62,6 +63,34 @@ Example lines:
|
|||
- Player "bar", no password, no privileges:
|
||||
bar::
|
||||
|
||||
auth.sqlite
|
||||
------------
|
||||
Contains authentification data as an SQLite database. This replaces auth.txt
|
||||
above when auth_backend is set to "sqlite3" in world.mt .
|
||||
|
||||
This database contains two tables "auth" and "user_privileges":
|
||||
|
||||
CREATE TABLE `auth` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` VARCHAR(32) UNIQUE,
|
||||
`password` VARCHAR(512),
|
||||
`last_login` INTEGER
|
||||
);
|
||||
CREATE TABLE `user_privileges` (
|
||||
`id` INTEGER,
|
||||
`privilege` VARCHAR(32),
|
||||
PRIMARY KEY (id, privilege)
|
||||
CONSTRAINT fk_id FOREIGN KEY (id) REFERENCES auth (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
The "name" and "password" fields of the auth table are the same as the auth.txt
|
||||
fields (with modern password hash). The "last_login" field is the last login
|
||||
time as a unix time stamp.
|
||||
|
||||
The "user_privileges" table contains one entry per privilege and player.
|
||||
A player with "interact" and "shout" privileges will have two entries, one
|
||||
with privilege="interact" and the second with privilege="shout".
|
||||
|
||||
env_meta.txt
|
||||
-------------
|
||||
Simple global environment variables.
|
||||
|
@ -98,8 +127,16 @@ See Player File Format below.
|
|||
world.mt
|
||||
---------
|
||||
World metadata.
|
||||
Example content (added indentation):
|
||||
gameid = mesetint
|
||||
Example content (added indentation and - explanations):
|
||||
gameid = mesetint - name of the game
|
||||
enable_damage = true - whether damage is enabled or not
|
||||
creative_mode = false - whether creative mode is enabled or not
|
||||
backend = sqlite3 - which DB backend to use for blocks (sqlite3, dummy, leveldb, redis, postgresql)
|
||||
player_backend = sqlite3 - which DB backend to use for player data
|
||||
readonly_backend = sqlite3 - optionally readonly seed DB (DB file _must_ be located in "readonly" subfolder)
|
||||
server_announce = false - whether the server is publicly announced or not
|
||||
load_mod_<mod> = false - whether <mod> is to be loaded in this world
|
||||
auth_backend = files - which DB backend to use for authentication data
|
||||
|
||||
Player File Format
|
||||
===================
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
name = Earth
|
||||
name = BlockColor
|
||||
release = 1626
|
||||
author = Chiantos
|
||||
description = BlockColor is a creative sandbox with only 8 colors. Only a limit : Your Imagination - http://blockcolor.net/
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
#---------------------------------------------------------------------
|
||||
# Use By Game Blockcolor
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
-- Colors for Nodes, Decorates and Hotbar
|
||||
|
||||
-- 8 Colors
|
||||
|
||||
-- color1 = 292421 -- (Black)
|
||||
-- color2 = 0000FF -- (Blue)
|
||||
-- color3 = 00FF00 -- (Green)
|
||||
-- color4 = F5F5F5 -- (White)
|
||||
-- color5 = FF6103 -- (Orange)
|
||||
-- color6 = FF0000 -- (Red)
|
||||
-- color7 = FFFF00 -- (Yellow)
|
||||
-- color8 = FF69B4 -- (Pink)
|
||||
|
||||
-- End
|
||||
|
||||
default_privs = shout,home,fly,fast,interact
|
||||
creative_mode = true
|
||||
enable_damage = false
|
||||
only_peaceful_mobs = false
|
||||
enable_pvp = false
|
||||
enable_tnt = false
|
||||
disable_fire = false
|
||||
fire_enabled = false
|
||||
|
||||
# extras mod settings
|
||||
playerhotbar = 8
|
||||
playerbox = 1
|
||||
playerboxsize = 128
|
||||
pingkick = 1
|
||||
autorollback = 0
|
||||
isplayer = 0
|
||||
recrafting = 0
|
||||
safepvp = 0
|
||||
|
||||
# player visibility?
|
||||
player_transfer_distance = 50
|
||||
unlimited_player_transfer_distance = false
|
||||
|
||||
hud_item_wheel = true
|
|
@ -1,38 +0,0 @@
|
|||
hud.register(name, def)
|
||||
-- name: statbar name (health, air, hunger, armor already used by default)
|
||||
-- def: <HUD item definition> (see below)
|
||||
|
||||
hud.change_item(player, name, def)
|
||||
-- player: player object
|
||||
-- name: statbar name
|
||||
-- def: table containing new values
|
||||
-- currently supported: number, text and offset
|
||||
|
||||
hud.swap_statbar(player, name1, name2) -- swaps position and offset of statbar with name1 with statbar with name2
|
||||
-- player: player object
|
||||
-- name1: statbar name
|
||||
-- name2: statbar name
|
||||
|
||||
hud.remove_item(player, name)
|
||||
|
||||
HUD item definition
|
||||
{
|
||||
hud_elem_type = "statbar", -- currently only supported type (same as in lua-api.txt)
|
||||
position = {x=<x>, y=<y>}, -- position of statbar (same as in lua-api.txt)
|
||||
size = {x=24, y=24}, -- statbar texture size (default 24x24), needed to be scaled correctly
|
||||
text = "hud_heart_fg.png", -- texture name (same as in lua-api.txt)
|
||||
number = 20, -- number/2 = number of full textures(e.g. hearts)
|
||||
max = 20, -- used to prevent "overflow" of statbars
|
||||
alignment = {x=-1,y=-1}, -- alignment on screen (same as in lua-api.txt)
|
||||
offset = HUD_HEALTH_OFFSET,
|
||||
background = "hud_heart_bg.png", -- statbar background texture name
|
||||
autohide_bg = false, -- hide statbar background textures when number = 0
|
||||
events = { -- called on events "damage" and "breath_changed" of players
|
||||
{
|
||||
type = "damage",
|
||||
func = function(player)
|
||||
-- do something here
|
||||
end
|
||||
}
|
||||
},
|
||||
}
|
|
@ -1,502 +0,0 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
|
@ -1,67 +0,0 @@
|
|||
Minetest mod "Better HUD"
|
||||
=========================
|
||||
Version: 2.1.5
|
||||
|
||||
(c) Copyright BlockMen (2013-2016)
|
||||
|
||||
|
||||
About this mod:
|
||||
~~~~~~~~~~~~~~~
|
||||
This mod improves the HUD of Minetest and adds (hidden by default) statbars for Hunger and Armor.
|
||||
Also it provides an API to add new statbars easily, see API.txt for more informations.
|
||||
|
||||
Changes in builtin HUD items:
|
||||
- Adds background for Health bar
|
||||
- Uses better textures for Hotbar
|
||||
- Uses texture for crosshair
|
||||
- Positions of builtin statbars can be changed via "hud.conf" file
|
||||
- Experimental "ItemWheel" that replaces the hotbar (must be enabled by adding "hud_item_wheel = true" in minetest.conf)
|
||||
|
||||
This mod gets provided as Modpack aswell, which includes the hunger mod (https://github.com/BlockMen/hunger)
|
||||
More information concerning the hunger mechanics can be get there.
|
||||
|
||||
This mod supports the 3d_armor mod by stu (https://github.com/stujones11/minetest-3d_armor)
|
||||
|
||||
|
||||
|
||||
License:
|
||||
~~~~~~~~
|
||||
(c) Copyright BlockMen (2013-2016)
|
||||
|
||||
|
||||
Code:
|
||||
Licensed under the GNU LGPL version 2.1 or higher.
|
||||
You can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License
|
||||
as published by the Free Software Foundation;
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
See LICENSE.txt and http://www.gnu.org/licenses/lgpl-2.1.txt
|
||||
|
||||
|
||||
Textures:
|
||||
hud_heart_fg.png - celeron55 (CC BY-SA 3.0), modified by BlockMen
|
||||
hud_heart_bg.png - celeron55 (CC BY-SA 3.0), modified by BlockMen
|
||||
hud_hunger_fg.png - PilzAdam (WTFPL), modified by BlockMen
|
||||
hud_hunger_bg.png - PilzAdam (WTFPL), modified by BlockMen
|
||||
wieldhand.png (from character.png) - Jordach (CC BY-SA 3.0), modified by BlockMen
|
||||
hud_air_fg.png - kaeza (WTFPL), modified by BlockMen
|
||||
hud_armor_fg.png - Stu (CC BY-SA 3.0), modified by BlockMen
|
||||
hud_armor_bg.png - Stu (CC BY-SA 3.0), modified by BlockMen
|
||||
|
||||
|
||||
Github:
|
||||
~~~~~~~
|
||||
https://github.com/BlockMen/hud
|
||||
|
||||
Forum:
|
||||
~~~~~~
|
||||
https://forum.minetest.net/viewtopic.php?id=6342
|
||||
|
||||
|
||||
Changelog:
|
||||
~~~~~~~~~~
|
||||
see changelog.txt
|
|
@ -1,275 +0,0 @@
|
|||
|
||||
-- global values
|
||||
hud.registered_items = {}
|
||||
hud.damage_events = {}
|
||||
hud.breath_events = {}
|
||||
|
||||
-- keep id handling internal
|
||||
local hud_id = {} -- hud item ids
|
||||
local sb_bg = {} -- statbar background ids
|
||||
|
||||
-- localize often used table
|
||||
local items = hud.registered_items
|
||||
|
||||
local function throw_error(msg)
|
||||
minetest.log("error", "Better HUD[error]: " .. msg)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- API
|
||||
--
|
||||
|
||||
function hud.register(name, def)
|
||||
if not name or not def then
|
||||
throw_error("not enough parameters given")
|
||||
return false
|
||||
end
|
||||
|
||||
--TODO: allow other elements
|
||||
if def.hud_elem_type ~= "statbar" then
|
||||
throw_error("The given HUD element is no statbar")
|
||||
return false
|
||||
end
|
||||
if items[name] ~= nil then
|
||||
throw_error("A statbar with that name already exists")
|
||||
return false
|
||||
end
|
||||
|
||||
-- actually register
|
||||
-- add background first since draworder is based on id :\
|
||||
if def.hud_elem_type == "statbar" and def.background ~= nil then
|
||||
sb_bg[name] = table.copy(def)
|
||||
sb_bg[name].text = def.background
|
||||
if not def.autohide_bg and def.max then
|
||||
sb_bg[name].number = def.max
|
||||
end
|
||||
end
|
||||
-- add item itself
|
||||
items[name] = def
|
||||
|
||||
-- register events
|
||||
if def.events then
|
||||
for _,v in pairs(def.events) do
|
||||
if v and v.type and v.func then
|
||||
if v.type == "damage" then
|
||||
table.insert(hud.damage_events, v)
|
||||
end
|
||||
|
||||
if v.type == "breath" then
|
||||
table.insert(hud.breath_events, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- no error so far, return success
|
||||
return true
|
||||
end
|
||||
|
||||
-- swaps stabar positions
|
||||
function hud.swap_statbar(player, item1, item2)
|
||||
if not player or not item1 or not item2 then
|
||||
throw_error("Not enough parameters given to swap statbars")
|
||||
return false
|
||||
end
|
||||
|
||||
local def1 = items[item1] or nil
|
||||
local def2 = items[item2] or nil
|
||||
|
||||
if not def1 or not def2 then
|
||||
throw_error("Can't swap statbars. Given statbars are not correct")
|
||||
return false
|
||||
end
|
||||
|
||||
local pos_swap = false
|
||||
local p_name = player:get_player_name()
|
||||
local elem1 = hud_id[p_name.."_"..item1]
|
||||
local elem2 = hud_id[p_name.."_"..item2]
|
||||
|
||||
if not elem1 or not elem2 or not elem1.id or not elem2.id then
|
||||
return false
|
||||
end
|
||||
|
||||
player:hud_change(elem2.id, "offset", def1.offset)
|
||||
player:hud_change(elem1.id, "offset", def2.offset)
|
||||
|
||||
if def1.position.x ~= def2.position.x or def1.position.y ~= def2.position.y then
|
||||
player:hud_change(elem2.id, "position", def1.position)
|
||||
player:hud_change(elem1.id, "position", def2.position)
|
||||
pos_swap = true
|
||||
end
|
||||
|
||||
-- do the items have backgrounds? if so, swap them aswell
|
||||
local bg1 = hud_id[p_name.."_"..item1.."_bg"] or nil
|
||||
local bg2 = hud_id[p_name.."_"..item2.."_bg"] or nil
|
||||
if bg1 ~= nil and bg1.id then
|
||||
player:hud_change(bg1.id, "offset", def2.offset)
|
||||
if pos_swap == true then
|
||||
player:hud_change(bg1.id, "position", def2.position)
|
||||
end
|
||||
end
|
||||
if bg2 ~= nil and bg2.id then
|
||||
player:hud_change(bg2.id, "offset", def1.offset)
|
||||
if pos_swap == true then
|
||||
player:hud_change(bg2.id, "position", def1.position)
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
|
||||
end
|
||||
|
||||
function hud.change_item(player, name, def)
|
||||
if not player or not player:is_player() or not name or not def then
|
||||
throw_error("Not enough parameters given to change HUD item")
|
||||
return false
|
||||
end
|
||||
local i_name = player:get_player_name().."_"..name
|
||||
local elem = hud_id[i_name]
|
||||
if not elem then
|
||||
throw_error("Given HUD element " .. dump(name) .. " does not exist".." hääää")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Only update if values supported and value actually changed
|
||||
-- update supported values (currently number and text only)
|
||||
if def.number and elem.number then
|
||||
if def.number ~= elem.number then
|
||||
if elem.max and def.number > elem.max and not def.max then
|
||||
def.number = elem.max
|
||||
end
|
||||
if def.max then
|
||||
elem.max = def.max
|
||||
end
|
||||
player:hud_change(elem.id, "number", def.number)
|
||||
elem.number = def.number
|
||||
-- hide background when set
|
||||
local bg = hud_id[i_name.."_bg"]
|
||||
if elem.autohide_bg then
|
||||
if def.number < 1 then
|
||||
player:hud_change(bg.id, "number", 0)
|
||||
else
|
||||
local num = bg.number
|
||||
if bg.max then
|
||||
num = bg.max
|
||||
end
|
||||
player:hud_change(bg.id, "number", num)
|
||||
end
|
||||
else
|
||||
if bg and bg.max and bg.max < 1 and def.max and def.max > bg.max then
|
||||
player:hud_change(bg.id, "number", def.max)
|
||||
bg.max = def.max
|
||||
bg.number = def.max
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if def.text and elem.text then
|
||||
if def.text ~= elem.text then
|
||||
player:hud_change(elem.id, "text", def.text)
|
||||
elem.text = def.text
|
||||
end
|
||||
end
|
||||
|
||||
if def.offset and elem.offset then
|
||||
if def.item_name and def.offset == "item" then
|
||||
-- for legacy reasons
|
||||
if def.item_name then
|
||||
hud.swap_statbar(player, name, def.item_name)
|
||||
end
|
||||
else
|
||||
player:hud_change(elem.id, "offset", def.offset)
|
||||
elem.offset = def.offset
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function hud.remove_item(player, name)
|
||||
if not player or not name then
|
||||
throw_error("Not enough parameters given")
|
||||
return false
|
||||
end
|
||||
local i_name = player:get_player_name().."_"..name
|
||||
if hud_id[i_name] == nil then
|
||||
throw_error("Given HUD element " .. dump(name) .. " does not exist")
|
||||
return false
|
||||
end
|
||||
player:hud_remove(hud_id[i_name].id)
|
||||
hud_id[i_name] = nil
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Add registered HUD items to joining players
|
||||
--
|
||||
|
||||
-- Following code is placed here to keep HUD ids internal
|
||||
local function add_hud_item(player, name, def)
|
||||
if not player or not name or not def then
|
||||
throw_error("not enough parameters given")
|
||||
return false
|
||||
end
|
||||
local i_name = player:get_player_name().."_"..name
|
||||
hud_id[i_name] = def
|
||||
hud_id[i_name].id = player:hud_add(def)
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
|
||||
-- first: hide the default statbars
|
||||
local hud_flags = player:hud_get_flags()
|
||||
hud_flags.healthbar = false
|
||||
hud_flags.breathbar = false
|
||||
player:hud_set_flags(hud_flags)
|
||||
|
||||
-- now add the backgrounds for statbars
|
||||
for _,item in pairs(sb_bg) do
|
||||
add_hud_item(player, _.."_bg", item)
|
||||
end
|
||||
-- and finally the actual HUD items
|
||||
for _,item in pairs(items) do
|
||||
add_hud_item(player, _, item)
|
||||
end
|
||||
|
||||
-- fancy hotbar (only when no crafting mod present)
|
||||
if minetest.get_modpath("crafting") == nil then
|
||||
minetest.after(0.5, function()
|
||||
player:hud_set_hotbar_image("hud_hotbar.png")
|
||||
player:hud_set_hotbar_selected_image("hud_hotbar_selected.png")
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
function hud.player_event(player, event)
|
||||
if not player then return end -- ADDED
|
||||
|
||||
--needed for first update called by on_join
|
||||
minetest.after(0, function(player) -- ADDED (player)
|
||||
if event == "health_changed" then
|
||||
for _,v in pairs(hud.damage_events) do
|
||||
if v.func then
|
||||
v.func(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if event == "breath_changed" then
|
||||
for _,v in pairs(hud.breath_events) do
|
||||
if v.func then
|
||||
v.func(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if event == "hud_changed" then--called when flags changed
|
||||
|
||||
end
|
||||
end, player) -- ADDED , player)
|
||||
end
|
||||
|
||||
core.register_playerevent(hud.player_event)
|
|
@ -1,126 +0,0 @@
|
|||
|
||||
HUD_IW_MAX = 8
|
||||
HUD_IW_TICK = 0.4
|
||||
if minetest.is_singleplayer() == true then
|
||||
HUD_IW_TICK = 0.2
|
||||
end
|
||||
|
||||
HUD_SB_SIZE = {x = 24, y = 24}
|
||||
|
||||
HUD_HEALTH_POS = {x = 0.5,y = 1}
|
||||
HUD_HEALTH_OFFSET = {x = -262, y = -87}
|
||||
HUD_AIR_POS = {x = 0.5, y = 1}
|
||||
HUD_AIR_OFFSET = {x = 15, y = -87}
|
||||
HUD_HUNGER_POS = {x = 0.5, y = 1}
|
||||
HUD_HUNGER_OFFSET = {x = 15, y = -110}
|
||||
HUD_ARMOR_POS = {x = 0.5, y = 1}
|
||||
HUD_ARMOR_OFFSET = {x = -262, y = -110}
|
||||
|
||||
-- Reorder everything when using ItemWeel
|
||||
hud.item_wheel = minetest.settings:get_bool("hud_item_wheel")
|
||||
if hud.item_wheel then
|
||||
HUD_HEALTH_POS = {x = 0.5,y = 1}
|
||||
HUD_HEALTH_OFFSET = {x = -385, y = -77}
|
||||
HUD_AIR_POS = {x = 0.5, y = 1}
|
||||
HUD_AIR_OFFSET = {x = 150, y = -77}
|
||||
HUD_HUNGER_POS = {x = 0.5, y = 1}
|
||||
HUD_HUNGER_OFFSET = {x = 180, y = -44}
|
||||
HUD_ARMOR_POS = {x = 0.5, y = 1}
|
||||
HUD_ARMOR_OFFSET = {x = -415, y = -44}
|
||||
end
|
||||
|
||||
-- read hud.conf settings
|
||||
function hud.read_conf()
|
||||
local mod_path = minetest.get_modpath("hud")
|
||||
local set = io.open(mod_path .. "/hud.conf", "r")
|
||||
if set then
|
||||
dofile(mod_path .. "/hud.conf")
|
||||
set:close()
|
||||
end
|
||||
end
|
||||
|
||||
hud.read_conf()
|
||||
|
||||
local damage_enabled = minetest.settings:get_bool("enable_damage")
|
||||
|
||||
hud.show_hunger = minetest.get_modpath("hunger") ~= nil
|
||||
hud.show_armor = minetest.get_modpath("3d_armor") ~= nil
|
||||
|
||||
-- check if some settings are invalid
|
||||
local enable_hunger = minetest.settings:get_bool("hud_hunger_enable")
|
||||
if (enable_hunger == true) and not hud.show_hunger then
|
||||
hud.notify_hunger(5)
|
||||
end
|
||||
|
||||
if damage_enabled ~= true then
|
||||
hud.show_armor = false
|
||||
return
|
||||
end
|
||||
|
||||
hud.register("health", {
|
||||
hud_elem_type = "statbar",
|
||||
position = HUD_HEALTH_POS,
|
||||
size = HUD_SB_SIZE,
|
||||
text = "hud_heart_fg.png",
|
||||
number = 20,
|
||||
alignment = {x = -1, y = -1},
|
||||
offset = HUD_HEALTH_OFFSET,
|
||||
background = "hud_heart_bg.png",
|
||||
events = {
|
||||
{
|
||||
type = "damage",
|
||||
func = function(player)
|
||||
hud.change_item(player, "health", {number = player:get_hp()})
|
||||
end
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
hud.register("air", {
|
||||
hud_elem_type = "statbar",
|
||||
position = HUD_AIR_POS,
|
||||
size = HUD_SB_SIZE,
|
||||
text = "hud_air_fg.png",
|
||||
number = 0,
|
||||
alignment = {x = -1, y = -1},
|
||||
offset = HUD_AIR_OFFSET,
|
||||
background = nil,
|
||||
events = {
|
||||
{
|
||||
type = "breath",
|
||||
func = function(player)
|
||||
if not player then return end -- ADDED
|
||||
local air = player:get_breath() or 11
|
||||
if air > 10 then
|
||||
air = 0
|
||||
end
|
||||
hud.change_item(player, "air", {number = air * 2})
|
||||
end
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
hud.register("armor", {
|
||||
hud_elem_type = "statbar",
|
||||
position = HUD_ARMOR_POS,
|
||||
size = HUD_SB_SIZE,
|
||||
text = "hud_armor_fg.png",
|
||||
number = 0,
|
||||
alignment = {x = -1, y = -1},
|
||||
offset = HUD_ARMOR_OFFSET,
|
||||
background = "hud_armor_bg.png",
|
||||
autohide_bg = true,
|
||||
max = 20,
|
||||
})
|
||||
|
||||
hud.register("hunger", {
|
||||
hud_elem_type = "statbar",
|
||||
position = HUD_HUNGER_POS,
|
||||
size = HUD_SB_SIZE,
|
||||
text = "hud_hunger_fg.png",
|
||||
number = 0,
|
||||
alignment = {x = -1, y = -1},
|
||||
offset = HUD_HUNGER_OFFSET,
|
||||
background = "hud_hunger_bg.png",
|
||||
max = 0,
|
||||
})
|
|
@ -1,140 +0,0 @@
|
|||
2.1.5
|
||||
-----
|
||||
- Fixed armor not being updated correct due armor mod changes
|
||||
|
||||
2.1.4
|
||||
-----
|
||||
- Fixed unhandled exception in hud.swap_statbar()
|
||||
|
||||
2.1.3
|
||||
-----
|
||||
- Added hud.swap_statbar() and fix wrong behavior of previous workaround
|
||||
- Fixed missing background of some statbars in multiplayer
|
||||
|
||||
2.1.2
|
||||
-----
|
||||
- Fixed crash caused by animated nodes (reported by Krock)
|
||||
- Fixed "freezing" of empty slots (reported by kilbith)
|
||||
|
||||
2.1.1
|
||||
-----
|
||||
- Added itemcounting/wearout info
|
||||
- Added support for hud scaling
|
||||
- Fixed typo causing endless updating
|
||||
- Fixed image scaling of some textures (like glass)
|
||||
- Improved ItemWheel image
|
||||
|
||||
2.1
|
||||
---
|
||||
- Added "ItemWheel" (experimental)
|
||||
- Fixed disapperaring hunger bar (reported by poet-nohit)
|
||||
|
||||
2.0.1
|
||||
-----
|
||||
- Fix disappearing hotbar (reported by poet-nohit)
|
||||
- Fix unused global var
|
||||
- Added one more check to catch probably incorrect players
|
||||
|
||||
2.0
|
||||
---
|
||||
- Complete rewrite
|
||||
- Moved hunger into seperate mod
|
||||
- Added API
|
||||
- Switched License to LGPL 2.1
|
||||
|
||||
===== ===== =====
|
||||
----- 0-1.x -----
|
||||
===== ===== =====
|
||||
|
||||
1.4.1
|
||||
-----
|
||||
- ###
|
||||
|
||||
1.4
|
||||
---
|
||||
- New hunger mechanics/added experimental player-action based hunger
|
||||
- Better crosshair texture, switched to "new" default hand
|
||||
- Added support for farming redo mod, kpgmobs and jkmod
|
||||
|
||||
1.3.3
|
||||
-----
|
||||
- Prevent crash with armor mod and missing player
|
||||
- Add support for ethereal mod (by TenPlus1)
|
||||
|
||||
1.3.2
|
||||
-----
|
||||
- Fix dependecies (by Chris Beelby)
|
||||
- Add support for creatures mod
|
||||
- Add optional healing for food (by TenPlus1)
|
||||
|
||||
1.3.1
|
||||
-----
|
||||
- Add compatibility for statbar scaling
|
||||
- Fix typo in depends.txt
|
||||
- Lower maintimer tick
|
||||
|
||||
1.3
|
||||
---
|
||||
- New way hunger is saved (all old files in world dirctory can get deleted [e.g. hud_BlockMen_hunger])
|
||||
- Fixed healing (not while drowning, fix after death)
|
||||
- Add support for mods: seaplants[sea] and mobfcooking (by Xanthin)
|
||||
- Tweaked hand image
|
||||
- Player can die caus of starving now
|
||||
|
||||
1.2
|
||||
---
|
||||
- Send statbar values only to client when changed
|
||||
- Hide armor bar if not wearing armor
|
||||
- More reliable food overrides (by CiaranG)
|
||||
- Support for bushes_classic foods (plantlife modpack) (by CiaranG)
|
||||
- Add support for mushroom mod food/poison (by CiaranG)
|
||||
- Add support for mods: fruit and mush45
|
||||
- New images for hotbar, smaller armor icons
|
||||
|
||||
1.1
|
||||
---
|
||||
- added support for stu's 3darmor mod
|
||||
- restructured and cleaned up code
|
||||
- added support for poisen food (damages player, but does not kill)
|
||||
|
||||
1.0
|
||||
---
|
||||
- hunger is reset after death
|
||||
- health and hunger bar is shown correct on all screen resolutions now
|
||||
- switched to changed native hotbar image support
|
||||
- fixed revival of player when drown
|
||||
- hunger bar is not shown anymore if hunger is disabled
|
||||
- hunger can be disabled by minetest.conf ("hud_hunger_enable = false")
|
||||
|
||||
0.5 Beta
|
||||
----------
|
||||
- removed the fancy borders of hud inventory bar and moved to new native support
|
||||
- moved crosshair to native support too
|
||||
|
||||
0.4 Beta
|
||||
----------
|
||||
- enabled drowning
|
||||
|
||||
0.3 Beta
|
||||
----------
|
||||
- added fancy borders of hud inventory bar (only for screenheight <= 800)
|
||||
|
||||
0.2.3 Beta
|
||||
----------
|
||||
- added support for food of glooptest and bushes (commit by CheeseKeg)
|
||||
|
||||
0.2.2 Beta
|
||||
----------
|
||||
- added support for food of animalmaterials (mobf modpack),fishing
|
||||
|
||||
0.2.1 Beta
|
||||
----------
|
||||
- tweaked override of food
|
||||
- added support for food of dwares, moretrees and simple mobs
|
||||
|
||||
0.2 Beta
|
||||
--------
|
||||
- added support of custom config files
|
||||
- you can eat max. 50% more than before (although it isnt shown in hunger bar)
|
||||
- you get healed with 8 breads and more (in hunger bar) now
|
||||
- a bread (from farming) == 2 breads in hunger bar
|
|
@ -1 +0,0 @@
|
|||
3d_armor?
|
|
@ -1,35 +0,0 @@
|
|||
--##Better HUD example config file##
|
||||
------------------------------------
|
||||
-- This example moves the statbars in the down left and down right corners. By Echoes91
|
||||
|
||||
-- NOTICE --
|
||||
-- if damage is disabled no statbar is shown at all
|
||||
-- Make sure that the statbars are shown correct on other screen resolutions aswell
|
||||
|
||||
|
||||
HUD_SB_SIZE = {x = 24, y = 24} -- statbar icon size in pixel before (!) scaling
|
||||
|
||||
--
|
||||
-- health bar
|
||||
--
|
||||
HUD_HEALTH_POS = {x = 0, y = 1} -- min 0, max 1
|
||||
HUD_HEALTH_OFFSET = {x = 10, y = -30} -- offset in pixel
|
||||
|
||||
--
|
||||
-- hunger bar
|
||||
--
|
||||
HUD_HUNGER_POS = {x = 1, y = 1} -- min 0, max 1
|
||||
HUD_HUNGER_OFFSET = {x = -250, y = -30} -- offset in pixel
|
||||
|
||||
--
|
||||
-- breath bar
|
||||
--
|
||||
HUD_AIR_POS = {x = 1, y = 1} -- min 0, max 1
|
||||
HUD_AIR_OFFSET = {x = -250, y = -60} -- offset in pixel
|
||||
|
||||
--
|
||||
-- armor bar
|
||||
--
|
||||
HUD_ARMOR_POS = {x = 0, y = 1} -- min 0, max 1
|
||||
HUD_ARMOR_OFFSET = {x = 10, y = -60} -- offset in pixel
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
hud = {}
|
||||
GameOS = 0
|
||||
|
||||
local path = minetest.get_modpath("hud")
|
||||
|
||||
if PLATFORM == "IOS" or PLATFORM == "Android" then
|
||||
GameOS = "Mobile"
|
||||
else
|
||||
GameOS = "PC"
|
||||
end
|
||||
|
||||
if GameOS == "Mobile" then
|
||||
|
||||
elseif GameOS == "PC" then
|
||||
|
||||
dofile(path .. "/api.lua")
|
||||
dofile(path .. "/builtin.lua")
|
||||
dofile(path .. "/legacy.lua")
|
||||
dofile(path .. "/itemwheel.lua")
|
||||
|
||||
else
|
||||
|
||||
end
|
|
@ -1,195 +0,0 @@
|
|||
local hb = {}
|
||||
local scale = 0.5
|
||||
|
||||
local function update_wheel(player)
|
||||
local name = player:get_player_name()
|
||||
if not player or not name then
|
||||
return
|
||||
end
|
||||
|
||||
local i = player:get_wield_index()
|
||||
local i1 = i - 1
|
||||
local i3 = i + 1
|
||||
|
||||
-- it's a wheel
|
||||
if i1 < 1 then
|
||||
i1 = HUD_IW_MAX
|
||||
end
|
||||
if i3 > HUD_IW_MAX then
|
||||
i3 = 1
|
||||
end
|
||||
|
||||
-- get the displayed items
|
||||
local inv = player:get_inventory()
|
||||
local item = hb[name].item
|
||||
local index = hb[name].index
|
||||
local item2 = player:get_wielded_item():get_name()
|
||||
|
||||
-- update all items when wielded has changed
|
||||
if item and item2 and item ~= item2 or item == "wheel_init" or (index and index ~= i) then
|
||||
local items = {}
|
||||
items[1] = inv:get_stack("main", i1):get_name() or nil
|
||||
items[2] = item2
|
||||
items[3] = inv:get_stack("main", i3):get_name() or nil
|
||||
local num = player:get_wielded_item():get_count()
|
||||
local wear = player:get_wielded_item():get_wear()
|
||||
if num < 2 then
|
||||
num = ""
|
||||
else
|
||||
num = tostring(num)
|
||||
end
|
||||
if wear > 0 then
|
||||
num = tostring(100 - math.floor((wear/65535)*100)) .. "%"
|
||||
end
|
||||
|
||||
for n, m in pairs(items) do
|
||||
-- some default values
|
||||
local image = "hud_wielded.png"
|
||||
local need_scale = false
|
||||
local s1 = {x = 1*scale, y = 1*scale}
|
||||
local s2 = {x = 3*scale, y = 3*scale}
|
||||
if n ~= 2 then
|
||||
s1 = {x = 0.6*scale, y = 0.6*scale}
|
||||
s2 = {x = 2*scale, y = 2*scale}
|
||||
end
|
||||
|
||||
-- get the images
|
||||
local def = minetest.registered_items[m]
|
||||
if def then
|
||||
if def.tiles and (def.tiles[1] and not def.tiles[1].name) then
|
||||
image = minetest.inventorycube(def.tiles[1], def.tiles[6] or def.tiles[3] or def.tiles[1], def.tiles[3] or def.tiles[1])
|
||||
need_scale = true
|
||||
end
|
||||
if def.inventory_image and def.inventory_image ~= "" then
|
||||
image = def.inventory_image
|
||||
need_scale = true
|
||||
end
|
||||
if def.wielded_image and def.wielded_image ~= "" then
|
||||
image = def.wielded_image
|
||||
need_scale = false
|
||||
end
|
||||
-- needed for nodes with inventory cube inv imges, e.g. glass
|
||||
if string.find(image, 'inventorycube') then
|
||||
need_scale = true
|
||||
end
|
||||
end
|
||||
|
||||
-- get the id and update hud elements
|
||||
local id = hb[name].id[n]
|
||||
if id and image then
|
||||
if need_scale then
|
||||
player:hud_change(id, "scale", s1)
|
||||
else
|
||||
player:hud_change(id, "scale", s2)
|
||||
end
|
||||
-- make previous and next item darker
|
||||
--if n ~= 2 then
|
||||
--image = image .. "^[colorize:#0005"
|
||||
--end
|
||||
player:hud_change(id, "text", image)
|
||||
end
|
||||
end
|
||||
if hb[name].id[4] then
|
||||
player:hud_change(hb[name].id[4], "text", num)
|
||||
end
|
||||
end
|
||||
|
||||
-- update wielded buffer
|
||||
if hb[name].id[2] ~= nil then
|
||||
hb[name].item = item2
|
||||
hb[name].index = i
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
hb[name]= {}
|
||||
hb[name].id = {}
|
||||
hb[name].item = "wheel_init"
|
||||
hb[name].index = 1
|
||||
|
||||
minetest.after(0.1, function()
|
||||
|
||||
-- hide builtin hotbar
|
||||
local hud_flags = player:hud_get_flags()
|
||||
hud_flags.hotbar = false
|
||||
player:hud_set_flags(hud_flags)
|
||||
|
||||
player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
text = "hud_new.png",
|
||||
position = {x = 0.5, y = 1},
|
||||
scale = {x = 1*scale, y = 1*scale},
|
||||
alignment = {x = 0, y = -1},
|
||||
offset = {x = 0, y = 0}
|
||||
})
|
||||
|
||||
hb[name].id[1] = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
text = "hud_wielded.png",
|
||||
position = {x = 0.5, y = 1},
|
||||
scale = {x = 0.5, y = 0.5},
|
||||
alignment = {x = -3.5, y = -1.5},
|
||||
offset = {x = -75*scale, y = -8*scale}
|
||||
})
|
||||
|
||||
hb[name].id[2] = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
text = "hud_wielded.png",
|
||||
position = {x = 0.5, y = 1},
|
||||
scale = {x = 3*scale, y = 3*scale},
|
||||
alignment = {x = 0, y = -1.5},
|
||||
offset = {x = 0, y = -12*scale}
|
||||
})
|
||||
|
||||
hb[name].id[3] = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
text = "hud_wielded.png",
|
||||
position = {x = 0.5, y = 1},
|
||||
scale = {x = 1*scale, y = 1*scale},
|
||||
alignment = {x = 3.5, y = -1.5},
|
||||
offset = {x = 75*scale, y = -8*scale}
|
||||
})
|
||||
|
||||
hb[name].id[4] = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x = 0.5, y = 1},
|
||||
offset = {x = 35*scale, y = -55*scale},
|
||||
alignment = {x = 0, y = -1},
|
||||
number = 0xffffff,
|
||||
text = "",
|
||||
})
|
||||
|
||||
-- init item wheel
|
||||
minetest.after(0, function()
|
||||
hb[name].item = "wheel_init"
|
||||
update_wheel(player)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
local function update_wrapper(a, b, player)
|
||||
local name = player:get_player_name()
|
||||
if not name then
|
||||
return
|
||||
end
|
||||
minetest.after(0, function()
|
||||
hb[name].item = "wheel_init"
|
||||
update_wheel(player)
|
||||
end)
|
||||
end
|
||||
|
||||
minetest.register_on_placenode(update_wrapper)
|
||||
minetest.register_on_dignode(update_wrapper)
|
||||
|
||||
|
||||
local timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime
|
||||
if timer >= HUD_IW_TICK then
|
||||
timer = 0
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
update_wheel(player)
|
||||
end
|
||||
end--timer
|
||||
end)
|
|
@ -1,73 +0,0 @@
|
|||
-- Armor
|
||||
function hud.set_armor()
|
||||
end
|
||||
|
||||
if hud.show_armor then
|
||||
local shields = minetest.get_modpath("shields") ~= nil
|
||||
local armor_org_func = armor.set_player_armor
|
||||
|
||||
local function get_armor_lvl(def)
|
||||
-- items/protection based display
|
||||
local lvl = def.level or 0
|
||||
local max = 63 -- full diamond armor
|
||||
if shields then
|
||||
max = 84.14 -- full diamond armor + diamond shield
|
||||
end
|
||||
-- TODO: is there a sane way to read out max values?
|
||||
local ret = lvl/max
|
||||
if ret > 1 then
|
||||
ret = 1
|
||||
end
|
||||
|
||||
return tonumber(20 * ret)
|
||||
end
|
||||
|
||||
function armor.set_player_armor(self, player)
|
||||
armor_org_func(self, player)
|
||||
local name = player:get_player_name()
|
||||
local def = self.def
|
||||
local armor_lvl = 0
|
||||
if def[name] and def[name].level then
|
||||
armor_lvl = get_armor_lvl(def[name])
|
||||
end
|
||||
hud.change_item(player, "armor", {number = armor_lvl})
|
||||
end
|
||||
end
|
||||
|
||||
function hud.notify_hunger(delay, use)
|
||||
local txt_part = "enable"
|
||||
if use then
|
||||
txt_part = "use"
|
||||
end
|
||||
minetest.after(delay, function()
|
||||
minetest.chat_send_all("#Better HUD: You can't " .. txt_part .. " hunger without the \"hunger\" mod")
|
||||
minetest.chat_send_all(" Enable it or download it from \"https://github.com/BlockMen/hunger\"")
|
||||
end)
|
||||
end
|
||||
|
||||
-- Hunger related functions
|
||||
if not hud.show_hunger then
|
||||
function hud.set_hunger()
|
||||
hud.notify_hunger(1, true)
|
||||
end
|
||||
|
||||
function hud.get_hunger()
|
||||
hud.notify_hunger(1, true)
|
||||
end
|
||||
|
||||
function hud.item_eat(hp_change, replace_with_item)
|
||||
return function(itemstack, user, pointed_thing)
|
||||
hud.notify_hunger(1, true)
|
||||
local func = minetest.item_eat(hp_change, replace_with_item)
|
||||
return func(itemstack, user, pointed_thing)
|
||||
end
|
||||
end
|
||||
|
||||
function hud.save_hunger()
|
||||
hud.notify_hunger(1, true)
|
||||
end
|
||||
|
||||
function hud.load_hunger(player)
|
||||
hud.notify_hunger(1, true)
|
||||
end
|
||||
end
|
Before Width: | Height: | Size: 216 B |
Before Width: | Height: | Size: 579 B |
Before Width: | Height: | Size: 424 B |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 369 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 417 B |
Before Width: | Height: | Size: 522 B |
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 143 B |
|
@ -17,7 +17,7 @@ inventory_plus = {}
|
|||
inventory_plus.buttons = {}
|
||||
|
||||
-- default inventory page
|
||||
inventory_plus.default = minetest.settings:get("inventory_default") or "main"
|
||||
inventory_plus.default = "main"
|
||||
|
||||
-- register_button
|
||||
inventory_plus.register_button = function(player, name, label)
|
||||
|
|
|
@ -8,7 +8,7 @@ color7 = minetest.setting_get("color7") or "FFFF00"
|
|||
color8 = minetest.setting_get("color8") or "FF69B4"
|
||||
|
||||
local source_list = {
|
||||
{"black", "Color1", color1, 40, 36, 33},
|
||||
{"black", "Color1", color1, 41, 36, 33},
|
||||
{"blue", "Color2", color2, 0, 0, 255},
|
||||
{"green", "Color3", color3, 0, 255, 0},
|
||||
{"white", "Color4", color4, 245, 245, 245},
|
||||
|
|
|
@ -29,6 +29,6 @@ local default_path = minetest.get_modpath("default")
|
|||
|
||||
dofile(default_path.."/functions.lua")
|
||||
dofile(default_path.."/mapgen.lua")
|
||||
dofile(default_path.."/player.lua")
|
||||
dofile(default_path.."/aliases.lua")
|
||||
dofile(default_path.."/creative.lua")
|
||||
dofile(default_path.."/player.lua")
|
|
@ -72,6 +72,9 @@ function default.player_set_model(player, model_name)
|
|||
textures = player_textures[name] or model.textures,
|
||||
visual = "mesh",
|
||||
visual_size = 4,
|
||||
collisionbox = model.collisionbox or {-0.3, -1.00, -0.3, 0.3, 1.0, 0.3},
|
||||
stepheight = model.stepheight or 0.4,
|
||||
eye_height = model.eye_height or 0.8,
|
||||
})
|
||||
default.player_set_animation(player, "stand")
|
||||
else
|
||||
|
|