diff --git a/builtin/game/init.lua b/builtin/game/init.lua index 34061ed7d..e2635f07a 100644 --- a/builtin/game/init.lua +++ b/builtin/game/init.lua @@ -31,6 +31,6 @@ assert(loadfile(gamepath.."falling.lua"))(builtin_shared) dofile(gamepath.."features.lua") dofile(gamepath.."voxelarea.lua") dofile(gamepath.."forceloading.lua") ---dofile(gamepath.."statbars.lua") +dofile(gamepath.."statbars.lua") profiler = nil diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index f99768d6a..8b37dcc56 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -229,57 +229,3 @@ end function core.cancel_shutdown_requests() core.request_shutdown("", false, -1) end - -local hud, timer, wield = {}, {}, {} -local timeout = 2 - -local function add_text(player) - local player_name = player:get_player_name() - hud[player_name] = player:hud_add({ - hud_elem_type = "text", - position = {x = 0.5, y = 0.965}, - offset = {x = 0, y = -75}, - alignment = {x = 0, y = 0}, - number = 0xFFFFFF, - text = "", - }) -end - -core.register_on_joinplayer(function(player) - core.after(0, add_text, player) -end) - -core.register_globalstep(function(dtime) - local players = core.get_connected_players() - for i = 1, #players do - local player = players[i] - local player_name = player:get_player_name() - - local wielded_item = player:get_wielded_item() - local wielded_item_name = wielded_item:get_name() - - timer[player_name] = timer[player_name] and timer[player_name] + dtime or 0 - wield[player_name] = wield[player_name] or "" - - if timer[player_name] > timeout and hud[player_name] then - player:hud_change(hud[player_name], "text", "") - timer[player_name] = 0 - return - end - - if hud[player_name] and wielded_item_name ~= wield[player_name] then - wield[player_name] = wielded_item_name - timer[player_name] = 0 - - local def = core.registered_items[wielded_item_name] - local meta = wielded_item:get_meta() - local meta_desc = meta:get_string("description") - meta_desc = meta_desc:gsub("\27", ""):gsub("%(c@#%w%w%w%w%w%w%)", "") - - local description = meta_desc ~= "" and meta_desc or - (def and (def.description:match("(.-)\n") or def.description) or "") - - player:hud_change(hud[player_name], "text", description) - end - end -end) diff --git a/builtin/game/statbars.lua b/builtin/game/statbars.lua index 0909e726c..11f656f35 100644 --- a/builtin/game/statbars.lua +++ b/builtin/game/statbars.lua @@ -1,5 +1,5 @@ -- cache setting -local enable_damage = core.settings:get_bool("enable_damage") +--[[local enable_damage = core.settings:get_bool("enable_damage") local health_bar_definition = { @@ -162,4 +162,69 @@ end core.register_on_joinplayer(initialize_builtin_statbars) core.register_on_leaveplayer(cleanup_builtin_statbars) -core.register_playerevent(player_event_handler) +core.register_playerevent(player_event_handler)]] + +-- Hud Item name + +local hud, timer, wield = {}, {}, {} +local timeout = 2 +local textposition + +core.register_on_joinplayer(function(player) + if PLATFORM == "iOS" then + textposition = {x = 0.5, y = 0.89} + else + textposition = {x = 0.5, y = 0.975} + end +end) + +local function add_text(player) + local player_name = player:get_player_name() + hud[player_name] = player:hud_add({ + hud_elem_type = "text", + position = textposition, + offset = {x = 0, y = -75}, + alignment = {x = 0, y = 0}, + number = 0xFFFFFF, + text = "", + }) +end + +core.register_on_joinplayer(function(player) + core.after(1, add_text, player) +end) + +core.register_globalstep(function(dtime) + local players = core.get_connected_players() + for i = 1, #players do + local player = players[i] + local player_name = player:get_player_name() + + local wielded_item = player:get_wielded_item() + local wielded_item_name = wielded_item:get_name() + + timer[player_name] = timer[player_name] and timer[player_name] + dtime or 0 + wield[player_name] = wield[player_name] or "" + + if timer[player_name] > timeout and hud[player_name] then + player:hud_change(hud[player_name], "text", "") + timer[player_name] = 0 + return + end + + if hud[player_name] and wielded_item_name ~= wield[player_name] then + wield[player_name] = wielded_item_name + timer[player_name] = 0 + + local def = core.registered_items[wielded_item_name] + local meta = wielded_item:get_meta() + local meta_desc = meta:get_string("description") + meta_desc = meta_desc:gsub("\27", ""):gsub("%(c@#%w%w%w%w%w%w%)", "") + + local description = meta_desc ~= "" and meta_desc or + (def and (def.description:match("(.-)\n") or def.description) or "") + + player:hud_change(hud[player_name], "text", description) + end + end +end) diff --git a/builtin/mainmenu/tab_credits.lua b/builtin/mainmenu/tab_credits.lua index 597e65035..219e8f549 100644 --- a/builtin/mainmenu/tab_credits.lua +++ b/builtin/mainmenu/tab_credits.lua @@ -97,9 +97,9 @@ return { cbf_formspec = function(tabview, name, tabdata) local version = core.get_version() return "label[0.1,-0.1;MultiCraft Open Source Project, ver. " .. version.string .. "]" .. - "label[0.1,0.2;Copyright (c) 2014-2019 MultiCraft Developement Team]" .. - "label[0.1,0.5;Home page: https://github.com/MultiCraftProject/MultiCraft]" .. - "label[0.1,0.8;Licence: LGPLv3.0+ and CC-BY-SA 3.0]" .. + "label[0.1,0.3;Copyright (c) 2014-2019 MultiCraft Developement Team]" .. + "label[0.1,0.7;Home page: https://github.com/MultiCraftProject/MultiCraft]" .. + "label[0.1,1.1;Licence: LGPLv3.0+ and CC-BY-SA 3.0]" .. "tablecolumns[color;text]" .. "tableoptions[background=#999999;highlight=#00000000;border=true]" .. "table[0,1.6;11.8,3.8;list_credits;" .. diff --git a/builtin/mainmenu/tab_local.lua b/builtin/mainmenu/tab_local.lua index a45f3ef3f..fa3326532 100644 --- a/builtin/mainmenu/tab_local.lua +++ b/builtin/mainmenu/tab_local.lua @@ -49,7 +49,7 @@ local function get_formspec(tabview, name, tabdata) "local_creative_" .. tostring(creative_mode) .. "_btn.png") .. ";cb_creative_mode;;true;false]" .. - "textlist[-0.025,0.01;6.3,4.63;sp_worlds;" .. + "textlist[-0.01,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. ";true]" return retval diff --git a/textures/base/server_flags_mt.png b/textures/base/server_flags_mt.png index bf04e8fe2..8cad3bf40 100644 Binary files a/textures/base/server_flags_mt.png and b/textures/base/server_flags_mt.png differ