forked from VoxeLibre/VoxeLibre
Remember Hardcore mode:
Add a flag to hardcore worlds on world creation; so that they remain in hardcore mode despite any change settings change.
This commit is contained in:
parent
e6bf27f9b2
commit
eeb8eb97b6
|
@ -486,16 +486,9 @@ function hb.get_hudbar_identifiers()
|
||||||
return ids
|
return ids
|
||||||
end
|
end
|
||||||
|
|
||||||
local hardcore_mode = minetest.settings:get_bool("hardcore_mode_enabled", false)
|
|
||||||
if hardcore_mode then
|
|
||||||
heart_texture_fg = "hudbars_icon_health_hardcore.png"
|
|
||||||
else
|
|
||||||
heart_texture_fg = "hudbars_icon_health.png"
|
|
||||||
end
|
|
||||||
|
|
||||||
--register built-in HUD bars
|
--register built-in HUD bars
|
||||||
if minetest.settings:get_bool("enable_damage") or hb.settings.forceload_default_hudbars then
|
if minetest.settings:get_bool("enable_damage") or hb.settings.forceload_default_hudbars then
|
||||||
hb.register_hudbar("health", 0xFFFFFF, S("Health"), { bar = "hudbars_bar_health.png", icon = heart_texture_fg, bgicon = "hudbars_bgicon_health.png" }, 0, 20, 20, false)
|
hb.register_hudbar("health", 0xFFFFFF, S("Health"), { bar = "hudbars_bar_health.png", icon = "hudbars_icon_health.png", bgicon = "hudbars_bgicon_health.png" }, 0, 20, 20, false)
|
||||||
hb.register_hudbar("breath", 0xFFFFFF, S("Breath"), { bar = "hudbars_bar_breath.png", icon = "hudbars_icon_breath.png", bgicon = "hudbars_bgicon_breath.png" }, 1, 10, 10, true)
|
hb.register_hudbar("breath", 0xFFFFFF, S("Breath"), { bar = "hudbars_bar_breath.png", icon = "hudbars_icon_breath.png", bgicon = "hudbars_bgicon_breath.png" }, 1, 10, 10, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,15 @@ for _,_ in pairs(EF) do
|
||||||
end
|
end
|
||||||
|
|
||||||
local icon_ids = {}
|
local icon_ids = {}
|
||||||
local hardcore_mode = minetest.settings:get_bool("hardcore_mode_enabled", false)
|
|
||||||
|
|
||||||
if hardcore_mode then
|
-- Hardcore mode Healthbar change
|
||||||
|
local hardcore_mode = minetest.settings:get_bool("hardcore_mode_enabled", false)
|
||||||
|
local file = io.open(minetest.get_worldpath().."/hardcore_mode.txt", "r")
|
||||||
|
if file ~= nil then
|
||||||
|
hardcore_world = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if hardcore_mode or hardcore_world then
|
||||||
heart_texture_fg = "hudbars_icon_health_hardcore.png"
|
heart_texture_fg = "hudbars_icon_health_hardcore.png"
|
||||||
else
|
else
|
||||||
heart_texture_fg = "hudbars_icon_health.png"
|
heart_texture_fg = "hudbars_icon_health.png"
|
||||||
|
|
|
@ -8,13 +8,24 @@ of the license, or (at your option) any later version.
|
||||||
|
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
--Spectator mode:
|
-- Spectator mode:
|
||||||
-- Players are unable to interact with the world, invisible, have fast, fly & noclip, are immortal and their health/hunger hudbars are hidden.
|
-- Players are unable to interact with the world, invisible, have fast, fly & noclip, are immortal and their health/hunger hudbars are hidden.
|
||||||
|
--
|
||||||
|
--
|
||||||
|
|
||||||
|
mcl_hardcore = {}
|
||||||
|
|
||||||
|
-- Write Hardcore mode state to world.
|
||||||
|
function mcl_hardcore.save()
|
||||||
|
local file = io.open(minetest.get_worldpath().."/hardcore_mode.txt", "w")
|
||||||
|
if file then
|
||||||
|
file:write("Enabled")
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Spectator mode
|
-- Spectator mode
|
||||||
mcl_hardcore = {}
|
|
||||||
|
|
||||||
function mcl_hardcore.spectator_mode(player)
|
function mcl_hardcore.spectator_mode(player)
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
|
@ -63,8 +74,18 @@ function mcl_hardcore.spectator_mode_disabled(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local hardcore_mode = minetest.settings:get_bool("hardcore_mode_enabled", false)
|
-- Hardcore mode
|
||||||
if hardcore_mode then
|
function mcl_hardcore.hardcore_mode(player)
|
||||||
|
local meta = player:get_meta()
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
if meta:get_int("dead") == 1 then
|
||||||
|
mcl_hardcore.spectator_mode(player)
|
||||||
|
minetest.chat_send_player(player_name, "You died in hardcore mode; rejoining as a spectator.")
|
||||||
|
else
|
||||||
|
minetest.after(4, function(player)
|
||||||
|
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health_hardcore.png", nil, "hudbars_bar_health.png")
|
||||||
|
end, player)
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player, reason)
|
minetest.register_on_dieplayer(function(player, reason)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
@ -81,20 +102,22 @@ if hardcore_mode then
|
||||||
minetest.chat_send_player(player_name, "You died in hardcore mode; respawning as a spectator.")
|
minetest.chat_send_player(player_name, "You died in hardcore mode; respawning as a spectator.")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- If hardcore is enabled or re-enabled, & you've already died once; ensure that you're a spectator when rejoining.
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
local meta = player:get_meta()
|
|
||||||
local player_name = player:get_player_name()
|
|
||||||
if meta:get_int("dead") == 1 then
|
|
||||||
mcl_hardcore.spectator_mode(player)
|
|
||||||
minetest.chat_send_player(player_name, "You died in hardcore mode; rejoining as a spectator.")
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
else
|
|
||||||
-- If hardcore disabled, make sure settings are back to basics via the 'spectator_mode_disabled' function.
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
mcl_hardcore.spectator_mode_disabled(player)
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local hardcore_mode = minetest.settings:get_bool("hardcore_mode_enabled", false)
|
||||||
|
--Set world state:
|
||||||
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
if minetest.get_gametime() <= 5 and hardcore_mode then
|
||||||
|
mcl_hardcore.save()
|
||||||
|
else
|
||||||
|
local file = io.open(minetest.get_worldpath().."/hardcore_mode.txt", "r")
|
||||||
|
if file ~= nil then
|
||||||
|
hardcore_world = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if hardcore_mode or hardcore_world then
|
||||||
|
mcl_hardcore.hardcore_mode(player)
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
Before Width: | Height: | Size: 948 B After Width: | Height: | Size: 948 B |
|
@ -39,7 +39,7 @@ mcl_doTileDrops (Blocks have drops) bool true
|
||||||
# If enabled, TNT explosions destroy blocks.
|
# If enabled, TNT explosions destroy blocks.
|
||||||
mcl_tnt_griefing (TNT destroys blocks) bool true
|
mcl_tnt_griefing (TNT destroys blocks) bool true
|
||||||
|
|
||||||
# If enabled, you will only have 1 life to use. After death you will be dropped into spectator mode, and unable to interact with the world while 'hardcore_mode' is enabled.
|
# If enabled, you will only have 1 life to use. After death you will be dropped into spectator mode, and unable to interact with the world.
|
||||||
hardcore_mode_enabled (Enable Hardcore mode) bool false
|
hardcore_mode_enabled (Enable Hardcore mode) bool false
|
||||||
|
|
||||||
[Players]
|
[Players]
|
||||||
|
|
Loading…
Reference in New Issue