init.lua 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. -- all nodes that do not fit in any other category
  2. -- Author: Och_Noe
  3. -- Licence: LGPL 2.1
  4. --
  5. local own_name = "advtrains_platform"
  6. local function register_platform(on,preset)
  7. local ndef=minetest.registered_nodes[preset]
  8. if not ndef then
  9. minetest.log("warning", " register_platform couldn't find preset node "..preset)
  10. return
  11. end
  12. local btex=ndef.tiles
  13. if type(btex)=="table" then
  14. btex=btex[1]
  15. end
  16. local desc=ndef.description or ""
  17. local nodename=string.match(preset, ":(.+)$")
  18. minetest.register_node(on..":platform_low_"..nodename, {
  19. description = attrans("@1 Platform (low)", desc),
  20. tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex},
  21. groups = {cracky = 1, not_blocking_trains = 1, platform=1},
  22. sounds = default.node_sound_stone_defaults(),
  23. drawtype = "nodebox",
  24. node_box = {
  25. type = "fixed",
  26. fixed = {
  27. {-0.5, -0.1, -0.1, 0.5, 0 , 0.5},
  28. {-0.5, -0.5, 0 , 0.5, -0.1, 0.5}
  29. },
  30. },
  31. paramtype2="facedir",
  32. paramtype = "light",
  33. sunlight_propagates = true,
  34. })
  35. minetest.register_node(on..":platform_high_"..nodename, {
  36. description = attrans("@1 Platform (high)", desc),
  37. tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex},
  38. groups = {cracky = 1, not_blocking_trains = 1, platform=2},
  39. sounds = default.node_sound_stone_defaults(),
  40. drawtype = "nodebox",
  41. node_box = {
  42. type = "fixed",
  43. fixed = {
  44. {-0.5, 0.3, -0.1, 0.5, 0.5, 0.5},
  45. {-0.5, -0.5, 0 , 0.5, 0.3, 0.5}
  46. },
  47. },
  48. paramtype2="facedir",
  49. paramtype = "light",
  50. sunlight_propagates = true,
  51. })
  52. minetest.register_craft({
  53. type="shapeless",
  54. output = on..":platform_high_"..nodename.." 4",
  55. recipe = {
  56. "dye:yellow", preset, preset
  57. },
  58. })
  59. minetest.register_craft({
  60. type="shapeless",
  61. output = on..":platform_low_"..nodename.." 4",
  62. recipe = {
  63. "dye:yellow", preset
  64. },
  65. })
  66. end
  67. -- bricks / blocks
  68. list_default = {
  69. "default:desert_sandstone_brick",
  70. "default:desert_stonebrick",
  71. "default:silver_sandstone",
  72. "default:silver_sandstone_brick",
  73. "default:silver_sandstone_block",
  74. "default:brick",
  75. "default:stone",
  76. "default:sandstone",
  77. "default:obsidian_glass",
  78. "default:dirt",
  79. "default:dirt_with_grass",
  80. "default:desert_stone",
  81. "default:desert_sandstone",
  82. -- added 2018-10-16
  83. "default:desert_sandstone_brick",
  84. -- added 2018-10-26
  85. "default:cobble",
  86. -- added 2021-04-04
  87. "default:steelblock",
  88. "default:obsidianbrick",
  89. }
  90. list_moreblocks = {
  91. "moreblocks:cactus_brick",
  92. "moreblocks:coal_stone_bricks",
  93. "moreblocks:grey_bricks",
  94. "moreblocks:iron_stone_bricks",
  95. "moreblocks:stone_tile",
  96. -- added 2019-01-19
  97. "moreblocks:split_stone_tile",
  98. "moreblocks:split_stone_tile_alt",
  99. }
  100. list_ethereal = {
  101. "ethereal:icebrick",
  102. "ethereal:bamboo_dirt"
  103. }
  104. -- added 2018-10-16
  105. list_errata= {
  106. "minetest_errata:desert_sandstone_cobble",
  107. "minetest_errata:mossy_stone_tile",
  108. "minetest_errata:mossystone",
  109. "minetest_errata:sandstone_cobble",
  110. "minetest_errata:silver_sandstone_cobble",
  111. -- added 2021-08-16
  112. "minetest_errata:flint_block",
  113. }
  114. -- wood
  115. list_wood= {
  116. "default:acacia_wood",
  117. "default:aspen_wood",
  118. "default:junglewood",
  119. "default:pine_wood",
  120. "default:wood"
  121. }
  122. list_wood_ethereal = {
  123. "ethereal:banana_wood",
  124. "ethereal:birch_wood",
  125. "ethereal:frost_wood",
  126. "ethereal:palm_wood",
  127. "ethereal:redwood_wood",
  128. "ethereal:willow_wood",
  129. "ethereal:yellow_wood",
  130. "ethereal:bamboo_floor",
  131. -- added 2020-01-12
  132. "ethereal:olive_wood",
  133. "ethereal:sakura_wood",
  134. }
  135. list_wood_maple = {
  136. "maple:maple_wood" }
  137. -- metal blocks
  138. list_moreores = {
  139. "moreores:mithril_block",
  140. -- added 2021-04-04
  141. "moreores:silver_block",
  142. }
  143. -- wool
  144. -- ?
  145. -- technic - added 2019-03-11
  146. list_technic = {
  147. "technic:marble" ,
  148. --added 2021-09-24
  149. "moretrees:rubber_tree_planks",
  150. }
  151. -- baked clay - added 2021-04-04
  152. -- only darker colours, or the yellow line will not be good visible
  153. -- currently only gray, because it does not create a colour contrast
  154. list_baked_clay = {
  155. "bakedclay:grey",
  156. "bakedclay:dark_grey",
  157. }
  158. for _,name in pairs(list_default) do
  159. register_platform(own_name,name)
  160. end
  161. if minetest.get_modpath("moreblocks") then
  162. for _,name in pairs(list_moreblocks) do
  163. register_platform(own_name,name)
  164. end
  165. end
  166. -- added 2018-10-16
  167. if minetest.get_modpath("minetest_errata") then
  168. for _,name in pairs(list_errata) do
  169. register_platform(own_name,name)
  170. end
  171. end
  172. for _,name in pairs(list_wood) do
  173. register_platform(own_name,name)
  174. end
  175. if minetest.get_modpath("ethereal") then
  176. for _,name in pairs(list_ethereal) do
  177. register_platform(own_name,name)
  178. end
  179. for _,name in pairs(list_wood_ethereal) do
  180. register_platform(own_name,name)
  181. end
  182. end
  183. if minetest.get_modpath("maple") then
  184. for _,name in pairs(list_wood_maple) do
  185. register_platform(own_name,name)
  186. end
  187. end
  188. if minetest.get_modpath("moreores") then
  189. for _,name in pairs(list_moreores) do
  190. register_platform(own_name,name)
  191. end
  192. end
  193. if minetest.get_modpath("technic") then
  194. for _,name in pairs(list_technic) do
  195. register_platform(own_name,name)
  196. end
  197. end
  198. if minetest.get_modpath("bakedclay") then
  199. for _,name in pairs(list_baked_clay) do
  200. register_platform(own_name,name)
  201. end
  202. end
  203. local woodpath_lengths = {
  204. { 5,10 },
  205. { 5,20 },
  206. { 5,25 },
  207. { 10,10 },
  208. { 10,20 },
  209. { 10,25 },
  210. { 20,20 },
  211. { 20,25 },
  212. { 25,25 },
  213. }
  214. -- path crossing track aka "level crossing"
  215. local snowdef = minetest.registered_nodes['default:snowblock']
  216. local node_sound_snow_default = nil
  217. if snowdef then
  218. node_sound_snow_default = snowdef.sounds
  219. end
  220. -- nodelist
  221. nodelist = {}
  222. -- nodelist:insert( { name = "", tile = ".png",
  223. -- sound = ,
  224. -- full = "", half = "" } )
  225. table.insert(nodelist, { name = "wood",
  226. tile = "default_wood.png",
  227. sound = default.node_sound_wood_defaults(),
  228. full = "default:wood",
  229. half = "moreblocks:slab_wood" } ) -- fixed
  230. -- half = "stairs:slab_wood" } )
  231. table.insert(nodelist, { name = "cobble",
  232. tile = "default_cobble.png",
  233. sound = default.node_sound_stone_defaults(),
  234. full = "default:cobble",
  235. half = "moreblocks:slab_cobble" } ) -- fixed
  236. -- half = "stairs:slab_cobble" } )
  237. table.insert(nodelist, { name = "stonebrick",
  238. tile = "default_stone_brick.png",
  239. sound = default.node_sound_stone_defaults(),
  240. full = "default:stonebrick",
  241. half = "moreblocks:slab_stonebrick" } ) -- fixed
  242. -- half = "stairs:slab_stonebrick" } )
  243. table.insert(nodelist, { name = "snow", tile = "default_snow.png",
  244. sound = node_sound_snow_default,
  245. full = "default:snowblock",
  246. half = "stairs:slab_snowblock" } )
  247. local adv_track = "advtrains:dtrack_placer"
  248. if minetest.get_modpath("moreblocks") then
  249. table.insert(nodelist, { name = "tar",
  250. tile = "moreblocks_tar.png",
  251. sound = default.node_sound_stone_defaults(),
  252. full = "moreblocks:tar",
  253. half = "moreblocks:slab_tar" } )
  254. table.insert(nodelist, { name = "stone tile",
  255. tile = "moreblocks_stone_tile.png",
  256. sound = default.node_sound_stone_defaults(),
  257. full = "moreblocks:stone_tile",
  258. half = "moreblocks:slab_stone_tile" } )
  259. -- added 2021-02-26
  260. table.insert(nodelist, { name = "stone tile alt",
  261. tile = "moreblocks_split_stone_tile_alt.png",
  262. sound = default.node_sound_stone_defaults(),
  263. full = "moreblocks:split_stone_tile_alt",
  264. half = "moreblocks:slab_split_stone_tile_alt" } )
  265. end
  266. for _,entry in pairs(nodelist) do
  267. for _,lengths in pairs(woodpath_lengths) do
  268. local b = lengths[1] -- "back" in 1/10 nodes
  269. local f = lengths[2] -- "front" in 1/10 nodes
  270. local h = string.format(":"..entry.name:gsub(" ","_") .."path_track_%02d%02d",b,f)
  271. local d = string.format(entry.name .." level crossing %02d-%02d",b,f)
  272. local h2 = string.format(":"..entry.name:gsub(" ","_") .."path_track_narrow_%02d%02d",b,f)
  273. local d2 = string.format(entry.name .." level crossing (narrow) %02d-%02d",b,f)
  274. minetest.register_node(own_name..h,
  275. {
  276. tiles = { entry.tile, },
  277. description = d,
  278. drawtype = "nodebox",
  279. paramtype = "light",
  280. paramtype2 = "facedir",
  281. node_box =
  282. {
  283. type = "fixed",
  284. fixed = {
  285. {-0.5, -0.5, b/-10, 0.5, -0.4, f/10},
  286. }
  287. },
  288. groups = {choppy = 2, not_blocking_trains = 1,
  289. oddly_breakable_by_hand = 2,
  290. },
  291. sounds = entry.sound,
  292. on_place = minetest.rotate_node,
  293. })
  294. minetest.register_node(own_name..h2,
  295. {
  296. tiles = { entry.tile, },
  297. description = d2,
  298. drawtype = "nodebox",
  299. paramtype = "light",
  300. paramtype2 = "facedir",
  301. node_box =
  302. {
  303. type = "fixed",
  304. fixed = {
  305. {-0.4, -0.5, b/-10, 0.4, -0.4, f/10},
  306. }
  307. },
  308. groups = {choppy = 2, not_blocking_trains = 1,
  309. oddly_breakable_by_hand = 2,
  310. },
  311. sounds = entry.sound,
  312. on_place = minetest.rotate_node,
  313. })
  314. local craft = { { "","","" } , { "","","" } , { "","","" } }
  315. craft[3][2] = adv_track
  316. for y = 2,1,-1
  317. do
  318. if (b>=5) and (f>=5) then
  319. b = b-5
  320. f = f-5
  321. craft[y][2] = entry.full
  322. end
  323. end
  324. for y = 2,1,-1
  325. do
  326. if (b>=10) then
  327. b = b-10
  328. craft[y][1] = entry.full
  329. elseif (b>=5) then
  330. b = b-5
  331. craft[y][1] = entry.half
  332. end
  333. if (f>=10) then
  334. f = f-10
  335. craft[y][3] = entry.full
  336. elseif (f>=5) then
  337. f = f-5
  338. craft[y][3] = entry.half
  339. end
  340. end
  341. -- if (b>0) or (f>0) then
  342. -- print(h.." b: "..b.." f: "..f)
  343. -- else
  344. -- t_aus = ""
  345. -- for y=1,3 do
  346. -- for x=1,3 do
  347. -- t_aus = t_aus .. craft[y][x] .. ", "
  348. -- end
  349. -- end
  350. -- print(h..t_aus)
  351. -- end
  352. minetest.register_craft({
  353. output = own_name..h,
  354. recipe = craft,
  355. replacements = { {adv_track,adv_track}, }
  356. })
  357. minetest.register_craft({
  358. output = own_name..h2,
  359. recipe = { { own_name..h } },
  360. })
  361. end
  362. -- 3 nodes long slope
  363. end
  364. minetest.register_node(own_name..":version_node", {
  365. description = own_name.." version node",
  366. tiles = {own_name.."_version_node.png"},
  367. groups = {cracky = 3,not_in_creative_inventory=1},
  368. })
  369. minetest.register_craft({
  370. output = own_name..":version_node",
  371. recipe = {
  372. { "advtrains_platform:platform_high_cobble" },
  373. { "advtrains_platform:platform_high_stone" },
  374. { adv_track },
  375. },
  376. })