Create API for registration of fence gate.
This commit is contained in:
parent
d90a081722
commit
a2ecc51fbc
14
game_api.txt
14
game_api.txt
|
@ -78,6 +78,12 @@ The doors mod allows modders to register custom doors and trapdoors.
|
||||||
* `name` Name for trapdoor
|
* `name` Name for trapdoor
|
||||||
* `def` See [#Trapdoor definition]
|
* `def` See [#Trapdoor definition]
|
||||||
|
|
||||||
|
`doors.register_fencegate(name, def)`
|
||||||
|
|
||||||
|
* Registers new fence gate
|
||||||
|
* `name` Name for fence gate
|
||||||
|
* `def` See [#Fence gate definition]
|
||||||
|
|
||||||
`doors.get(pos)`
|
`doors.get(pos)`
|
||||||
|
|
||||||
* `pos` A position as a table, e.g `{x = 1, y = 1, z = 1}`
|
* `pos` A position as a table, e.g `{x = 1, y = 1, z = 1}`
|
||||||
|
@ -119,6 +125,14 @@ The doors mod allows modders to register custom doors and trapdoors.
|
||||||
sound_close = sound play for close door, -- optional
|
sound_close = sound play for close door, -- optional
|
||||||
protected = false, -- If true, only placer can open the door (locked for others)
|
protected = false, -- If true, only placer can open the door (locked for others)
|
||||||
|
|
||||||
|
###Fence gate definition
|
||||||
|
|
||||||
|
description = "Wooden Fence Gate",
|
||||||
|
texture = "default_wood.png",
|
||||||
|
material = "default:wood",
|
||||||
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
|
||||||
|
sounds = default.node_sound_wood_defaults(), -- optional
|
||||||
|
|
||||||
Fence API
|
Fence API
|
||||||
---------
|
---------
|
||||||
Allows creation of new fences with "fencelike" drawtype.
|
Allows creation of new fences with "fencelike" drawtype.
|
||||||
|
|
|
@ -658,59 +658,101 @@ minetest.register_craft({
|
||||||
|
|
||||||
----fence gate----
|
----fence gate----
|
||||||
|
|
||||||
local fence = {
|
function doors.register_fencegate(name, def)
|
||||||
description = "Fence Gate",
|
local fence = {
|
||||||
|
description = def.description,
|
||||||
drawtype = "mesh",
|
drawtype = "mesh",
|
||||||
tiles = {"default_wood.png"},
|
tiles = { def.texture },
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
drop = "doors:gate_closed",
|
drop = name .. "_closed",
|
||||||
connect_sides = { "left", "right" },
|
connect_sides = { "left", "right" },
|
||||||
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2,
|
groups = def.groups,
|
||||||
flammable = 2, fence = 1},
|
sounds = def.sounds,
|
||||||
on_rightclick = function(pos, clicker)
|
on_rightclick = function(pos, clicker)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local def = minetest.registered_nodes[node.name]
|
local node_def = minetest.registered_nodes[node.name]
|
||||||
minetest.swap_node(pos, {name = def.gate, param2 = node.param2})
|
minetest.swap_node(pos, {name = node_def.gate, param2 = node.param2})
|
||||||
minetest.sound_play(def.sound, {pos = pos, gain = 0.3,
|
minetest.sound_play(node_def.sound, {pos = pos, gain = 0.3,
|
||||||
max_hear_distance = 8})
|
max_hear_distance = 8})
|
||||||
end,
|
end,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4},
|
fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local fence_closed = table.copy(fence)
|
if not fence.sounds then
|
||||||
fence_closed.mesh = "doors_fencegate_closed.obj"
|
fence.sounds = default.node_sound_wood_defaults()
|
||||||
fence_closed.gate = "doors:gate_open"
|
end
|
||||||
fence_closed.sound = "doors_fencegate_open"
|
|
||||||
fence_closed.collision_box = {
|
fence.groups.fence = 1
|
||||||
|
|
||||||
|
local fence_closed = table.copy(fence)
|
||||||
|
fence_closed.mesh = "doors_fencegate_closed.obj"
|
||||||
|
fence_closed.gate = name .. "_open"
|
||||||
|
fence_closed.sound = "doors_fencegate_open"
|
||||||
|
fence_closed.collision_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4},
|
fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4},
|
||||||
}
|
}
|
||||||
|
|
||||||
local fence_open = table.copy(fence)
|
local fence_open = table.copy(fence)
|
||||||
fence_open.mesh = "doors_fencegate_open.obj"
|
fence_open.mesh = "doors_fencegate_open.obj"
|
||||||
fence_open.gate = "doors:gate_closed"
|
fence_open.gate = name .. "_closed"
|
||||||
fence_open.sound = "doors_fencegate_close"
|
fence_open.sound = "doors_fencegate_close"
|
||||||
fence_open.groups.not_in_creative_inventory = 1
|
fence_open.groups.not_in_creative_inventory = 1
|
||||||
fence_open.collision_box = {
|
fence_open.collision_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {{-1/2, -1/2, -1/4, -3/8, 1/2, 1/4},
|
fixed = {{-1/2, -1/2, -1/4, -3/8, 1/2, 1/4},
|
||||||
{-5/8, -3/8, -14/16, -3/8, 3/8, 0}},
|
{-5/8, -3/8, -14/16, -3/8, 3/8, 0}},
|
||||||
}
|
}
|
||||||
|
|
||||||
minetest.register_node("doors:gate_closed", fence_closed)
|
minetest.register_node(":" .. name .. "_closed", fence_closed)
|
||||||
minetest.register_node("doors:gate_open", fence_open)
|
minetest.register_node(":" .. name .. "_open", fence_open)
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "doors:gate_closed",
|
output = name .. "_closed",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:stick", "group:wood", "default:stick"},
|
{"default:stick", def.material, "default:stick"},
|
||||||
{"default:stick", "group:wood", "default:stick"},
|
{"default:stick", def.material, "default:stick"}
|
||||||
},
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
doors.register_fencegate("doors:gate_wood", {
|
||||||
|
description = "Wooden Fence Gate",
|
||||||
|
texture = "default_wood.png",
|
||||||
|
material = "default:wood",
|
||||||
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
doors.register_fencegate("doors:gate_acacia_wood", {
|
||||||
|
description = "Acacia Fence Gate",
|
||||||
|
texture = "default_acacia_wood.png",
|
||||||
|
material = "default:acacia_wood",
|
||||||
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}
|
||||||
|
})
|
||||||
|
|
||||||
|
doors.register_fencegate("doors:gate_junglewood", {
|
||||||
|
description = "Junglewood Fence Gate",
|
||||||
|
texture = "default_junglewood.png",
|
||||||
|
material = "default:junglewood",
|
||||||
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}
|
||||||
|
})
|
||||||
|
|
||||||
|
doors.register_fencegate("doors:gate_pine_wood", {
|
||||||
|
description = "Pine Fence Gate",
|
||||||
|
texture = "default_pine_wood.png",
|
||||||
|
material = "default:pine_wood",
|
||||||
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}
|
||||||
|
})
|
||||||
|
|
||||||
|
doors.register_fencegate("doors:gate_aspen_wood", {
|
||||||
|
description = "Aspen Fence Gate",
|
||||||
|
texture = "default_aspen_wood.png",
|
||||||
|
material = "default:aspen_wood",
|
||||||
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue