Browse Source

Add trapdoor/door model specification (#2371)

An0n3m0us 2 years ago
parent
commit
172b62f802
2 changed files with 21 additions and 8 deletions
  1. 5 0
      game_api.txt
  2. 16 8
      mods/doors/init.lua

+ 5 - 0
game_api.txt

@@ -218,6 +218,8 @@ The doors mod allows modders to register custom doors and trapdoors.
 	description = "Door description",
 	inventory_image = "mod_door_inv.png",
 	groups = {choppy = 2},
+	model = "mod_door", -- (optional)
+	-- Model name without a suffix ("big_door" not "big_door_a.obj", "big_door_b.obj")
 	tiles = {"mod_door.png"}, -- UV map.
 	-- The front and back of the door must be identical in appearence as they swap on
 	-- open/close.
@@ -236,6 +238,9 @@ The doors mod allows modders to register custom doors and trapdoors.
 
 	description = "Trapdoor description",
 	inventory_image = "mod_trapdoor_inv.png",
+	nodebox_closed = {} -- Nodebox for closed model
+	nodebox_opened = {} -- Nodebox for opened model
+	-- (optional) both nodeboxes must be used, not one only
 	groups = {choppy = 2},
 	tile_front = "doors_trapdoor.png", -- the texture for the front and back of the trapdoor
 	tile_side = "doors_trapdoor_side.png",

+ 16 - 8
mods/doors/init.lua

@@ -670,10 +670,14 @@ function doors.register_trapdoor(name, def)
 	local def_opened = table.copy(def)
 	local def_closed = table.copy(def)
 
-	def_closed.node_box = {
-		type = "fixed",
-		fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
-	}
+	if def.nodebox_closed and def.nodebox_opened then
+		def_closed.node_box = def.nodebox_closed
+	else
+		def_closed.node_box = {
+		    type = "fixed",
+		    fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
+		}
+	end
 	def_closed.selection_box = {
 		type = "fixed",
 		fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
@@ -687,10 +691,14 @@ function doors.register_trapdoor(name, def)
 		def.tile_side
 	}
 
-	def_opened.node_box = {
-		type = "fixed",
-		fixed = {-0.5, -0.5, 6/16, 0.5, 0.5, 0.5}
-	}
+	if def.nodebox_opened and def.nodebox_closed then
+		def_opened.node_box = def.nodebox_opened
+	else
+		def_opened.node_box = {
+		    type = "fixed",
+		    fixed = {-0.5, -0.5, 6/16, 0.5, 0.5, 0.5}
+		}
+	end
 	def_opened.selection_box = {
 		type = "fixed",
 		fixed = {-0.5, -0.5, 6/16, 0.5, 0.5, 0.5}