finally fixed crash
parent
58f672b7c6
commit
0bb1a89b7b
69
init.lua
69
init.lua
|
@ -15,7 +15,10 @@ GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
--]]
|
--]]
|
||||||
|
--Carbone death coords
|
||||||
|
--License of media (textures and sounds) From carbone subgame
|
||||||
|
--------------------------------------
|
||||||
|
--mods/default/sounds/player_death.ogg: from OpenArena – GNU GPL v2.
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
local title = "Death Messages"
|
local title = "Death Messages"
|
||||||
local version = "0.1.2"
|
local version = "0.1.2"
|
||||||
|
@ -168,8 +171,13 @@ minetest.register_on_dieplayer(function(player)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
local node = minetest.registered_nodes[minetest.get_node(player:getpos()).name]
|
local node = minetest.registered_nodes[minetest.get_node(player:getpos()).name]
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
--local death = {x=0, y=-2, z=0}
|
local death = {x=0, y=23, z=-1.5}
|
||||||
--local holding = player:get_wielded_item() --added to fix?
|
minetest.sound_play("player_death", {pos = pos, gain = 1})
|
||||||
|
pos.x = math.floor(pos.x + 0.5)
|
||||||
|
pos.y = math.floor(pos.y + 0.5)
|
||||||
|
pos.z = math.floor(pos.z + 0.5)
|
||||||
|
local param2 = minetest.dir_to_facedir(player:get_look_dir())
|
||||||
|
local player_name = player:get_player_name()
|
||||||
if minetest.is_singleplayer() then
|
if minetest.is_singleplayer() then
|
||||||
player_name = "You"
|
player_name = "You"
|
||||||
end
|
end
|
||||||
|
@ -179,46 +187,54 @@ minetest.register_on_dieplayer(function(player)
|
||||||
minetest.chat_send_all(
|
minetest.chat_send_all(
|
||||||
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
||||||
string.char(0x1b).."(c@#ff0000)"..get_message("lava"))
|
string.char(0x1b).."(c@#ff0000)"..get_message("lava"))
|
||||||
|
player:setpos(death)
|
||||||
elseif node.name == "default:lava_flowing" then
|
elseif node.name == "default:lava_flowing" then
|
||||||
minetest.chat_send_all(
|
minetest.chat_send_all(
|
||||||
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
||||||
string.char(0x1b).."(c@#ff0000)"..get_message("lava"))
|
string.char(0x1b).."(c@#ff0000)"..get_message("lava"))
|
||||||
|
player:setpos(death)
|
||||||
-- Death by drowning
|
-- Death by drowning
|
||||||
elseif player:get_breath() == 0 then
|
elseif player:get_breath() == 0 then
|
||||||
minetest.chat_send_all(
|
minetest.chat_send_all(
|
||||||
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
||||||
string.char(0x1b).."(c@#ff0000)"..get_message("water"))
|
string.char(0x1b).."(c@#ff0000)"..get_message("water"))
|
||||||
|
player:setpos(death)
|
||||||
-- Death by fire
|
-- Death by fire
|
||||||
elseif node.name == "fire:basic_flame" then
|
elseif node.name == "fire:basic_flame" then
|
||||||
minetest.chat_send_all(
|
minetest.chat_send_all(
|
||||||
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
||||||
string.char(0x1b).."(c@#ff0000)"..get_message("fire"))
|
string.char(0x1b).."(c@#ff0000)"..get_message("fire"))
|
||||||
|
player:setpos(death)
|
||||||
-- Death by Toxic water
|
-- Death by Toxic water
|
||||||
elseif node.name == "es:toxic_water_source" then
|
elseif node.name == "es:toxic_water_source" then
|
||||||
minetest.chat_send_all(
|
minetest.chat_send_all(
|
||||||
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
||||||
string.char(0x1b).."(c@#ff0000)"..get_message("toxic"))
|
string.char(0x1b).."(c@#ff0000)"..get_message("toxic"))
|
||||||
--player:setpos(death)
|
player:setpos(death)
|
||||||
elseif node.name == "es:toxic_water_flowing" then
|
elseif node.name == "es:toxic_water_flowing" then
|
||||||
minetest.chat_send_all(
|
minetest.chat_send_all(
|
||||||
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
||||||
string.char(0x1b).."(c@#ff0000)"..get_message("toxic"))
|
string.char(0x1b).."(c@#ff0000)"..get_message("toxic"))
|
||||||
--player:setpos(death)
|
player:setpos(death)
|
||||||
elseif node.name == "groups:radioactive" then
|
elseif node.name == "groups:radioactive" then
|
||||||
minetest.chat_send_all(
|
minetest.chat_send_all(
|
||||||
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
||||||
string.char(0x1b).."(c@#ff0000)"..get_message("toxic"))
|
string.char(0x1b).."(c@#ff0000)"..get_message("toxic"))
|
||||||
--player:setpos(death)
|
player:setpos(death)
|
||||||
|
|
||||||
-- Death by something else
|
-- Death by something else
|
||||||
else
|
else
|
||||||
--minetest.chat_send_all(
|
minetest.chat_send_all(
|
||||||
--string.char(0x1b).."(c@#ffffff)"..player_name ..
|
string.char(0x1b).."(c@#ffffff)"..player_name ..
|
||||||
--string.char(0x1b).."(c@#ff0000)"..get_message("other")) --toospammy
|
string.char(0x1b).."(c@#ff0000)"..get_message("other")) --toospammy
|
||||||
|
minetest.after(0.5, function(holding)
|
||||||
|
player:setpos(death) --gamebreaker?
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
minetest.chat_send_all(string.char(0x1b).."(c@#000000)".."[DEATH COORDINATES] "..string.char(0x1b).."(c@#ffffff)" .. player_name .. string.char(0x1b).."(c@#000000)".." left a corpse full of diamonds here: " ..
|
||||||
|
minetest.pos_to_string(pos) .. string.char(0x1b).."(c@#aaaaaa)".." Come and get them!")
|
||||||
--player:setpos(death)
|
--player:setpos(death)
|
||||||
minetest.sound_play("pacmine_death", { gain = 0.35})
|
minetest.sound_play("pacmine_death", { gain = 0.35})
|
||||||
|
|
||||||
|
@ -231,7 +247,7 @@ end)
|
||||||
-- get tool/item when hitting get_name() returns item name (e.g. "default:stone")
|
-- get tool/item when hitting get_name() returns item name (e.g. "default:stone")
|
||||||
minetest.register_on_punchplayer(function(player, hitter)
|
minetest.register_on_punchplayer(function(player, hitter)
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
local death = {x=0, y=-2, z=0}
|
local death = {x=0, y=23, z=-1.5}
|
||||||
if not (player or hitter) then
|
if not (player or hitter) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -245,7 +261,6 @@ minetest.register_on_punchplayer(function(player, hitter)
|
||||||
if holding:to_string() ~= "" then
|
if holding:to_string() ~= "" then
|
||||||
local weap = holding:get_name(holding:get_name())
|
local weap = holding:get_name(holding:get_name())
|
||||||
if holding then
|
if holding then
|
||||||
--player:setpos(death)
|
|
||||||
minetest.chat_send_all(
|
minetest.chat_send_all(
|
||||||
string.char(0x1b).."(c@#ffffff)"..player:get_player_name()..
|
string.char(0x1b).."(c@#ffffff)"..player:get_player_name()..
|
||||||
string.char(0x1b).."(c@#ff0000)".." was"..
|
string.char(0x1b).."(c@#ff0000)".." was"..
|
||||||
|
@ -255,6 +270,7 @@ minetest.register_on_punchplayer(function(player, hitter)
|
||||||
string.char(0x1b).."(c@#ffffff)".." with "..
|
string.char(0x1b).."(c@#ffffff)".." with "..
|
||||||
string.char(0x1b).."(c@#00bbff)"..weap..
|
string.char(0x1b).."(c@#00bbff)"..weap..
|
||||||
string.char(0x1b).."(c@#00bbff)"..get_message("player")) --TODO: make custom mob death messages
|
string.char(0x1b).."(c@#00bbff)"..get_message("player")) --TODO: make custom mob death messages
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -268,36 +284,17 @@ minetest.register_on_punchplayer(function(player, hitter)
|
||||||
string.char(0x1b).."(c@#ff0000)".." was"..
|
string.char(0x1b).."(c@#ff0000)".." was"..
|
||||||
string.char(0x1b).."(c@#ff0000)"..get_message("pvp")..
|
string.char(0x1b).."(c@#ff0000)"..get_message("pvp")..
|
||||||
string.char(0x1b).."(c@#ff0000)".." by "..
|
string.char(0x1b).."(c@#ff0000)".." by "..
|
||||||
string.char(0x1b).."(c@#ffffff)"..hitter:get_luaentity().name..
|
string.char(0x1b).."(c@#ffffff)"..hitter:get_luaentity().name.. --too many mobs add to crash
|
||||||
string.char(0x1b).."(c@#00bbff)"..get_message("mobs")) --TODO: make custom mob death messages
|
string.char(0x1b).."(c@#00bbff)"..get_message("mobs")) --TODO: make custom mob death messages
|
||||||
|
|
||||||
if player=="" or hitter=="" then return end -- no mob killers/victims
|
if player=="" or hitter=="" or hitter=="*" then return end -- no mob killers/victims
|
||||||
else
|
else
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
end)
|
end)
|
||||||
end)
|
|
||||||
|
|
||||||
--Carbone death coords
|
|
||||||
--License of media (textures and sounds) From carbone subgame
|
|
||||||
--------------------------------------
|
|
||||||
--mods/default/sounds/player_death.ogg: from OpenArena – GNU GPL v2.
|
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player)
|
|
||||||
local pos = player:getpos()
|
|
||||||
--local death = {x=0, y=-2, z=0} --old spawnjail
|
|
||||||
local death = {x=0, y=23, z=-1.5}
|
|
||||||
minetest.sound_play("player_death", {pos = pos, gain = 1})
|
|
||||||
pos.x = math.floor(pos.x + 0.5)
|
|
||||||
pos.y = math.floor(pos.y + 0.5)
|
|
||||||
pos.z = math.floor(pos.z + 0.5)
|
|
||||||
local param2 = minetest.dir_to_facedir(player:get_look_dir())
|
|
||||||
local player_name = player:get_player_name()
|
|
||||||
|
|
||||||
minetest.chat_send_all(string.char(0x1b).."(c@#000000)".."[DEATH COORDINATES] "..string.char(0x1b).."(c@#ffffff)" .. player_name .. string.char(0x1b).."(c@#000000)".." left a corpse full of diamonds here: " ..
|
|
||||||
minetest.pos_to_string(pos) .. string.char(0x1b).."(c@#aaaaaa)".." Come and get them!")
|
|
||||||
player:setpos(death) --Important
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue