Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
minetest_game
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zadrog Pzvotrügen
minetest_game
Commits
a2ecc51f
Commit
a2ecc51f
authored
9 years ago
by
Rui914
Committed by
paramat
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Create API for registration of fence gate.
parent
d90a0817
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
game_api.txt
+14
-0
14 additions, 0 deletions
game_api.txt
mods/doors/init.lua
+90
-48
90 additions, 48 deletions
mods/doors/init.lua
with
104 additions
and
48 deletions
game_api.txt
+
14
−
0
View file @
a2ecc51f
...
...
@@ -78,6 +78,12 @@ The doors mod allows modders to register custom doors and trapdoors.
* `name` Name for trapdoor
* `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)`
* `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
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
---------
Allows creation of new fences with "fencelike" drawtype.
...
...
This diff is collapsed.
Click to expand it.
mods/doors/init.lua
+
90
−
48
View file @
a2ecc51f
...
...
@@ -658,59 +658,101 @@ minetest.register_craft({
----fence gate----
local
fence
=
{
description
=
"Fence Gate"
,
drawtype
=
"mesh"
,
tiles
=
{
"default_wood.png"
},
paramtype
=
"light"
,
paramtype2
=
"facedir"
,
sunlight_propagates
=
true
,
is_ground_content
=
false
,
drop
=
"doors:gate_closed"
,
connect_sides
=
{
"left"
,
"right"
},
groups
=
{
snappy
=
1
,
choppy
=
2
,
oddly_breakable_by_hand
=
2
,
flammable
=
2
,
fence
=
1
},
on_rightclick
=
function
(
pos
,
clicker
)
local
node
=
minetest
.
get_node
(
pos
)
local
def
=
minetest
.
registered_nodes
[
node
.
name
]
minetest
.
swap_node
(
pos
,
{
name
=
def
.
gate
,
param2
=
node
.
param2
})
minetest
.
sound_play
(
def
.
sound
,
{
pos
=
pos
,
gain
=
0
.
3
,
max_hear_distance
=
8
})
end
,
selection_box
=
{
function
doors
.
register_fencegate
(
name
,
def
)
local
fence
=
{
description
=
def
.
description
,
drawtype
=
"mesh"
,
tiles
=
{
def
.
texture
},
paramtype
=
"light"
,
paramtype2
=
"facedir"
,
sunlight_propagates
=
true
,
is_ground_content
=
false
,
drop
=
name
..
"_closed"
,
connect_sides
=
{
"left"
,
"right"
},
groups
=
def
.
groups
,
sounds
=
def
.
sounds
,
on_rightclick
=
function
(
pos
,
clicker
)
local
node
=
minetest
.
get_node
(
pos
)
local
node_def
=
minetest
.
registered_nodes
[
node
.
name
]
minetest
.
swap_node
(
pos
,
{
name
=
node_def
.
gate
,
param2
=
node
.
param2
})
minetest
.
sound_play
(
node_def
.
sound
,
{
pos
=
pos
,
gain
=
0
.
3
,
max_hear_distance
=
8
})
end
,
selection_box
=
{
type
=
"fixed"
,
fixed
=
{
-
1
/
2
,
-
1
/
2
,
-
1
/
4
,
1
/
2
,
1
/
2
,
1
/
4
},
},
}
if
not
fence
.
sounds
then
fence
.
sounds
=
default
.
node_sound_wood_defaults
()
end
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"
,
fixed
=
{
-
1
/
2
,
-
1
/
2
,
-
1
/
4
,
1
/
2
,
1
/
2
,
1
/
4
},
},
}
}
local
fence_closed
=
table
.
copy
(
fence
)
fence_closed
.
mesh
=
"doors_fencegate_closed.obj"
fence_closed
.
gate
=
"doors:gate_open"
fence_closed
.
sound
=
"doors_fencegate_open"
fence_closed
.
collision_box
=
{
type
=
"fixed"
,
fixed
=
{
-
1
/
2
,
-
1
/
2
,
-
1
/
4
,
1
/
2
,
1
/
2
,
1
/
4
},
}
local
fence_open
=
table
.
copy
(
fence
)
fence_open
.
mesh
=
"doors_fencegate_open.obj"
fence_open
.
gate
=
name
..
"_closed"
fence_open
.
sound
=
"doors_fencegate_close"
fence_open
.
groups
.
not_in_creative_inventory
=
1
fence_open
.
collision_box
=
{
type
=
"fixed"
,
fixed
=
{{
-
1
/
2
,
-
1
/
2
,
-
1
/
4
,
-
3
/
8
,
1
/
2
,
1
/
4
},
{
-
5
/
8
,
-
3
/
8
,
-
14
/
16
,
-
3
/
8
,
3
/
8
,
0
}},
}
local
fence_open
=
table
.
copy
(
fence
)
fence_open
.
mesh
=
"doors_fencegate_open.obj"
fence_open
.
gate
=
"doors:gate_closed"
fence_open
.
sound
=
"doors_fencegate_close"
fence_open
.
groups
.
not_in_creative_inventory
=
1
fence_open
.
collision_box
=
{
type
=
"fixed"
,
fixed
=
{{
-
1
/
2
,
-
1
/
2
,
-
1
/
4
,
-
3
/
8
,
1
/
2
,
1
/
4
},
{
-
5
/
8
,
-
3
/
8
,
-
14
/
16
,
-
3
/
8
,
3
/
8
,
0
}},
}
minetest
.
register_node
(
":"
..
name
..
"_closed"
,
fence_closed
)
minetest
.
register_node
(
":"
..
name
..
"_open"
,
fence_open
)
minetest
.
register_node
(
"doors:gate_closed"
,
fence_closed
)
minetest
.
register_node
(
"doors:gate_open"
,
fence_open
)
minetest
.
register_craft
({
output
=
name
..
"_closed"
,
recipe
=
{
{
"default:stick"
,
def
.
material
,
"default:stick"
},
{
"default:stick"
,
def
.
material
,
"default:stick"
}
}
})
end
minetest
.
register_craft
({
output
=
"doors:gate_closed"
,
recipe
=
{
{
"default:stick"
,
"group:wood"
,
"default:stick"
},
{
"default:stick"
,
"group:wood"
,
"default:stick"
},
},
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
}
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment