Skip to content

Commit f600a9f

Browse files
sofarparamat
authored andcommittedFeb 13, 2016
New mesh door models, and extensive door API
This patch replaces the default door nodes with a new mesh model and nodes. Two new models were added that are 2 blocks high. One for left-hinge and one for right-hinge doors. This allows us to make a single texture fit on both models. The alternative would have been 1 model and 2 unmapped textures, which is more work for mod developers. Doors work exactly like the old doors, including ownership, breaking doors, opening and closing. Under the hood, we can prevent the top part of the door from being obstructed by placing an invisible node. This prevents liquids from flowing through doors or people placing sand or other blocks in the top half. The door code automatically places and removes these as needed. Metadata is used to store door state, just like the old version. A doors API is added, it allows mods to use the API to open/close or toggle door states without worrying about sounds, permissions and other details. This is intended for e.g. mesecons. This API allows mods to manipulate or inspect doors for players or for themselves. In-game old door nodes are automatically converted using an ABM and preserve ownership and orientation and state. TNT blows up all doors and trapdoors except for the steel ones, who can survive a blast. We return an itemstack in on_blast(), which requires a TNT API patch which is also pending. We enable backface culling for most of these doors, as this gives the identical visual appearance that the old doors had. In the case of the glass door, there's a slight twist. The texture files used by the new doors have new names that do not conflict with previous texture file names to avoid texture pack conflicts. Thanks to red-001 <red-001@users.noreply.github.com> for some of the conversion code, cleanups, and extra textures.
1 parent 9e54b37 commit f600a9f

26 files changed

+499
-386
lines changed
 

Diff for: ‎game_api.txt

+31-19
Original file line numberDiff line numberDiff line change
@@ -71,43 +71,55 @@ doors.register_door(name, def)
7171
-> Registers new door
7272

