Fix: door texture getting messed up
This commit is contained in:
parent
424ef678e7
commit
3e63a1c657
@ -1,2 +1,3 @@
|
||||
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",
|
||||
nodenames = {"factions:chest"},
|
||||
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)
|
||||
if parcel_faction then
|
||||
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:get_string("faction") .. ")")
|
||||
name .. ")")
|
||||
end
|
||||
end
|
||||
})
|
||||
local dc = minetest.registered_nodes["default:chest"]
|
||||
local def_on_rightclick = dc.on_rightclick
|
||||
local clonenode = {}
|
||||
for k,v in pairs(minetest.registered_nodes["default:chest"]) do clonenode[k] = v end
|
||||
clonenode.after_place_node = function(pos, placer)
|
||||
|
||||
local after_place_node = function(pos, placer)
|
||||
local parcel_faction = factions.get_faction_at(pos)
|
||||
if parcel_faction then
|
||||
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:get_string("faction") .. ")")
|
||||
name .. ")")
|
||||
end
|
||||
end
|
||||
clonenode.can_dig = function(pos,player)
|
||||
local can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main") and
|
||||
factions.can_use_node(pos, player:get_player_name(),"container")
|
||||
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)
|
||||
if not factions.can_use_node(pos, player:get_player_name(),"container") then
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
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
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
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
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
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
|
||||
return itemstack
|
||||
end
|
||||
def_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
|
||||
return def_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
|
||||
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
|
||||
-- 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"
|
||||
,"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
|
||||
if minetest.registered_nodes[k] then
|
||||
local dw = minetest.registered_nodes[k]
|
||||
local def_after_place_node = dw.on_rightclick
|
||||
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: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",
|
||||
"doors:rusty_prison_door_b", "doors:prison_door_a", "doors:prison_door_b", "doors:japanese_door_a", "doors:japanese_door_b"}
|
||||
for i, l in ipairs(doors) do
|
||||
local dw = minetest.registered_nodes[l]
|
||||
if dw then
|
||||
local def_on_rightclick = dw.on_rightclick
|
||||
local def_can_dig = dw.can_dig
|
||||
local clonenode = {}
|
||||
for k,v in pairs(minetest.registered_nodes[k]) do clonenode[k] = v end
|
||||
clonenode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
if factions.can_use_node(pos, clicker:get_player_name(),"door") then
|
||||
def_after_place_node(pos, node, clicker, itemstack, pointed_thing)
|
||||
|
||||
local on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
if factions.can_use_node(pos, clicker:get_player_name(), "door") then
|
||||
def_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local can_dig = nil
|
||||
|
||||
if def_can_dig then
|
||||
clonenode.can_dig = function(pos, digger)
|
||||
if factions.can_use_node(pos, digger:get_player_name(),"door") then
|
||||
can_dig = function(pos, digger)
|
||||
if factions.can_use_node(pos, digger:get_player_name(), "door") then
|
||||
return def_can_dig(pos, digger)
|
||||
end
|
||||
return false
|
||||
end
|
||||
else
|
||||
clonenode.can_dig = function(pos, digger)
|
||||
if factions.can_use_node(pos, digger:get_player_name(),"door") then
|
||||
can_dig = function(pos, digger)
|
||||
if factions.can_use_node(pos, digger:get_player_name(), "door") then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
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
|
||||
-- Code below was copied from TenPlus1's protector mod(MIT) and changed up a bit.
|
||||
|
Loading…
Reference in New Issue
Block a user