Множественные различные изменения
This commit is contained in:
parent
b2e595777a
commit
2ba4c9ade7
71
function.lua
71
function.lua
@ -29,7 +29,6 @@ surface_effect.showLogo = function(player)
|
|||||||
})
|
})
|
||||||
|
|
||||||
surface_effect.nplayer[name]['logo'] = "on"
|
surface_effect.nplayer[name]['logo'] = "on"
|
||||||
|
|
||||||
minetest.log("action", name .. " status logo " .. surface_effect.nplayer[name]['logo'] .. " id " .. id)
|
minetest.log("action", name .. " status logo " .. surface_effect.nplayer[name]['logo'] .. " id " .. id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -43,14 +42,43 @@ surface_effect.setHud = function(player)
|
|||||||
id_varning_text = false,
|
id_varning_text = false,
|
||||||
logo = 'off',
|
logo = 'off',
|
||||||
id_mask = false,
|
id_mask = false,
|
||||||
|
id_status_chemical = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
minetest.log("action", "Load nplayer: " .. surface_effect.dump(surface_effect.nplayer))
|
minetest.log("action", "Load nplayer: " .. surface_effect.dump(surface_effect.nplayer))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--Состояние костюма химической защиты вывод в процентах.
|
||||||
|
surface_effect.getHazmatState = function(player)
|
||||||
|
local name, inv = armor:get_valid_player(player)
|
||||||
|
|
||||||
|
if not name then
|
||||||
|
return -- Armor not initialized yet
|
||||||
|
end
|
||||||
|
|
||||||
|
if not inv:contains_item("armor", "hazmat_suit:suit_hazmat") then
|
||||||
|
return -- Skip checking every stack
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1, inv:get_size("armor") do
|
||||||
|
local stack = inv:get_stack("armor", i)
|
||||||
|
|
||||||
|
if stack:get_name() == "hazmat_suit:suit_hazmat" then
|
||||||
|
local arm = 65535 / 100
|
||||||
|
local percent = (65535 - stack:get_wear()) / arm
|
||||||
|
|
||||||
|
--stack:add_wear(1)
|
||||||
|
--inv:set_stack("armor", i, stack)
|
||||||
|
--armor:save_armor_inventory(player)
|
||||||
|
return math.round(percent)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
surface_effect.checkHazmat = function(player)
|
surface_effect.checkHazmat = function(player)
|
||||||
local armor = armor:get_weared_armor_elements (player)
|
local armor = armor:get_weared_armor_elements (player)
|
||||||
|
surface_effect.getHazmatState(player)
|
||||||
|
|
||||||
if armor ~= 'nil' then
|
if armor ~= 'nil' then
|
||||||
if type(armor) == 'nil' then return false end
|
if type(armor) == 'nil' then return false end
|
||||||
@ -122,11 +150,36 @@ surface_effect.mask = function(player)
|
|||||||
text = "surface_effect_mask.png"
|
text = "surface_effect_mask.png"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
surface_effect.nplayer[name]["id_status_chemical"] = player:hud_add({
|
||||||
|
name = "Chemical protection status indicator",
|
||||||
|
hud_elem_type = "text",
|
||||||
|
position = {x = 0.7, y = 0.1},
|
||||||
|
offset = {x = 60, y = -50},
|
||||||
|
scale = {
|
||||||
|
x = 50,
|
||||||
|
y = 10
|
||||||
|
},
|
||||||
|
z_index = -99,
|
||||||
|
size = 2,
|
||||||
|
text = S("Chemical protection status: @1%", surface_effect.getHazmatState(player)),
|
||||||
|
number = 0x000000
|
||||||
|
})
|
||||||
|
|
||||||
surface_effect.nplayer[name]["id_mask"] = id
|
surface_effect.nplayer[name]["id_mask"] = id
|
||||||
|
|
||||||
elseif surface_effect.nplayer[name]["id_mask"] ~= false and surface_effect.checkHazmat(player) == false then
|
elseif surface_effect.nplayer[name]["id_mask"] ~= false and surface_effect.checkHazmat(player) == false then
|
||||||
player:hud_remove(surface_effect.nplayer[name]['id_mask'])
|
player:hud_remove(surface_effect.nplayer[name]['id_mask'])
|
||||||
surface_effect.nplayer[name]["id_mask"] = false
|
surface_effect.nplayer[name]["id_mask"] = false
|
||||||
|
|
||||||
|
player:hud_remove(surface_effect.nplayer[name]['id_status_chemical'])
|
||||||
|
surface_effect.nplayer[name]["id_status_chemical"] = false
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if surface_effect.nplayer[name]["id_status_chemical"] ~= false then
|
||||||
|
player:hud_change(surface_effect.nplayer[name]["id_status_chemical"],
|
||||||
|
"text", S("Chemical protection status: @1%", surface_effect.getHazmatState(player)))
|
||||||
end
|
end
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -186,3 +239,19 @@ su.rediationDomage = function (player, pos)
|
|||||||
surface_effect.radiaton_off(player)
|
surface_effect.radiaton_off(player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
surface_effect.detectNuclides = function (player)
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
if inv:contains_item("main", "surface_effect:dosimeter") then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
|
||||||
|
--[[for i=1, inv:get_size("main") do
|
||||||
|
local stack = inv:get_stack("main", i)
|
||||||
|
if stack:get_name() == "surface_effect:dosimeter" then
|
||||||
|
use_battery(stack)
|
||||||
|
inv:set_stack("main", i, stack)
|
||||||
|
end
|
||||||
|
end]]
|
||||||
|
end
|
18
init.lua
18
init.lua
@ -6,6 +6,7 @@ local timer = 0
|
|||||||
|
|
||||||
dofile(minetest.get_modpath("surface_effect") .. "/function.lua")
|
dofile(minetest.get_modpath("surface_effect") .. "/function.lua")
|
||||||
dofile(minetest.get_modpath("surface_effect") .. "/nodes.lua")
|
dofile(minetest.get_modpath("surface_effect") .. "/nodes.lua")
|
||||||
|
dofile(minetest.get_modpath("surface_effect") .. "/register_abm.lua")
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
-- every 5 seconds
|
-- every 5 seconds
|
||||||
@ -110,9 +111,18 @@ local on_radiation_damage = function(player, damage, pos)
|
|||||||
end
|
end
|
||||||
damage = math.floor(damage)
|
damage = math.floor(damage)
|
||||||
if damage > 0 then
|
if damage > 0 then
|
||||||
minetest.log("action", player:get_player_name() .. " takes " .. tostring(damage) .. " damage from mese radiation damage at " .. minetest.pos_to_string(pos))
|
minetest.log("action", player:get_player_name() .. " Hazmat " .. surface_effect.dump(surface_effect.checkHazmat(player)) .. " pos" .. minetest.pos_to_string(pos))
|
||||||
player:set_hp(player:get_hp() - damage)
|
|
||||||
minetest.sound_play({name = "radiant_damage_geiger", gain = math.min(1, damage/10)}, {to_player=player:get_player_name()})
|
if surface_effect.checkHazmat(player) == false then
|
||||||
|
minetest.log("action", player:get_player_name() .. " takes " .. tostring(damage) .. " damage from radiation damage earth at " .. minetest.pos_to_string(pos))
|
||||||
|
player:set_hp(player:get_hp() - damage)
|
||||||
|
end
|
||||||
|
|
||||||
|
if surface_effect.detectNuclides(player) then
|
||||||
|
minetest.sound_play({name = "radiant_damage_geiger", gain = math.min(1, damage/10)}, {
|
||||||
|
to_player=player:get_player_name()
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -122,7 +132,7 @@ radiant_damage.register_radiant_damage("radioactive_earth", {
|
|||||||
--inverse_square_falloff = true,
|
--inverse_square_falloff = true,
|
||||||
emitted_by = {["surface_effect:radioactive_earth"] = 0.5},
|
emitted_by = {["surface_effect:radioactive_earth"] = 0.5},
|
||||||
attenuated_by = {['air'] = 0.4, ['default:grass_1'] = 0.5},
|
attenuated_by = {['air'] = 0.4, ['default:grass_1'] = 0.5},
|
||||||
default_attenuation = 1,
|
default_attenuation = 2,
|
||||||
on_damage = on_radiation_damage,
|
on_damage = on_radiation_damage,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# textdomain: surface_effect
|
# textdomain: surface_effect
|
||||||
Attention! High levels of radiation.=Внимание! Высокий уровень радиации.
|
Attention! High levels of radiation.=Внимание! Высокий уровень радиации.
|
||||||
|
Chemical protection status: @1%=Состояние химзащиты: @1%
|
||||||
|
|
||||||
#nodes lua
|
#nodes lua
|
||||||
Irradiated Earth=Облученная земля
|
Irradiated Earth=Облученная земля
|
||||||
|
Dosimeter=Дозиметр
|
2
mod.conf
2
mod.conf
@ -1,6 +1,6 @@
|
|||||||
name = surface_effect
|
name = surface_effect
|
||||||
description = surface effect
|
description = surface effect
|
||||||
depends = default, persistent_effects, mobs_monster
|
depends = default, persistent_effects, mobs_monster, radiant_damage
|
||||||
optional_depends = technic
|
optional_depends = technic
|
||||||
min_minetest_version = 5.7
|
min_minetest_version = 5.7
|
||||||
title = Surface Effect
|
title = Surface Effect
|
||||||
|
12
nodes.lua
12
nodes.lua
@ -16,13 +16,7 @@ minetest.register_node("surface_effect:radioactive_earth", {
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_tool("surface_effect:dosimeter", {
|
||||||
nodenames = {"default:dirt_with_grass"},
|
description = S("Dosimeter"),
|
||||||
interval = 10,
|
inventory_image = "surface_effect_dosimeter.png"
|
||||||
chance = 50,
|
|
||||||
action = function(pos)
|
|
||||||
if pos.y > -10 and pos.y < 1500 then
|
|
||||||
minetest.env:add_node(pos, {name="surface_effect:radioactive_earth"})
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
})
|
25
register_abm.lua
Normal file
25
register_abm.lua
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
local speed = minetest.setting_get("time_speed")/96
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"default:dirt_with_grass"},
|
||||||
|
interval = 10/speed,
|
||||||
|
chance = 50,
|
||||||
|
action = function(pos)
|
||||||
|
if pos.y > -10 and pos.y < 1500 then
|
||||||
|
minetest.env:add_node(pos, {name="surface_effect:radioactive_earth"})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
if minetest.get_modpath("areas") then
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"ethereal:grove_dirt"},
|
||||||
|
interval = 10/speed,
|
||||||
|
chance = 50,
|
||||||
|
action = function(pos)
|
||||||
|
if pos.y > -10 and pos.y < 1500 then
|
||||||
|
minetest.env:add_node(pos, {name="surface_effect:radioactive_earth"})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
Binary file not shown.
BIN
textures/surface_effect_dosimeter.png
Normal file
BIN
textures/surface_effect_dosimeter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Loading…
Reference in New Issue
Block a user