mirror of
https://github.com/D00Med/scifi_nodes.git
synced 2024-12-22 08:00:18 +01:00
add scifi_nodes.open_door(pos)
and api docs
This commit is contained in:
parent
83a5d401cc
commit
772aef2118
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
Minetest mod that adds scifi themed blocks, doors, materials, plants and other assets.
|
Minetest mod that adds scifi themed blocks, doors, materials, plants and other assets.
|
||||||
|
|
||||||
|
Lua api: see [api.md](./api.md)
|
||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
* Added support for unifieddyes
|
* Added support for unifieddyes
|
||||||
|
12
api.md
Normal file
12
api.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
scifi_nodes api
|
||||||
|
|
||||||
|
# Doors
|
||||||
|
|
||||||
|
Open scifi_nodes door at given position
|
||||||
|
|
||||||
|
```lua
|
||||||
|
scifi_nodes.open_door(pos)
|
||||||
|
```
|
||||||
|
|
||||||
|
returns `true` on success, `false` otherwise
|
33
doors.lua
33
doors.lua
@ -155,7 +155,7 @@ for _, current_door in ipairs(doors) do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function open_door(pos, node, player, itemstack, pointed_thing)
|
local function open_door(pos, node)
|
||||||
-- play sound
|
-- play sound
|
||||||
minetest.sound_play(sound,{
|
minetest.sound_play(sound,{
|
||||||
max_hear_distance = 16,
|
max_hear_distance = 16,
|
||||||
@ -240,7 +240,11 @@ for _, current_door in ipairs(doors) do
|
|||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {cracky = 3, oddly_breakable_by_hand = 1},
|
groups = {
|
||||||
|
cracky = 3,
|
||||||
|
oddly_breakable_by_hand = 1,
|
||||||
|
scifi_nodes_door = 1
|
||||||
|
},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
@ -253,6 +257,7 @@ for _, current_door in ipairs(doors) do
|
|||||||
{-0.5, -0.5, -0.0625, 0.5, 1.5, 0.0625}
|
{-0.5, -0.5, -0.0625, 0.5, 1.5, 0.0625}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
_open = open_door,
|
||||||
mesecons = mesecons_doors_def,
|
mesecons = mesecons_doors_def,
|
||||||
on_place = onplace,
|
on_place = onplace,
|
||||||
after_destruct = afterdestruct,
|
after_destruct = afterdestruct,
|
||||||
@ -350,3 +355,27 @@ for _, current_door in ipairs(doors) do
|
|||||||
sounds = scifi_nodes.node_sound_metal_defaults(),
|
sounds = scifi_nodes.node_sound_metal_defaults(),
|
||||||
})
|
})
|
||||||
end -- end of doors table browsing
|
end -- end of doors table browsing
|
||||||
|
|
||||||
|
-- opens the scifi-door at the given position
|
||||||
|
function scifi_nodes.open_door(pos)
|
||||||
|
local node = minetest.get_node_or_nil(pos)
|
||||||
|
if not node then
|
||||||
|
-- area not loaded
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local def = minetest.registered_nodes[node.name]
|
||||||
|
if type(def._open) ~= "function" then
|
||||||
|
-- open function not found
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if not def.groups or not def.groups.scifi_nodes_door then
|
||||||
|
-- not a scifi_nodes door
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- call open function
|
||||||
|
def._open(pos, node)
|
||||||
|
return true
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user