summaryrefslogtreecommitdiff
path: root/init.lua
blob: 5739b4e48b9eca8ca26c8968b7e4d198c112eede (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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
-- all nodes that do not fit in any other category
-- Author:  Och_Noe
-- Licence: LGPL 2.1 
-- 


local own_name = "advtrains_platform"


--  bricks / blocks

list_default =    { 
   "default:desert_sandstone_brick",
   "default:desert_stonebrick",
   "default:silver_sandstone_brick",
   "default:brick",
   "default:stone",
   "default:sandstone",
   "default:obsidian_glass",
   "default:dirt",
   "default:dirt_with_grass", 
   "default:desert_stone",
   "default:desert_sandstone",
-- added  2018-10-16    
   "default:desert_sandstone_brick",
-- added 2018-10-26
   "default:cobble",
}

list_moreblocks = {
   "moreblocks:cactus_brick",
   "moreblocks:coal_stone_bricks",
   "moreblocks:grey_bricks",
   "moreblocks:iron_stone_bricks",
   "moreblocks:stone_tile", 
-- added 2019-01-19
   "moreblocks:split_stone_tile", 
   "moreblocks:split_stone_tile_alt", 
}

list_ethereal = {
   "ethereal:icebrick",
   "ethereal:bamboo_dirt" }


-- added 2018-10-16
list_errata= {
   "minetest_errata:desert_sandstone_cobble",
   "minetest_errata:mossy_stone_tile",
   "minetest_errata:mossystone",
   "minetest_errata:sandstone_cobble",
   "minetest_errata:silver_sandstone_cobble", }


--  wood

list_wood= {
   "default:acacia_wood",
   "default:aspen_wood",
   "default:junglewood",
   "default:pine_wood",
   "default:wood"  }


list_wood_ethereal = {
   "ethereal:banana_wood",
   "ethereal:birch_wood",
   "ethereal:frost_wood",
   "ethereal:palm_wood",
   "ethereal:redwood_wood",
   "ethereal:willow_wood",
   "ethereal:yellow_wood",
   "ethereal:bamboo_floor"  }


list_wood_maple = { 
   "maple:maple_wood"  }



--  metal blocks

list_moreores = {
   "moreores:mithril_block" }


-- wool

-- ?


-- technic  - added 2019-03-11

list_technic =  {
	"technic:marble" }
	


for _,name in pairs(list_default) do
   advtrains.register_platform(own_name,name)   
end

if minetest.get_modpath("moreblocks") then
   for _,name in pairs(list_moreblocks) do
      advtrains.register_platform(own_name,name)   
   end
end

-- added 2018-10-16
if minetest.get_modpath("minetest_errata") then
   for _,name in pairs(list_errata) do
      advtrains.register_platform(own_name,name)   
   end
end



for _,name in pairs(list_wood) do
   advtrains.register_platform(own_name,name)   
end


if minetest.get_modpath("ethereal") then
   for _,name in pairs(list_ethereal) do
      advtrains.register_platform(own_name,name)   
   end
   for _,name in pairs(list_wood_ethereal) do
      advtrains.register_platform(own_name,name)   
   end
end


if minetest.get_modpath("maple") then
   for _,name in pairs(list_wood_maple) do
      advtrains.register_platform(own_name,name)   
   end
end


if minetest.get_modpath("moreores") then
   for _,name in pairs(list_moreores) do
      advtrains.register_platform(own_name,name)   
   end
end


if minetest.get_modpath("technic") then
   for _,name in pairs(list_technic) do
      advtrains.register_platform(own_name,name)
   end
end



local woodpath_lengths = { 
   { 5,10 },
   { 5,20 },
   { 5,25 },
   { 10,10 },
   { 10,20 },
   { 10,25 },
   { 20,20 },
   { 20,25 },
   { 25,25 },
}

local full_wood = "default:wood"
local half_wood = "stairs:slab_wood"
local adv_track = "advtrains:dtrack_placer"

for _,lengths in pairs(woodpath_lengths) do
   
   local b = lengths[1]  --  "back"  in 1/10 nodes
   local f = lengths[2]  --  "front" in 1/10 nodes   
   
   local h = string.format(":woodpath_track_%02d%02d",b,f)

   minetest.register_node(own_name..h, {
        tiles =  { "default_wood.png", },
        drawtype = "nodebox",
        paramtype = "light",
	paramtype2 = "facedir",
        node_box = {
                type = "fixed",
                fixed = {
                        {-0.4, -0.5, b/-10, 0.4, -0.4, f/10}, 
                }
        },
	groups = {choppy = 2, oddly_breakable_by_hand = 2,
	          not_blocking_trains = 1},
        sounds = default.node_sound_wood_defaults(),
	on_place = minetest.rotate_node,
	
     })


   local craft = { { "","","" } , { "","","" } , { "","","" } }
   
   craft[3][2] = adv_track
  
   for y = 2,1,-1
   do
      if (b>=5) and (f>=5) then
	 b = b-5
	 f = f-5
	 craft[y][2] = full_wood
      end
   end

   for y = 2,1,-1
   do
      if (b>=10) then
	 b = b-10
	 craft[y][1] = full_wood
      elseif (b>=5) then
	 b = b-5
	 craft[y][1] = half_wood
      end
      if (f>=10) then
	 f = f-10
	 craft[y][3] = full_wood
      elseif (f>=5) then
	 f = f-5
	 craft[y][3] = half_wood
      end
   end      

--   if (b>0) or (f>0) then
--      print(h.." b: "..b.." f: "..f)
--   else
--      t_aus = ""
--      for y=1,3 do
--	 for x=1,3 do
--	    t_aus = t_aus .. craft[y][x] .. ", "
--	 end
--      end
--      print(h..t_aus)
--   end

   minetest.register_craft({
			      output = own_name..h,
			      recipe = craft,
			      replacements = { {adv_track,adv_track}, }
			   })
end