7373
doors.register_trapdoor(name, def)
74-
^ name: "Trapdoor name"
74+
^ name: "mod_door"
7575
^ def: See [#Trapdoor definition]
7676
-> Registers new trapdoor
7777

78+
doors.get(pos)
79+
^ pos = { x = .., y = .., z = ..}
80+
-> Returns an ObjecRef to a door, or nil if the pos did not contain a door
81+
82+
Methods:
83+
:open(player) -- Open the door object, returns if door was opened
84+
:close(player) -- Close the door object, returns if door was closed
85+
:toggle(player) -- Toggle the door state, returns if state was toggled
86+
:state() -- returns the door state, true = open, false = closed
87+
88+
the "player" parameter can be omitted in all methods. If passed then
89+
the usual permission checks will be performed to make sure the player
90+
has the permissions needed to open this door. If omitted then no
91+
permission checks are performed.
92+
7893
#Door definition
7994
----------------
8095
{
8196
description = "Door description",
8297
inventory_image = "mod_door_inv.png",
83-
groups = {group = 1},
84-
tiles_bottom: [Tile definition],
85-
^ the tiles of the bottom part of the door {front, side}
86-
tiles_top: [Tile definition],
87-
^ the tiles of the bottom part of the door {front, side}
88-
node_box_bottom = regular nodebox, see [Node boxes], OPTIONAL,
89-
node_box_top = regular nodebox, see [Node boxes], OPTIONAL,
90-
selection_box_bottom = regular nodebox, see [Node boxes], OPTIONAL,
91-
selection_box_top = regular nodebox, see [Node boxes], OPTIONAL,
92-
sound_open_door = sound play for open door, OPTIONAL,
93-
sound_close_door = sound play for close door, OPTIONAL,
94-
only_placer_can_open = true/false,
98+
groups = {choppy = 1},
99+
tiles = { "mod_door.png" },
100+
material = "default:wood", -- used to make a craft recipe
101+
sounds = default.node_sound_wood_defaults(), -- optional
102+
sound_open = sound play for open door, -- optional
103+
sound_close = sound play for close door, -- optional
104+
protected = false,
95105
^ If true, only placer can open the door (locked for others)
96106
}
97107

98108
#Trapdoor definition
99109
----------------
100110
{
111+
description = "Trapdoor description",
112+
inventory_image = "mod_trapdoor_inv.png",
113+
groups = {choppy = 1},
101114
tile_front = "doors_trapdoor.png",
102115
^ the texture for the front and back of the trapdoor
103116
tile_side: "doors_trapdoor_side.png",
104117
^ the tiles of the four side parts of the trapdoor
105-
sound_open = sound to play when opening the trapdoor, OPTIONAL,
106-
sound_close = sound to play when closing the trapdoor, OPTIONAL,
107-
-> You can add any other node definition properties for minetest.register_node,
108-
such as wield_image, inventory_image, sounds, groups, description, ...
109-
Only node_box, selection_box, tiles, drop, drawtype, paramtype, paramtype2, on_rightclick
110-
will be overwritten by the trapdoor registration function
118+
sounds = default.node_sound_wood_defaults(), -- optional
119+
sound_open = sound play for open door, -- optional
120+
sound_close = sound play for close door, -- optional
121+
protected = false,
122+
^ If true, only placer can open the door (locked for others)
111123
}
112124

113125
Fence API

Diff for: ‎mods/doors/README.txt

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
Minetest Game mod: doors
22
========================
3-
version: 1.3
3+
version: 2.0
44

55
License of source code:
66
-----------------------
77
Copyright (C) 2012 PilzAdam
88
modified by BlockMen (added sounds, glassdoors[glass, obsidian glass], trapdoor)
99
Steel trapdoor added by sofar.
10+
Copyright (C) 2015 sofar@foo-projects.org
11+
Re-implemented most of the door algorithms, added meshes, UV wrapped texture
12+
Added doors API to facilitate coding mods accessing and operating doors.
1013

1114
This program is free software. It comes without any warranty, to
1215
the extent permitted by applicable law. You can redistribute it
@@ -40,8 +43,20 @@ following textures created by sofar (CC-BY-SA-3.0)
4043
doors_trapdoor_steel_side.png
4144
door_trapdoor_side.png
4245

46+
Door 3d models by sofar (CC-BY-SA-3.0)
47+
door_a.obj
48+
door_b.obj
49+
50+
Obsidian door textures by red-001 based on textures by Pilzadam and BlockMen: WTFPL
51+
door_obsidian_glass.png
52+
53+
Glass door textures by red-001 based on textures by celeron55: CC BY-SA 3.0
54+
door_glass.png
4355
All other textures (created by PilzAdam): WTFPL
4456

57+
Door textures were converted to the new texture map by sofar, paramat and
58+
red-001, under the same license as the originals.
59+
4560

4661
License of sounds
4762
--------------------------------------

2 commit comments

Comments
 (2)

JurajVajda commented on Feb 14, 2016

@JurajVajda

it's a great update, only if it wouldn't break all other mods what are using doors, will be there some solution for it ? (protector, messecon door, mydoors) Messecon doors where complaining also about some textures missing/renamed.

2016-02-14 00:13:02: ERROR[main]: ========== ERROR FROM LUA =========== 2016-02-14 00:13:02: ERROR[main]: Failed to load and run script from 2016-02-14 00:13:02: ERROR[main]: /root/.minetest/mods/protector/init.lua: 2016-02-14 00:13:02: ERROR[main]: /root/.minetest/mods/protector/doors_chest.lua:45: attempt to call field 'register_door' (a nil value) 2016-02-14 00:13:02: ERROR[main]: stack traceback: 2016-02-14 00:13:02: ERROR[main]: /root/.minetest/mods/protector/doors_chest.lua:45: in main chunk 2016-02-14 00:13:02: ERROR[main]: [C]: in function 'dofile' 2016-02-14 00:13:02: ERROR[main]: /root/.minetest/mods/protector/init.lua:532: in main chunk 2016-02-14 00:13:02: ERROR[main]: ======= END OF ERROR FROM LUA ======== 2016-02-14 00:13:02: ERROR[main]: Server: Failed to load and run /root/.minetest/mods/protector/init.lua

JurajVajda commented on Feb 14, 2016

@JurajVajda

i fixed mydoor mod and i found your commit in messecon mod - thanks a lot ;)

Please sign in to comment.