forked from mtcontrib/factions
Fix: door texture getting messed up
This commit is contained in:
parent
424ef678e7
commit
3e63a1c657
@ -1,2 +1,3 @@
|
|||||||
default?
|
default?
|
||||||
doors?
|
doors?
|
||||||
|
xdecor?
|
||||||
|
100
nodes.lua
100
nodes.lua
@ -18,93 +18,131 @@ if minetest.registered_nodes["default:chest"] then
|
|||||||
name = "factions:replace_factions_chest",
|
name = "factions:replace_factions_chest",
|
||||||
nodenames = {"factions:chest"},
|
nodenames = {"factions:chest"},
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
minetest.swap_node(pos, {name="default:chest"})
|
minetest.swap_node(pos, {name = "default:chest"})
|
||||||
local parcel_faction = factions.get_faction_at(pos)
|
local parcel_faction = factions.get_faction_at(pos)
|
||||||
if parcel_faction then
|
if parcel_faction then
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("faction", parcel_faction.name or "")
|
local name = parcel_faction.name
|
||||||
|
meta:set_string("faction", name)
|
||||||
meta:set_string("infotext", "Faction Chest (owned by faction " ..
|
meta:set_string("infotext", "Faction Chest (owned by faction " ..
|
||||||
meta:get_string("faction") .. ")")
|
name .. ")")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
local dc = minetest.registered_nodes["default:chest"]
|
local dc = minetest.registered_nodes["default:chest"]
|
||||||
local def_on_rightclick = dc.on_rightclick
|
local def_on_rightclick = dc.on_rightclick
|
||||||
local clonenode = {}
|
|
||||||
for k,v in pairs(minetest.registered_nodes["default:chest"]) do clonenode[k] = v end
|
local after_place_node = function(pos, placer)
|
||||||
clonenode.after_place_node = function(pos, placer)
|
|
||||||
local parcel_faction = factions.get_faction_at(pos)
|
local parcel_faction = factions.get_faction_at(pos)
|
||||||
if parcel_faction then
|
if parcel_faction then
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("faction", parcel_faction.name or "")
|
local name = parcel_faction.name
|
||||||
|
meta:set_string("faction", name)
|
||||||
meta:set_string("infotext", "Faction Chest (owned by faction " ..
|
meta:set_string("infotext", "Faction Chest (owned by faction " ..
|
||||||
meta:get_string("faction") .. ")")
|
name .. ")")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
clonenode.can_dig = function(pos,player)
|
local can_dig = function(pos,player)
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:is_empty("main") and
|
return inv:is_empty("main") and
|
||||||
factions.can_use_node(pos, player:get_player_name(),"container")
|
factions.can_use_node(pos, player:get_player_name(),"container")
|
||||||
end
|
end
|
||||||
clonenode.allow_metadata_inventory_move = function(pos, from_list, from_index,
|
local allow_metadata_inventory_move = function(pos, from_list, from_index,
|
||||||
to_list, to_index, count, player)
|
to_list, to_index, count, player)
|
||||||
if not factions.can_use_node(pos, player:get_player_name(),"container") then
|
if not factions.can_use_node(pos, player:get_player_name(),"container") then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
clonenode.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
local allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
if not factions.can_use_node(pos, player:get_player_name(),"container") then
|
if not factions.can_use_node(pos, player:get_player_name(),"container") then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
clonenode.allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
local allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
if not factions.can_use_node(pos, player:get_player_name(),"container") then
|
if not factions.can_use_node(pos, player:get_player_name(),"container") then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
clonenode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
local on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
if not factions.can_use_node(pos, clicker:get_player_name(),"container") then
|
if not factions.can_use_node(pos, clicker:get_player_name(),"container") then
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
def_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
|
return def_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
|
||||||
end
|
end
|
||||||
minetest.register_node(":default:chest",clonenode)
|
minetest.override_item("default:chest", {after_place_node = after_place_node,
|
||||||
|
can_dig = can_dig,
|
||||||
|
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||||
|
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||||
|
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||||
|
on_rightclick = on_rightclick})
|
||||||
end
|
end
|
||||||
-- Edit default doors and trapdoors to make them require the door permission.
|
-- Edit default doors and trapdoors to make them require the door permission.
|
||||||
local doors = {"doors:door_wood_a","doors:door_wood_b","doors:door_steel_a","doors:door_steel_b","doors:door_glass_a","doors:door_glass_b"
|
local doors = {"doors:door_wood_a", "doors:door_wood_b", "doors:door_steel_a", "doors:door_steel_b", "doors:door_glass_a", "doors:door_glass_b",
|
||||||
,"doors:door_obsidian_glass_a","doors:door_obsidian_glass_b","doors:trapdoor","doors:trapdoor_open","doors:trapdoor_steel","doors:trapdoor_steel_open"}
|
"doors:door_obsidian_glass_a", "doors:door_obsidian_glass_b", "doors:trapdoor", "doors:trapdoor_open", "doors:trapdoor_steel", "doors:trapdoor_steel_open",
|
||||||
for i,k in ipairs(doors) do
|
"doors:woodglass_door_a", "doors:woodglass_door_b", "doors:slide_door_a", "doors:slide_door_b", "doors:screen_door_a", "doors:screen_door_b", "doors:rusty_prison_door_a",
|
||||||
if minetest.registered_nodes[k] then
|
"doors:rusty_prison_door_b", "doors:prison_door_a", "doors:prison_door_b", "doors:japanese_door_a", "doors:japanese_door_b"}
|
||||||
local dw = minetest.registered_nodes[k]
|
for i, l in ipairs(doors) do
|
||||||
local def_after_place_node = dw.on_rightclick
|
local dw = minetest.registered_nodes[l]
|
||||||
|
if dw then
|
||||||
|
local def_on_rightclick = dw.on_rightclick
|
||||||
local def_can_dig = dw.can_dig
|
local def_can_dig = dw.can_dig
|
||||||
local clonenode = {}
|
|
||||||
for k,v in pairs(minetest.registered_nodes[k]) do clonenode[k] = v end
|
local on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
clonenode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
if factions.can_use_node(pos, clicker:get_player_name(), "door") then
|
||||||
if factions.can_use_node(pos, clicker:get_player_name(),"door") then
|
def_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
|
||||||
def_after_place_node(pos, node, clicker, itemstack, pointed_thing)
|
|
||||||
end
|
end
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local can_dig = nil
|
||||||
|
|
||||||
if def_can_dig then
|
if def_can_dig then
|
||||||
clonenode.can_dig = function(pos, digger)
|
can_dig = function(pos, digger)
|
||||||
if factions.can_use_node(pos, digger:get_player_name(),"door") then
|
if factions.can_use_node(pos, digger:get_player_name(), "door") then
|
||||||
return def_can_dig(pos, digger)
|
return def_can_dig(pos, digger)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
clonenode.can_dig = function(pos, digger)
|
can_dig = function(pos, digger)
|
||||||
if factions.can_use_node(pos, digger:get_player_name(),"door") then
|
if factions.can_use_node(pos, digger:get_player_name(), "door") then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.register_node(":"..k,clonenode)
|
minetest.override_item(l, {on_rightclick = on_rightclick,
|
||||||
|
can_dig = can_dig})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local door_items = {"doors:door_wood", "doors:door_steel", "doors:door_glass", "doors:door_obsidian_glass", "doors:trapdoor", "doors:trapdoor_steel", "doors:woodglass_door", "doors:slide_door",
|
||||||
|
"doors:screen_door", "doors:rusty_prison_door", "doors:prison_door", "doors:japanese_door"}
|
||||||
|
|
||||||
|
for i, l in ipairs(door_items) do
|
||||||
|
local it = minetest.registered_items[l]
|
||||||
|
if it then
|
||||||
|
local def_on_place = it.on_place
|
||||||
|
if def_on_place ~= nil then
|
||||||
|
local on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
local r = def_on_place(itemstack, placer, pointed_thing)
|
||||||
|
local pos = pointed_thing.above
|
||||||
|
local parcel_faction = factions.get_faction_at(pos)
|
||||||
|
if parcel_faction then
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local name = parcel_faction.name
|
||||||
|
meta:set_string("faction", name)
|
||||||
|
meta:set_string("infotext", "Faction Door (owned by faction " ..
|
||||||
|
name .. ")")
|
||||||
|
end
|
||||||
|
return r
|
||||||
|
end
|
||||||
|
minetest.override_item(l, {on_place = on_place})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Code below was copied from TenPlus1's protector mod(MIT) and changed up a bit.
|
-- Code below was copied from TenPlus1's protector mod(MIT) and changed up a bit.
|
||||||
|
Loading…
Reference in New Issue
Block a user