исправления багов

This commit is contained in:
Vitaliy Olkhin 2024-08-05 15:07:18 +05:00
parent 7368ed1cc5
commit 9e50640617
3 changed files with 32 additions and 21 deletions

View File

@ -38,13 +38,12 @@ surface_effect.setHud = function(player)
if type(surface_effect.nplayer[name]) == 'nil' then
surface_effect.nplayer[name] = {
radiation_damage = "OFF",
radiation_damage = false,
id_varning_text = false,
logo = 'off',
id_mask = false,
id_status_chemical = false,
}
minetest.log("action", "Load nplayer: " .. surface_effect.dump(surface_effect.nplayer))
end
end
@ -96,10 +95,11 @@ end
surface_effect.radiaton_off = function(player)
local name = player:get_player_name()
if surface_effect.nplayer[name]["radiation_damage"] == "ON" then
if surface_effect.nplayer[name]["radiation_damage"] == true then
player:hud_remove(surface_effect.nplayer[name]['id_varning_text'])
surface_effect.nplayer[name]["radiation_damage"] = "OFF"
surface_effect.nplayer[name]["id_varning_text"] = nil
surface_effect.nplayer[name]["radiation_damage"] = false
surface_effect.nplayer[name]["id_varning_text"] = false
end
end
@ -205,28 +205,29 @@ su.rediationDomage = function (player, pos)
duration = 10, -- this effect will last 10 seconds
effect = function(player)
if surface_effect.nplayer[name]['radiation_damage'] == "OFF" then
if surface_effect.nplayer[name]['radiation_damage'] == false then
local idtext = player:hud_add({
name = "Attention! Radiation ",
name = "Attention! Radiation",
hud_elem_type = "text",
position = {x = 1, y = 0.5},
offset = {x = -180, y = 0},
text = S("Attention! High levels of radiation."),
alignment = -1,
alignment = -2,
scale = { x = 50, y = 10},
number = 0xFF0000,
})
minetest.after(1.52, function(name, id)
--[[minetest.after(1.52, function(name, id)
local player = minetest.get_player_by_name(name)
if player then
--player:hud_remove(id)
else
-- player has left the game
end
end, player:get_player_name(), id)
surface_effect.nplayer[name]["radiation_damage"] = "ON"
end, player:get_player_name(), id)]]
surface_effect.nplayer[name]["id_varning_text"] = idtext
surface_effect.nplayer[name]["radiation_damage"] = true
end
if surface_effect.checkHazmat(player) == false then
@ -236,6 +237,8 @@ su.rediationDomage = function (player, pos)
end,
persistence = 2, -- every 0.1 seconds for 10 seconds the previous function will be run.
})
return
else
surface_effect.radiaton_off(player)
end

View File

@ -47,26 +47,29 @@ minetest.register_on_newplayer(function(player)
end
end)
--Событие когда игрок заходит на сервер
minetest.register_on_joinplayer(function(player, last_login)
surface_effect.setHud(player)
surface_effect.showLogo(player)
local name = player:get_player_name()
surface_effect.nplayer[name]['radiation_damage'] = false
local pos = player:get_pos()
surface_effect.mask(player)
surface_effect.nplayer[name]['logo'] = 'off'
su.rediationDomage(player, pos)
end )
minetest.register_on_prejoinplayer(function(name, ip)
--[[minetest.register_on_prejoinplayer(function(name, ip)
local player = minetest.get_player_by_name(name)
--Защита игрока отсмерти на спавне
--[[if object then
if object then
local pos = object:get_pos()
su.rediationDomage(player, pos)
end]]
end)
end
end)]]
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
@ -82,9 +85,14 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch,
end )
--Вызывается, когда игрок покидает игру
--[[minetest.register_on_leaveplayer(function(player, timed_out)
end)]]
minetest.register_on_leaveplayer(function(player, timed_out)
local name = player:get_player_name()
surface_effect.nplayer[name]['logo'] = 'off'
surface_effect.nplayer[name]["radiation_damage"] = false
surface_effect.nplayer[name]["id_varning_text"] = false
surface_effect.nplayer[name]["id_mask"] = false
surface_effect.nplayer[name]["id_varning_text"] = false
end)
local mobs_monster = {
{name = "mobs_monster:sand_monster"},

View File

@ -1,7 +1,7 @@
name = surface_effect
description = surface effect
depends = default, persistent_effects, mobs_monster, radiant_damage
optional_depends = technic
depends = default, persistent_effects, mobs_monster, radiant_damage, hazmat_suit
optional_depends = technic, farming
min_minetest_version = 5.7
title = Surface Effect
release = 0