aboutsummaryrefslogtreecommitdiff
path: root/advtrains/misc_nodes.lua
blob: 0750d1db60dca80d2fbc17208e01e5b45358c0b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
--all nodes that do not fit in any other category

function advtrains.register_platform(modprefix, preset, use_full_nodename)
	local ndef=minetest.registered_nodes[preset]
	if not ndef then 
		minetest.log("warning", " register_platform couldn't find preset node "..preset)
		return
	end
	local btex=ndef.tiles
	if type(btex)=="table" then
		btex=btex[1]
		if type(btex) == "table" then
			btex = btex.name
			if type(btex) ~= "string" then
				error("Error in tiles when registering a platform for "..preset.."!")
			end
		end
	end
	local desc=ndef.description or ""
	local nodename

	if use_full_nodename then
		local a, b = string.match(":"..preset, ":(.+):(.+)$")
		nodename = a.."_"..b
		-- minetest.log("warning", "DEBUG: generated name '"..nodename.."'")
	else
		nodename =string.match(preset, ":(.+)$")
	end
	-- minetest.log("action", "DEBUG: will register platforms for "..preset.." using nodename = ("..nodename..")")
	minetest.register_node(modprefix .. ":platform_low_"..nodename, {
		description = attrans("@1 Platform (low)", desc),
		tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex},
		groups = {cracky = 1, not_blocking_trains = 1, platform=1},
		sounds = ndef.sounds,
		drawtype = "nodebox",
		node_box = {
			type = "fixed",
			fixed = {
				{-0.5, -0.1, -0.1, 0.5,  0  , 0.5},
				{-0.5, -0.5,  0  , 0.5, -0.1, 0.5}
			},
		},
		paramtype2="facedir",
		paramtype = "light",
		sunlight_propagates = true,
	})
	minetest.register_node(modprefix .. ":platform_high_"..nodename, {
		description = attrans("@1 Platform (high)", desc),
		tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex},
		groups = {cracky = 1, not_blocking_trains = 1, platform=2},
		sounds = ndef.sounds,
		drawtype = "nodebox",
		node_box = {
			type = "fixed",
			fixed = {
				{-0.5,  0.3, 0, 0.5,  0.5, 0.5},
				{-0.5, -0.5, 0.1  , 0.5,  0.3, 0.5}
			},
		},
		paramtype2="facedir",
		paramtype = "light",
		sunlight_propagates = true,
	})
	local diagonalbox = {
			type = "fixed",
			fixed = {
				{-0.5,  -0.5, 0.5, -0.25, 0.5, -0.8 },
				{-0.25, -0.5, 0.5 , 0,    0.5, -0.55},
				{0,     -0.5, 0.5 , 0.25, 0.5, -0.3 },
				{0.25 , -0.5, 0.5,  0.5,  0.5, -0.05}
			}
	}
	minetest.register_node(modprefix..":platform_45_"..nodename, {
		description = attrans("@1 Platform (45 degree)", desc),
		groups = {cracky = 1, not_blocking_trains = 1, platform=2},
		sounds = ndef.sounds,
		drawtype = "mesh",
		mesh = "advtrains_platform_diag.b3d",
		selection_box = diagonalbox,
		collision_box = diagonalbox,
		tiles = {btex, btex.."^advtrains_platform_diag.png"},
		paramtype2 = "facedir",
		paramtype = "light",
		sunlight_propagates = true,
	})
	local diagonalbox_low = {
			type = "fixed",
			fixed = {
				{-0.5,  -0.5, 0.5, -0.25, 0, -0.8 },
				{-0.25, -0.5, 0.5 , 0,    0, -0.55},
				{0,     -0.5, 0.5 , 0.25, 0, -0.3 },
				{0.25 , -0.5, 0.5,  0.5,  0, -0.05}
			}
	}
	minetest.register_node(modprefix..":platform_45_low_"..nodename, {
		description = attrans("@1 Platform (low, 45 degree)", desc),
		groups = {cracky = 1, not_blocking_trains = 1, platform=2},
		sounds = ndef.sounds,
		drawtype = "mesh",
		mesh = "advtrains_platform_diag_low.b3d",
		selection_box = diagonalbox_low,
		collision_box = diagonalbox_low,
		tiles = {btex, btex.."^advtrains_platform_diag.png"},
		paramtype2 = "facedir",
		paramtype = "light",
		sunlight_propagates = true,
	})
	minetest.register_craft({
		type="shapeless",
		output = modprefix .. ":platform_high_"..nodename.." 4",
		recipe = {
			"dye:yellow", preset, preset
		},
	})
	minetest.register_craft({
		type="shapeless",
		output = modprefix .. ":platform_low_"..nodename.." 4",
		recipe = {
			"dye:yellow", preset
		},
	})
	minetest.register_craft({
		type="shapeless",
		output = modprefix .. ":platform_45_"..nodename.." 2",
		recipe = {
			"dye:yellow", preset, preset, preset
		}
	})
    minetest.register_craft({
        type="shapeless",
        output = modprefix .. ":platform_45_low_"..nodename.." 2",
        recipe = { modprefix .. ":platform_45_"..nodename },
    })
end

advtrains.register_platform("advtrains", "default:stonebrick")
-- advtrains.register_platform("advtrains", "default:sandstonebrick")

local platform_materials = {
	"basic_materials:cement_block",
	"basic_materials:concrete_block",
	"building_blocks:Tar",
	"darkage:basalt",
	"darkage:basalt_brick",
	-- "darkage:basalt_cobble",
	--"darkage:gneiss",
	"darkage:gneiss_brick",
	--"darkage:gneiss_cobble",
	{"darkage:marble"},
	-- "darkage:ors",
	"darkage:ors_brick",
	-- "darkage:ors_cobble",
	"darkage:serpentine",
	-- "darkage:slate",
	"darkage:slate_brick",
	-- "darkage:slate_cobble",
	"darkage:stone_brick",
	"default:acacia_wood",
	"default:aspen_wood",
	"default:desert_stone",
	"default:desert_stone_block",
	"default:junglewood",
	"default:pine_wood",
	"default:steelblock",
	"default:stone",
	"default:stone_block",
	"default:wood",
	"moretrees:cedar_planks",
	"moretrees:cherrytree_planks",
	"moretrees:chestnut_tree_planks",
	"moretrees:date_palm_planks",
	"moretrees:birch_planks",
	-- "moretrees:beech_planks",
	"moretrees:apple_tree_planks",
	"moretrees:ebony_planks",
	"moretrees:fir_planks",
	"moretrees:oak_planks",
	"moretrees:palm_planks",
	"moretrees:plumtree_planks",
	"moretrees:rubber_tree_planks",
	"moretrees:sequoia_planks",
	"moretrees:spruce_planks",
	"moretrees:poplar_planks",
	"moretrees:willow_planks",
	"moreblocks:wood_tile_center",
	"moreblocks:wood_tile_full",
	{"technic:marble"},
}
for _, name in ipairs(platform_materials) do
	local nodename, use_full_nodename
	if type(name) == "string" then
		nodename = name
	else
		nodename = name[1]
		use_full_nodename = true
	end

	if minetest.registered_nodes[nodename] then
		advtrains.register_platform("advtrains", nodename, use_full_nodename)
	else
		minetest.log("warning", nodename.." not find as a node to build a platform")
	end
end