diff options
-rw-r--r-- | default.lua | 30 | ||||
-rw-r--r-- | fire.lua | 2 | ||||
-rw-r--r-- | hud.lua | 2 | ||||
-rw-r--r-- | init.lua | 2 | ||||
-rw-r--r-- | protection.lua | 68 | ||||
-rw-r--r-- | sign.lua | 48 |
6 files changed, 53 insertions, 99 deletions
diff --git a/default.lua b/default.lua index 926da20..ab1d243 100644 --- a/default.lua +++ b/default.lua @@ -1,35 +1,9 @@ if minetest.get_modpath("default") then - minetest.register_node(":default:sign_wall", { - description = "Sign", - drawtype = "signlike", - tiles = {"default_sign_wall.png"}, - inventory_image = "default_sign_wall.png", - wield_image = "default_sign_wall.png", - paramtype = "light", - paramtype2 = "wallmounted", - sunlight_propagates = true, - walkable = false, - selection_box = { - type = "wallmounted", - --wall_top = <default> - --wall_bottom = <default> - --wall_side = <default> - }, - groups = {choppy=2,dig_immediate=2}, - legacy_wallmounted = true, - sounds = default.node_sound_defaults(), - on_construct = function(pos) - --local n = minetest.env:get_node(pos) - - local meta = minetest.env:get_meta(pos) - meta:set_string("formspec", "hack:sign_text_input") - meta:set_string("infotext", "\"\"") - end, + minetest.override_item("default:sign_wall", { on_receive_fields = function(pos, formname, fields, sender) - --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields)) local name = sender:get_player_name() if landrush.can_interact(pos, name) then - local meta = minetest.env:get_meta(pos) + local meta = minetest.get_meta(pos) fields.text = fields.text or "" print((name or "").." wrote \""..fields.text.. "\" to sign at "..minetest.pos_to_string(pos)) @@ -1,4 +1,4 @@ -if minetest.get_modpath("fire") then +if minetest.get_modpath("fire") and rawget(_G, "fire") then landrush.default_flame_should_extinguish = fire.flame_should_extinguish function fire.flame_should_extinguish(pos) @@ -9,7 +9,7 @@ minetest.register_globalstep(function(dtime) for _,player in ipairs(oplayers) do local name = player:get_player_name() local sameowner = false - owner = landrush.get_owner(player:getpos()) + local owner = landrush.get_owner(player:getpos()) if ( landrush.playerHudItems[name] ~= nil ) then if ( landrush.playerHudItems[name].lastowner == owner ) then @@ -1,7 +1,7 @@ minetest.log('action','Loading Land Rush Land Claim') -- Freeminer Compatibility -if freeminer then +if rawget(_G, "freeminer") then minetest = freeminer end diff --git a/protection.lua b/protection.lua index e3ce8d2..40989f8 100644 --- a/protection.lua +++ b/protection.lua @@ -155,44 +155,44 @@ minetest.register_on_protection_violation( landrush.protection_violation ) landrush.default_place = minetest.item_place function minetest.item_place(itemstack, placer, pointed_thing) - owner = landrush.get_owner(pointed_thing.above) - name = placer:get_player_name() - if landrush.can_interact(pointed_thing.above,name) or itemstack:get_name() == "" then - -- add a workaround for TNT, since overwriting the registered node seems not to work - if itemstack:get_name() == "tnt:tnt" or itemstack:get_name() == "tnt:tnt_burning" then - local pos = pointed_thing.above - local temp_pos = pos - temp_pos.x = pos.x + 2 - if name ~= landrush.get_owner( temp_pos ) then - minetest.chat_send_player( name, "Do not place TNT near claimed areas..." ) - return itemstack - end - temp_pos.x = pos.x - 2 - if name ~= landrush.get_owner( temp_pos ) then - minetest.chat_send_player( name, "Do not place TNT near claimed areas..." ) - return itemstack - end - temp_pos.z = pos.z + 2 - if name ~= landrush.get_owner( temp_pos ) then - minetest.chat_send_player( name, "Do not place TNT near claimed areas..." ) - return itemstack - end - temp_pos.z = pos.z - 2 - if name ~= landrush.get_owner( temp_pos ) then - minetest.chat_send_player( name, "Do not place TNT near claimed areas..." ) - return itemstack - end + local owner = landrush.get_owner(pointed_thing.above) + local name = placer:get_player_name() + if landrush.can_interact(pointed_thing.above,name) or itemstack:get_name() == "" then + -- add a workaround for TNT, since overwriting the registered node seems not to work + if itemstack:get_name() == "tnt:tnt" or itemstack:get_name() == "tnt:tnt_burning" then + local pos = pointed_thing.above + local temp_pos = pos + temp_pos.x = pos.x + 2 + if name ~= landrush.get_owner( temp_pos ) then + minetest.chat_send_player( name, "Do not place TNT near claimed areas..." ) + return itemstack end - -- end of the workaround - return landrush.default_place(itemstack, placer, pointed_thing) - else - if ( owner ~= nil ) then - minetest.chat_send_player(name, "Area owned by "..owner) + temp_pos.x = pos.x - 2 + if name ~= landrush.get_owner( temp_pos ) then + minetest.chat_send_player( name, "Do not place TNT near claimed areas..." ) return itemstack - else - minetest.chat_send_player(name,"Area unclaimed, claim this area to build") + end + temp_pos.z = pos.z + 2 + if name ~= landrush.get_owner( temp_pos ) then + minetest.chat_send_player( name, "Do not place TNT near claimed areas..." ) + return itemstack + end + temp_pos.z = pos.z - 2 + if name ~= landrush.get_owner( temp_pos ) then + minetest.chat_send_player( name, "Do not place TNT near claimed areas..." ) return itemstack end end + -- end of the workaround + return landrush.default_place(itemstack, placer, pointed_thing) + else + if ( owner ~= nil ) then + minetest.chat_send_player(name, "Area owned by "..owner) + return itemstack + else + minetest.chat_send_player(name,"Area unclaimed, claim this area to build") + return itemstack + end + end end @@ -1,38 +1,18 @@ -- create a new type of sign that is not protected by landrush mod -minetest.register_node("landrush:unlocked_sign", { - description = "Unprotected Sign", - drawtype = "signlike", - tiles = {"default_sign_wall.png"}, - inventory_image = "default_sign_wall.png", - wield_image = "default_sign_wall.png", - paramtype = "light", - paramtype2 = "wallmounted", - sunlight_propagates = true, - walkable = false, - selection_box = { - type = "wallmounted", - --wall_top = <default> - --wall_bottom = <default> - --wall_side = <default> - }, - groups = {choppy=2,dig_immediate=2,attached_node=1}, - legacy_wallmounted = true, - sounds = default.node_sound_defaults(), - on_construct = function(pos) - --local n = minetest.get_node(pos) - local meta = minetest.get_meta(pos) - meta:set_string("formspec", "field[text;;${text}]") - meta:set_string("infotext", "\"\"") - end, - on_receive_fields = function(pos, formname, fields, sender) - local meta = minetest.get_meta(pos) - fields.text = fields.text or "" - print((sender:get_player_name() or "").." wrote \""..fields.text.. - "\" to sign at "..minetest.pos_to_string(pos)) - meta:set_string("text", fields.text) - meta:set_string("infotext", '"'..fields.text..'"') - end, -}) + +local signdef = table.copy(minetest.registered_nodes["default:sign_wall"]) + +signdef.description = "Unprotected Sign" +signdef.on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.get_meta(pos) + fields.text = fields.text or "" + print((sender:get_player_name() or "").." wrote \""..fields.text.. + "\" to sign at "..minetest.pos_to_string(pos)) + meta:set_string("text", fields.text) + meta:set_string("infotext", '"'..fields.text..'"') +end + +minetest.register_node("landrush:unlocked_sign", signdef) minetest.register_craft({ |