From e206cb74be79c35964519e2b6e577bcd04c2ae83 Mon Sep 17 00:00:00 2001 From: poikilos <7557867+poikilos@users.noreply.github.com> Date: Wed, 22 Feb 2017 18:55:30 -0500 Subject: [PATCH] fixes, and now bones writes to log instead of just printing to console --- README.md | 13 +++- games/ENLIVEN/mods/bones/init.lua | 9 +-- games/ENLIVEN/mods/protector/init.lua | 95 +++++++++++++-------------- 3 files changed, 64 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 6aee7a7..c467374 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,24 @@ Otherwise just install everything EXCEPT cme_to_spawners & tsm_pyramids_to_spawn ## Changes: -* (2017-02-15) (change homedecor_modpack/homedecor) Add optional non-adult beverage version of homedecor in homedecor_modpack (just changes display name & variable name of Wine rack and Beer tap and beer mug, and textures for beer mug) +* (2017-02-22) Fix protector crash (also sent to TenPlus1): +```lua + if player and player:is_player() and player:get_hp() > 0 then -- ADDED THIS LINE + -- hurt player if protection violated + + -- (a bunch of code is here for processing violations) -- + + end -- ADDED THIS LINE + return true +``` +* (2017-02-22) NOTE: the protector fix below was merged by TenPlus1 today * (2017-02-15) (change protector) Avoid crash by not allowing non-player to dig protected area (may only happen when one of the owners of an area does it--that was the crash scenario) changed return protector.can_dig(1, pos, player:get_player_name(), true, 1) to return player and protector.can_dig(1, pos, player:get_player_name(), true, 1) or false +* (2017-02-15) (change homedecor_modpack/homedecor) Add optional non-adult beverage version of homedecor in homedecor_modpack (just changes display name & variable name of Wine rack and Beer tap and beer mug, and textures for beer mug) * (2017-02-15) (change bones) Show player (and print to server console) where died (and say bones remain or why not) -- with this addition, you can search your server log for "player's bones" where player is playername whether bones remain or not. * (2017-02-14) (change mobs) Added some nonviolent textures that could be used in a school to the ENLIVEN/mods folder (they can be manually installed after ENLIVEN by copying them to the same place in your games/ENLIVEN folder on your installation of Minetest) * (2017-02-06) Added installation of trmp_minetest_game to the installer script, since treasurer requires one or more trms in order to work (tested and working now on tsm_railcorridors) diff --git a/games/ENLIVEN/mods/bones/init.lua b/games/ENLIVEN/mods/bones/init.lua index 57806e2..38dc61c 100644 --- a/games/ENLIVEN/mods/bones/init.lua +++ b/games/ENLIVEN/mods/bones/init.lua @@ -169,7 +169,7 @@ minetest.register_on_dieplayer(function(player) local pos = vector.round(player:getpos()) -- return if keep inventory set or in creative mode if bones_mode == "keep" or minetest.setting_getbool("creative_mode") then - print(player:get_player_name() .. "'s bones do not remain since in creative_mode -- died at " .. minetest.pos_to_string(vector.round(player:getpos()))) + minetest.log("action", "[bones] " .. player:get_player_name() .. "'s bones do not remain since in creative_mode -- died at " .. minetest.pos_to_string(vector.round(player:getpos()))) minetest.chat_send_player(player:get_player_name(), player:get_player_name() .. "'s bones do not remain since in creative_mode -- died at " .. minetest.pos_to_string(pos)) --formerly ("Bones placed at %s."):format(pos) return end @@ -177,7 +177,7 @@ minetest.register_on_dieplayer(function(player) local player_inv = player:get_inventory() if player_inv:is_empty("main") and player_inv:is_empty("craft") then - print(player:get_player_name() .. "'s bones do not remain since inventory and craft are empty -- died at " .. minetest.pos_to_string(vector.round(player:getpos()))) + minetest.log("action", "[bones] " .. player:get_player_name() .. "'s bones do not remain since inventory and craft are empty -- died at " .. minetest.pos_to_string(vector.round(player:getpos()))) minetest.chat_send_player(player:get_player_name(), player:get_player_name() .. "'s bones do not remain since inventory and craft are empty -- died at " .. minetest.pos_to_string(pos)) --formerly ("Bones placed at %s."):format(pos) return end @@ -210,14 +210,15 @@ minetest.register_on_dieplayer(function(player) player_inv:set_list("craft", {}) drop(pos, ItemStack("bones:bones")) - print(player:get_player_name() .. "'s bones do not remain since area is_protected -- died at " .. minetest.pos_to_string(pos)) + + minetest.log("action", "[bones] " .. player:get_player_name() .. "'s bones do not remain since area is_protected -- died at " .. minetest.pos_to_string(pos)) minetest.chat_send_player(player:get_player_name(), player:get_player_name() .. "'s do not remain since area is_protected -- died at " .. minetest.pos_to_string(pos)) --formerly ("Bones placed at %s."):format(pos) return end local param2 = minetest.dir_to_facedir(player:get_look_dir()) minetest.set_node(pos, {name = "bones:bones", param2 = param2}) - print(player:get_player_name() .. "'s bones remain where died at " .. minetest.pos_to_string(pos)) + minetest.log("action", "[bones] " .. player:get_player_name() .. "'s bones remain where died at " .. minetest.pos_to_string(pos)) minetest.chat_send_player(player:get_player_name(), player:get_player_name() .. "'s bones remain where died at " .. minetest.pos_to_string(pos)) --formerly ("Bones placed at %s."):format(pos) local meta = minetest.get_meta(pos) diff --git a/games/ENLIVEN/mods/protector/init.lua b/games/ENLIVEN/mods/protector/init.lua index f65d197..5cc8898 100644 --- a/games/ENLIVEN/mods/protector/init.lua +++ b/games/ENLIVEN/mods/protector/init.lua @@ -270,73 +270,72 @@ function minetest.is_protected(pos, digger) -- is area protected against digger? if not protector.can_dig(protector.radius, pos, digger, false, 1) then - local player = minetest.get_player_by_name(digger) + if player and player:is_player() and player:get_hp() > 0 then -- ADDED THIS LINE + -- hurt player if protection violated + if protector.hurt > 0 + and player then + player:set_hp(player:get_hp() - protector.hurt) + end - -- hurt player if protection violated - if protector.hurt > 0 - and player then - player:set_hp(player:get_hp() - protector.hurt) - end - - -- flip player when protection violated - if protector.flip - and player then + -- flip player when protection violated + if protector.flip + and player then - -- yaw + 180° - --local yaw = player:get_look_horizontal() + math.pi - local yaw = player:get_look_yaw() + math.pi + -- yaw + 180° + --local yaw = player:get_look_horizontal() + math.pi + local yaw = player:get_look_yaw() + math.pi - if yaw > 2 * math.pi then - yaw = yaw - 2 * math.pi - end + if yaw > 2 * math.pi then + yaw = yaw - 2 * math.pi + end - --player:set_look_horizontal(yaw) - player:set_look_yaw(yaw) + --player:set_look_horizontal(yaw) + player:set_look_yaw(yaw) - -- invert pitch - --player:set_look_vertical(-player:get_look_vertical()) - player:set_look_pitch(-player:get_look_pitch()) + -- invert pitch + --player:set_look_vertical(-player:get_look_vertical()) + player:set_look_pitch(-player:get_look_pitch()) - -- if digging below player, move up to avoid falling through hole - local pla_pos = player:getpos() + -- if digging below player, move up to avoid falling through hole + local pla_pos = player:getpos() - if pos.y < pla_pos.y then + if pos.y < pla_pos.y then - player:setpos({ - x = pla_pos.x, - y = pla_pos.y + 0.8, - z = pla_pos.z - }) + player:setpos({ + x = pla_pos.x, + y = pla_pos.y + 0.8, + z = pla_pos.z + }) + end end - end - - -- drop tool/item if protection violated - if protector.drop == true - and player then - local holding = player:get_wielded_item() + -- drop tool/item if protection violated + if protector.drop == true + and player then - if holding:to_string() ~= "" then + local holding = player:get_wielded_item() - -- take stack - local sta = holding:take_item(holding:get_count()) - player:set_wielded_item(holding) + if holding:to_string() ~= "" then - -- incase of lag, reset stack - minetest.after(0.1, function() + -- take stack + local sta = holding:take_item(holding:get_count()) player:set_wielded_item(holding) - -- drop stack - local obj = minetest.add_item(player:getpos(), sta) - if obj then - obj:setvelocity({x = 0, y = 5, z = 0}) - end - end) + -- incase of lag, reset stack + minetest.after(0.1, function() + player:set_wielded_item(holding) + -- drop stack + local obj = minetest.add_item(player:getpos(), sta) + if obj then + obj:setvelocity({x = 0, y = 5, z = 0}) + end + end) + + end end end - return true end