init.lua 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113
  1. -- stairs/init.lua
  2. -- Minetest 0.4 mod: stairs
  3. -- See README.txt for licensing and other information.
  4. -- Global namespace for functions
  5. stairs = {}
  6. -- Load support for MT game translation.
  7. local S = minetest.get_translator("stairs")
  8. -- Register aliases for new pine node names
  9. minetest.register_alias("stairs:stair_pinewood", "stairs:stair_pine_wood")
  10. minetest.register_alias("stairs:slab_pinewood", "stairs:slab_pine_wood")
  11. -- Get setting for replace ABM
  12. local replace = minetest.settings:get_bool("enable_stairs_replace_abm")
  13. local function rotate_and_place(itemstack, placer, pointed_thing)
  14. local p0 = pointed_thing.under
  15. local p1 = pointed_thing.above
  16. local param2 = 0
  17. if placer then
  18. local placer_pos = placer:get_pos()
  19. if placer_pos then
  20. param2 = minetest.dir_to_facedir(vector.subtract(p1, placer_pos))
  21. end
  22. local finepos = minetest.pointed_thing_to_face_pos(placer, pointed_thing)
  23. local fpos = finepos.y % 1
  24. if p0.y - 1 == p1.y or (fpos > 0 and fpos < 0.5)
  25. or (fpos < -0.5 and fpos > -0.999999999) then
  26. param2 = param2 + 20
  27. if param2 == 21 then
  28. param2 = 23
  29. elseif param2 == 23 then
  30. param2 = 21
  31. end
  32. end
  33. end
  34. return minetest.item_place(itemstack, placer, pointed_thing, param2)
  35. end
  36. local function warn_if_exists(nodename)
  37. if minetest.registered_nodes[nodename] then
  38. minetest.log("warning", "Overwriting stairs node: " .. nodename)
  39. end
  40. end
  41. -- Register stair
  42. -- Node will be called stairs:stair_<subname>
  43. function stairs.register_stair(subname, recipeitem, groups, images, description,
  44. sounds, worldaligntex)
  45. -- Set backface culling and world-aligned textures
  46. local stair_images = {}
  47. for i, image in ipairs(images) do
  48. if type(image) == "string" then
  49. stair_images[i] = {
  50. name = image,
  51. backface_culling = true,
  52. }
  53. if worldaligntex then
  54. stair_images[i].align_style = "world"
  55. end
  56. else
  57. stair_images[i] = table.copy(image)
  58. if stair_images[i].backface_culling == nil then
  59. stair_images[i].backface_culling = true
  60. end
  61. if worldaligntex and stair_images[i].align_style == nil then
  62. stair_images[i].align_style = "world"
  63. end
  64. end
  65. end
  66. local new_groups = table.copy(groups)
  67. new_groups.stair = 1
  68. warn_if_exists("stairs:stair_" .. subname)
  69. minetest.register_node(":stairs:stair_" .. subname, {
  70. description = description,
  71. drawtype = "nodebox",
  72. tiles = stair_images,
  73. paramtype = "light",
  74. paramtype2 = "facedir",
  75. is_ground_content = false,
  76. groups = new_groups,
  77. sounds = sounds,
  78. node_box = {
  79. type = "fixed",
  80. fixed = {
  81. {-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
  82. {-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
  83. },
  84. },
  85. on_place = function(itemstack, placer, pointed_thing)
  86. if pointed_thing.type ~= "node" then
  87. return itemstack
  88. end
  89. return rotate_and_place(itemstack, placer, pointed_thing)
  90. end,
  91. })
  92. -- for replace ABM
  93. if replace then
  94. minetest.register_node(":stairs:stair_" .. subname .. "upside_down", {
  95. replace_name = "stairs:stair_" .. subname,
  96. groups = {slabs_replace = 1},
  97. })
  98. end
  99. if recipeitem then
  100. -- Recipe matches appearence in inventory
  101. minetest.register_craft({
  102. output = "stairs:stair_" .. subname .. " 8",
  103. recipe = {
  104. {"", "", recipeitem},
  105. {"", recipeitem, recipeitem},
  106. {recipeitem, recipeitem, recipeitem},
  107. },
  108. })
  109. -- Use stairs to craft full blocks again (1:1)
  110. minetest.register_craft({
  111. output = recipeitem .. " 3",
  112. recipe = {
  113. {"stairs:stair_" .. subname, "stairs:stair_" .. subname},
  114. {"stairs:stair_" .. subname, "stairs:stair_" .. subname},
  115. },
  116. })
  117. -- Fuel
  118. local baseburntime = minetest.get_craft_result({
  119. method = "fuel",
  120. width = 1,
  121. items = {recipeitem}
  122. }).time
  123. if baseburntime > 0 then
  124. minetest.register_craft({
  125. type = "fuel",
  126. recipe = "stairs:stair_" .. subname,
  127. burntime = math.floor(baseburntime * 0.75),
  128. })
  129. end
  130. end
  131. end
  132. -- Register slab
  133. -- Node will be called stairs:slab_<subname>
  134. function stairs.register_slab(subname, recipeitem, groups, images, description,
  135. sounds, worldaligntex)
  136. -- Set world-aligned textures
  137. local slab_images = {}
  138. for i, image in ipairs(images) do
  139. if type(image) == "string" then
  140. slab_images[i] = {
  141. name = image,
  142. }
  143. if worldaligntex then
  144. slab_images[i].align_style = "world"
  145. end
  146. else
  147. slab_images[i] = table.copy(image)
  148. if worldaligntex and image.align_style == nil then
  149. slab_images[i].align_style = "world"
  150. end
  151. end
  152. end
  153. local new_groups = table.copy(groups)
  154. new_groups.slab = 1
  155. warn_if_exists("stairs:slab_" .. subname)
  156. minetest.register_node(":stairs:slab_" .. subname, {
  157. description = description,
  158. drawtype = "nodebox",
  159. tiles = slab_images,
  160. paramtype = "light",
  161. paramtype2 = "facedir",
  162. is_ground_content = false,
  163. groups = new_groups,
  164. sounds = sounds,
  165. node_box = {
  166. type = "fixed",
  167. fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
  168. },
  169. on_place = function(itemstack, placer, pointed_thing)
  170. local under = minetest.get_node(pointed_thing.under)
  171. local wield_item = itemstack:get_name()
  172. local player_name = placer and placer:get_player_name() or ""
  173. local creative_enabled = (creative and creative.is_enabled_for
  174. and creative.is_enabled_for(player_name))
  175. if under and under.name:find("^stairs:slab_") then
  176. -- place slab using under node orientation
  177. local dir = minetest.dir_to_facedir(vector.subtract(
  178. pointed_thing.above, pointed_thing.under), true)
  179. local p2 = under.param2
  180. -- Placing a slab on an upside down slab should make it right-side up.
  181. if p2 >= 20 and dir == 8 then
  182. p2 = p2 - 20
  183. -- same for the opposite case: slab below normal slab
  184. elseif p2 <= 3 and dir == 4 then
  185. p2 = p2 + 20
  186. end
  187. -- else attempt to place node with proper param2
  188. minetest.item_place_node(ItemStack(wield_item), placer, pointed_thing, p2)
  189. if not creative_enabled then
  190. itemstack:take_item()
  191. end
  192. return itemstack
  193. else
  194. return rotate_and_place(itemstack, placer, pointed_thing)
  195. end
  196. end,
  197. })
  198. -- for replace ABM
  199. if replace then
  200. minetest.register_node(":stairs:slab_" .. subname .. "upside_down", {
  201. replace_name = "stairs:slab_".. subname,
  202. groups = {slabs_replace = 1},
  203. })
  204. end
  205. if recipeitem then
  206. minetest.register_craft({
  207. output = "stairs:slab_" .. subname .. " 6",
  208. recipe = {
  209. {recipeitem, recipeitem, recipeitem},
  210. },
  211. })
  212. -- Use 2 slabs to craft a full block again (1:1)
  213. minetest.register_craft({
  214. output = recipeitem,
  215. recipe = {
  216. {"stairs:slab_" .. subname},
  217. {"stairs:slab_" .. subname},
  218. },
  219. })
  220. -- Fuel
  221. local baseburntime = minetest.get_craft_result({
  222. method = "fuel",
  223. width = 1,
  224. items = {recipeitem}
  225. }).time
  226. if baseburntime > 0 then
  227. minetest.register_craft({
  228. type = "fuel",
  229. recipe = "stairs:slab_" .. subname,
  230. burntime = math.floor(baseburntime * 0.5),
  231. })
  232. end
  233. end
  234. end
  235. -- Optionally replace old "upside_down" nodes with new param2 versions.
  236. -- Disabled by default.
  237. if replace then
  238. minetest.register_abm({
  239. label = "Slab replace",
  240. nodenames = {"group:slabs_replace"},
  241. interval = 16,
  242. chance = 1,
  243. action = function(pos, node)
  244. node.name = minetest.registered_nodes[node.name].replace_name
  245. node.param2 = node.param2 + 20
  246. if node.param2 == 21 then
  247. node.param2 = 23
  248. elseif node.param2 == 23 then
  249. node.param2 = 21
  250. end
  251. minetest.set_node(pos, node)
  252. end,
  253. })
  254. end
  255. -- Register inner stair
  256. -- Node will be called stairs:stair_inner_<subname>
  257. function stairs.register_stair_inner(subname, recipeitem, groups, images,
  258. description, sounds, worldaligntex, full_description)
  259. -- Set backface culling and world-aligned textures
  260. local stair_images = {}
  261. for i, image in ipairs(images) do
  262. if type(image) == "string" then
  263. stair_images[i] = {
  264. name = image,
  265. backface_culling = true,
  266. }
  267. if worldaligntex then
  268. stair_images[i].align_style = "world"
  269. end
  270. else
  271. stair_images[i] = table.copy(image)
  272. if stair_images[i].backface_culling == nil then
  273. stair_images[i].backface_culling = true
  274. end
  275. if worldaligntex and stair_images[i].align_style == nil then
  276. stair_images[i].align_style = "world"
  277. end
  278. end
  279. end
  280. local new_groups = table.copy(groups)
  281. new_groups.stair = 1
  282. if full_description then
  283. description = full_description
  284. else
  285. description = "Inner " .. description
  286. end
  287. warn_if_exists("stairs:stair_inner_" .. subname)
  288. minetest.register_node(":stairs:stair_inner_" .. subname, {
  289. description = description,
  290. drawtype = "nodebox",
  291. tiles = stair_images,
  292. paramtype = "light",
  293. paramtype2 = "facedir",
  294. is_ground_content = false,
  295. groups = new_groups,
  296. sounds = sounds,
  297. node_box = {
  298. type = "fixed",
  299. fixed = {
  300. {-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
  301. {-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
  302. {-0.5, 0.0, -0.5, 0.0, 0.5, 0.0},
  303. },
  304. },
  305. on_place = function(itemstack, placer, pointed_thing)
  306. if pointed_thing.type ~= "node" then
  307. return itemstack
  308. end
  309. return rotate_and_place(itemstack, placer, pointed_thing)
  310. end,
  311. })
  312. if recipeitem then
  313. minetest.register_craft({
  314. output = "stairs:stair_inner_" .. subname .. " 7",
  315. recipe = {
  316. {"", recipeitem, ""},
  317. {recipeitem, "", recipeitem},
  318. {recipeitem, recipeitem, recipeitem},
  319. },
  320. })
  321. -- Fuel
  322. local baseburntime = minetest.get_craft_result({
  323. method = "fuel",
  324. width = 1,
  325. items = {recipeitem}
  326. }).time
  327. if baseburntime > 0 then
  328. minetest.register_craft({
  329. type = "fuel",
  330. recipe = "stairs:stair_inner_" .. subname,
  331. burntime = math.floor(baseburntime * 0.875),
  332. })
  333. end
  334. end
  335. end
  336. -- Register outer stair
  337. -- Node will be called stairs:stair_outer_<subname>
  338. function stairs.register_stair_outer(subname, recipeitem, groups, images,
  339. description, sounds, worldaligntex, full_description)
  340. -- Set backface culling and world-aligned textures
  341. local stair_images = {}
  342. for i, image in ipairs(images) do
  343. if type(image) == "string" then
  344. stair_images[i] = {
  345. name = image,
  346. backface_culling = true,
  347. }
  348. if worldaligntex then
  349. stair_images[i].align_style = "world"
  350. end
  351. else
  352. stair_images[i] = table.copy(image)
  353. if stair_images[i].backface_culling == nil then
  354. stair_images[i].backface_culling = true
  355. end
  356. if worldaligntex and stair_images[i].align_style == nil then
  357. stair_images[i].align_style = "world"
  358. end
  359. end
  360. end
  361. local new_groups = table.copy(groups)
  362. new_groups.stair = 1
  363. if full_description then
  364. description = full_description
  365. else
  366. description = "Outer " .. description
  367. end
  368. warn_if_exists("stairs:stair_outer_" .. subname)
  369. minetest.register_node(":stairs:stair_outer_" .. subname, {
  370. description = description,
  371. drawtype = "nodebox",
  372. tiles = stair_images,
  373. paramtype = "light",
  374. paramtype2 = "facedir",
  375. is_ground_content = false,
  376. groups = new_groups,
  377. sounds = sounds,
  378. node_box = {
  379. type = "fixed",
  380. fixed = {
  381. {-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
  382. {-0.5, 0.0, 0.0, 0.0, 0.5, 0.5},
  383. },
  384. },
  385. on_place = function(itemstack, placer, pointed_thing)
  386. if pointed_thing.type ~= "node" then
  387. return itemstack
  388. end
  389. return rotate_and_place(itemstack, placer, pointed_thing)
  390. end,
  391. })
  392. if recipeitem then
  393. minetest.register_craft({
  394. output = "stairs:stair_outer_" .. subname .. " 6",
  395. recipe = {
  396. {"", recipeitem, ""},
  397. {recipeitem, recipeitem, recipeitem},
  398. },
  399. })
  400. -- Fuel
  401. local baseburntime = minetest.get_craft_result({
  402. method = "fuel",
  403. width = 1,
  404. items = {recipeitem}
  405. }).time
  406. if baseburntime > 0 then
  407. minetest.register_craft({
  408. type = "fuel",
  409. recipe = "stairs:stair_outer_" .. subname,
  410. burntime = math.floor(baseburntime * 0.625),
  411. })
  412. end
  413. end
  414. end
  415. -- Stair/slab registration function.
  416. -- Nodes will be called stairs:{stair,slab}_<subname>
  417. function stairs.register_stair_and_slab(subname, recipeitem, groups, images,
  418. desc_stair, desc_slab, sounds, worldaligntex)
  419. stairs.register_stair(subname, recipeitem, groups, images, desc_stair,
  420. sounds, worldaligntex)
  421. stairs.register_stair_inner(subname, recipeitem, groups, images, desc_stair,
  422. sounds, worldaligntex)
  423. stairs.register_stair_outer(subname, recipeitem, groups, images, desc_stair,
  424. sounds, worldaligntex)
  425. stairs.register_slab(subname, recipeitem, groups, images, desc_slab,
  426. sounds, worldaligntex)
  427. end
  428. -- Local function so we can apply translations
  429. local function my_register_stair_and_slab(subname, recipeitem, groups, images,
  430. desc_stair, desc_slab, sounds, worldaligntex)
  431. stairs.register_stair(subname, recipeitem, groups, images, S(desc_stair),
  432. sounds, worldaligntex)
  433. stairs.register_stair_inner(subname, recipeitem, groups, images, "",
  434. sounds, worldaligntex, S("Inner " .. desc_stair))
  435. stairs.register_stair_outer(subname, recipeitem, groups, images, "",
  436. sounds, worldaligntex, S("Outer " .. desc_stair))
  437. stairs.register_slab(subname, recipeitem, groups, images, S(desc_slab),
  438. sounds, worldaligntex)
  439. end
  440. -- Register default stairs and slabs
  441. my_register_stair_and_slab(
  442. "wood",
  443. "default:wood",
  444. {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
  445. {"default_wood.png"},
  446. "Wooden Stair",
  447. "Wooden Slab",
  448. default.node_sound_wood_defaults(),
  449. false
  450. )
  451. my_register_stair_and_slab(
  452. "junglewood",
  453. "default:junglewood",
  454. {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
  455. {"default_junglewood.png"},
  456. "Jungle Wood Stair",
  457. "Jungle Wood Slab",
  458. default.node_sound_wood_defaults(),
  459. false
  460. )
  461. my_register_stair_and_slab(
  462. "pine_wood",
  463. "default:pine_wood",
  464. {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
  465. {"default_pine_wood.png"},
  466. "Pine Wood Stair",
  467. "Pine Wood Slab",
  468. default.node_sound_wood_defaults(),
  469. false
  470. )
  471. my_register_stair_and_slab(
  472. "acacia_wood",
  473. "default:acacia_wood",
  474. {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
  475. {"default_acacia_wood.png"},
  476. "Acacia Wood Stair",
  477. "Acacia Wood Slab",
  478. default.node_sound_wood_defaults(),
  479. false
  480. )
  481. my_register_stair_and_slab(
  482. "aspen_wood",
  483. "default:aspen_wood",
  484. {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
  485. {"default_aspen_wood.png"},
  486. "Aspen Wood Stair",
  487. "Aspen Wood Slab",
  488. default.node_sound_wood_defaults(),
  489. false
  490. )
  491. my_register_stair_and_slab(
  492. "stone",
  493. "default:stone",
  494. {cracky = 3},
  495. {"default_stone.png"},
  496. "Stone Stair",
  497. "Stone Slab",
  498. default.node_sound_stone_defaults(),
  499. true
  500. )
  501. my_register_stair_and_slab(
  502. "cobble",
  503. "default:cobble",
  504. {cracky = 3},
  505. {"default_cobble.png"},
  506. "Cobblestone Stair",
  507. "Cobblestone Slab",
  508. default.node_sound_stone_defaults(),
  509. true
  510. )
  511. my_register_stair_and_slab(
  512. "mossycobble",
  513. "default:mossycobble",
  514. {cracky = 3},
  515. {"default_mossycobble.png"},
  516. "Mossy Cobblestone Stair",
  517. "Mossy Cobblestone Slab",
  518. default.node_sound_stone_defaults(),
  519. true
  520. )
  521. my_register_stair_and_slab(
  522. "stonebrick",
  523. "default:stonebrick",
  524. {cracky = 2},
  525. {"default_stone_brick.png"},
  526. "Stone Brick Stair",
  527. "Stone Brick Slab",
  528. default.node_sound_stone_defaults(),
  529. false
  530. )
  531. my_register_stair_and_slab(
  532. "stone_block",
  533. "default:stone_block",
  534. {cracky = 2},
  535. {"default_stone_block.png"},
  536. "Stone Block Stair",
  537. "Stone Block Slab",
  538. default.node_sound_stone_defaults(),
  539. true
  540. )
  541. my_register_stair_and_slab(
  542. "desert_stone",
  543. "default:desert_stone",
  544. {cracky = 3},
  545. {"default_desert_stone.png"},
  546. "Desert Stone Stair",
  547. "Desert Stone Slab",
  548. default.node_sound_stone_defaults(),
  549. true
  550. )
  551. my_register_stair_and_slab(
  552. "desert_cobble",
  553. "default:desert_cobble",
  554. {cracky = 3},
  555. {"default_desert_cobble.png"},
  556. "Desert Cobblestone Stair",
  557. "Desert Cobblestone Slab",
  558. default.node_sound_stone_defaults(),
  559. true
  560. )
  561. my_register_stair_and_slab(
  562. "desert_stonebrick",
  563. "default:desert_stonebrick",
  564. {cracky = 2},
  565. {"default_desert_stone_brick.png"},
  566. "Desert Stone Brick Stair",
  567. "Desert Stone Brick Slab",
  568. default.node_sound_stone_defaults(),
  569. false
  570. )
  571. my_register_stair_and_slab(
  572. "desert_stone_block",
  573. "default:desert_stone_block",
  574. {cracky = 2},
  575. {"default_desert_stone_block.png"},
  576. "Desert Stone Block Stair",
  577. "Desert Stone Block Slab",
  578. default.node_sound_stone_defaults(),
  579. true
  580. )
  581. my_register_stair_and_slab(
  582. "sandstone",
  583. "default:sandstone",
  584. {crumbly = 1, cracky = 3},
  585. {"default_sandstone.png"},
  586. "Sandstone Stair",
  587. "Sandstone Slab",
  588. default.node_sound_stone_defaults(),
  589. true
  590. )
  591. my_register_stair_and_slab(
  592. "sandstonebrick",
  593. "default:sandstonebrick",
  594. {cracky = 2},
  595. {"default_sandstone_brick.png"},
  596. "Sandstone Brick Stair",
  597. "Sandstone Brick Slab",
  598. default.node_sound_stone_defaults(),
  599. false
  600. )
  601. my_register_stair_and_slab(
  602. "sandstone_block",
  603. "default:sandstone_block",
  604. {cracky = 2},
  605. {"default_sandstone_block.png"},
  606. "Sandstone Block Stair",
  607. "Sandstone Block Slab",
  608. default.node_sound_stone_defaults(),
  609. true
  610. )
  611. my_register_stair_and_slab(
  612. "desert_sandstone",
  613. "default:desert_sandstone",
  614. {crumbly = 1, cracky = 3},
  615. {"default_desert_sandstone.png"},
  616. "Desert Sandstone Stair",
  617. "Desert Sandstone Slab",
  618. default.node_sound_stone_defaults(),
  619. true
  620. )
  621. my_register_stair_and_slab(
  622. "desert_sandstone_brick",
  623. "default:desert_sandstone_brick",
  624. {cracky = 2},
  625. {"default_desert_sandstone_brick.png"},
  626. "Desert Sandstone Brick Stair",
  627. "Desert Sandstone Brick Slab",
  628. default.node_sound_stone_defaults(),
  629. false
  630. )
  631. my_register_stair_and_slab(
  632. "desert_sandstone_block",
  633. "default:desert_sandstone_block",
  634. {cracky = 2},
  635. {"default_desert_sandstone_block.png"},
  636. "Desert Sandstone Block Stair",
  637. "Desert Sandstone Block Slab",
  638. default.node_sound_stone_defaults(),
  639. true
  640. )
  641. my_register_stair_and_slab(
  642. "silver_sandstone",
  643. "default:silver_sandstone",
  644. {crumbly = 1, cracky = 3},
  645. {"default_silver_sandstone.png"},
  646. "Silver Sandstone Stair",
  647. "Silver Sandstone Slab",
  648. default.node_sound_stone_defaults(),
  649. true
  650. )
  651. my_register_stair_and_slab(
  652. "silver_sandstone_brick",
  653. "default:silver_sandstone_brick",
  654. {cracky = 2},
  655. {"default_silver_sandstone_brick.png"},
  656. "Silver Sandstone Brick Stair",
  657. "Silver Sandstone Brick Slab",
  658. default.node_sound_stone_defaults(),
  659. false
  660. )
  661. my_register_stair_and_slab(
  662. "silver_sandstone_block",
  663. "default:silver_sandstone_block",
  664. {cracky = 2},
  665. {"default_silver_sandstone_block.png"},
  666. "Silver Sandstone Block Stair",
  667. "Silver Sandstone Block Slab",
  668. default.node_sound_stone_defaults(),
  669. true
  670. )
  671. my_register_stair_and_slab(
  672. "obsidian",
  673. "default:obsidian",
  674. {cracky = 1, level = 2},
  675. {"default_obsidian.png"},
  676. "Obsidian Stair",
  677. "Obsidian Slab",
  678. default.node_sound_stone_defaults(),
  679. true
  680. )
  681. my_register_stair_and_slab(
  682. "obsidianbrick",
  683. "default:obsidianbrick",
  684. {cracky = 1, level = 2},
  685. {"default_obsidian_brick.png"},
  686. "Obsidian Brick Stair",
  687. "Obsidian Brick Slab",
  688. default.node_sound_stone_defaults(),
  689. false
  690. )
  691. my_register_stair_and_slab(
  692. "obsidian_block",
  693. "default:obsidian_block",
  694. {cracky = 1, level = 2},
  695. {"default_obsidian_block.png"},
  696. "Obsidian Block Stair",
  697. "Obsidian Block Slab",
  698. default.node_sound_stone_defaults(),
  699. true
  700. )
  701. my_register_stair_and_slab(
  702. "brick",
  703. "default:brick",
  704. {cracky = 3},
  705. {"default_brick.png"},
  706. "Brick Stair",
  707. "Brick Slab",
  708. default.node_sound_stone_defaults(),
  709. false
  710. )
  711. my_register_stair_and_slab(
  712. "steelblock",
  713. "default:steelblock",
  714. {cracky = 1, level = 2},
  715. {"default_steel_block.png"},
  716. "Steel Block Stair",
  717. "Steel Block Slab",
  718. default.node_sound_metal_defaults(),
  719. true
  720. )
  721. my_register_stair_and_slab(
  722. "tinblock",
  723. "default:tinblock",
  724. {cracky = 1, level = 2},
  725. {"default_tin_block.png"},
  726. "Tin Block Stair",
  727. "Tin Block Slab",
  728. default.node_sound_metal_defaults(),
  729. true
  730. )
  731. my_register_stair_and_slab(
  732. "copperblock",
  733. "default:copperblock",
  734. {cracky = 1, level = 2},
  735. {"default_copper_block.png"},
  736. "Copper Block Stair",
  737. "Copper Block Slab",
  738. default.node_sound_metal_defaults(),
  739. true
  740. )
  741. my_register_stair_and_slab(
  742. "bronzeblock",
  743. "default:bronzeblock",
  744. {cracky = 1, level = 2},
  745. {"default_bronze_block.png"},
  746. "Bronze Block Stair",
  747. "Bronze Block Slab",
  748. default.node_sound_metal_defaults(),
  749. true
  750. )
  751. my_register_stair_and_slab(
  752. "goldblock",
  753. "default:goldblock",
  754. {cracky = 1},
  755. {"default_gold_block.png"},
  756. "Gold Block Stair",
  757. "Gold Block Slab",
  758. default.node_sound_metal_defaults(),
  759. true
  760. )
  761. my_register_stair_and_slab(
  762. "ice",
  763. "default:ice",
  764. {cracky = 3, cools_lava = 1, slippery = 3},
  765. {"default_ice.png"},
  766. "Ice Stair",
  767. "Ice Slab",
  768. default.node_sound_glass_defaults(),
  769. true
  770. )
  771. my_register_stair_and_slab(
  772. "snowblock",
  773. "default:snowblock",
  774. {crumbly = 3, cools_lava = 1, snowy = 1},
  775. {"default_snow.png"},
  776. "Snow Block Stair",
  777. "Snow Block Slab",
  778. default.node_sound_snow_defaults(),
  779. true
  780. )
  781. -- Glass stair nodes need to be registered individually to utilize specialized textures.
  782. stairs.register_stair(
  783. "glass",
  784. "default:glass",
  785. {cracky = 3, oddly_breakable_by_hand = 3},
  786. {"stairs_glass_split.png", "default_glass.png",
  787. "stairs_glass_stairside.png^[transformFX", "stairs_glass_stairside.png",
  788. "default_glass.png", "stairs_glass_split.png"},
  789. S("Glass Stair"),
  790. default.node_sound_glass_defaults(),
  791. false
  792. )
  793. stairs.register_slab(
  794. "glass",
  795. "default:glass",
  796. {cracky = 3, oddly_breakable_by_hand = 3},
  797. {"default_glass.png", "default_glass.png", "stairs_glass_split.png"},
  798. S("Glass Slab"),
  799. default.node_sound_glass_defaults(),
  800. false
  801. )
  802. stairs.register_stair_inner(
  803. "glass",
  804. "default:glass",
  805. {cracky = 3, oddly_breakable_by_hand = 3},
  806. {"stairs_glass_stairside.png^[transformR270", "default_glass.png",
  807. "stairs_glass_stairside.png^[transformFX", "default_glass.png",
  808. "default_glass.png", "stairs_glass_stairside.png"},
  809. "",
  810. default.node_sound_glass_defaults(),
  811. false,
  812. S("Inner Glass Stair")
  813. )
  814. stairs.register_stair_outer(
  815. "glass",
  816. "default:glass",
  817. {cracky = 3, oddly_breakable_by_hand = 3},
  818. {"stairs_glass_stairside.png^[transformR90", "default_glass.png",
  819. "stairs_glass_outer_stairside.png", "stairs_glass_stairside.png",
  820. "stairs_glass_stairside.png^[transformR90","stairs_glass_outer_stairside.png"},
  821. "",
  822. default.node_sound_glass_defaults(),
  823. false,
  824. S("Outer Glass Stair")
  825. )
  826. stairs.register_stair(
  827. "obsidian_glass",
  828. "default:obsidian_glass",
  829. {cracky = 3},
  830. {"stairs_obsidian_glass_split.png", "default_obsidian_glass.png",
  831. "stairs_obsidian_glass_stairside.png^[transformFX", "stairs_obsidian_glass_stairside.png",
  832. "default_obsidian_glass.png", "stairs_obsidian_glass_split.png"},
  833. S("Obsidian Glass Stair"),
  834. default.node_sound_glass_defaults(),
  835. false
  836. )
  837. stairs.register_slab(
  838. "obsidian_glass",
  839. "default:obsidian_glass",
  840. {cracky = 3},
  841. {"default_obsidian_glass.png", "default_obsidian_glass.png", "stairs_obsidian_glass_split.png"},
  842. S("Obsidian Glass Slab"),
  843. default.node_sound_glass_defaults(),
  844. false
  845. )
  846. stairs.register_stair_inner(
  847. "obsidian_glass",
  848. "default:obsidian_glass",
  849. {cracky = 3},
  850. {"stairs_obsidian_glass_stairside.png^[transformR270", "default_obsidian_glass.png",
  851. "stairs_obsidian_glass_stairside.png^[transformFX", "default_obsidian_glass.png",
  852. "default_obsidian_glass.png", "stairs_obsidian_glass_stairside.png"},
  853. "",
  854. default.node_sound_glass_defaults(),
  855. false,
  856. S("Inner Obsidian Glass Stair")
  857. )
  858. stairs.register_stair_outer(
  859. "obsidian_glass",
  860. "default:obsidian_glass",
  861. {cracky = 3},
  862. {"stairs_obsidian_glass_stairside.png^[transformR90", "default_obsidian_glass.png",
  863. "stairs_obsidian_glass_outer_stairside.png", "stairs_obsidian_glass_stairside.png",
  864. "stairs_obsidian_glass_stairside.png^[transformR90","stairs_obsidian_glass_outer_stairside.png"},
  865. "",
  866. default.node_sound_glass_defaults(),
  867. false,
  868. S("Outer Obsidian Glass Stair")
  869. )
  870. -- Dummy calls to S() to allow translation scripts to detect the strings.
  871. -- To update this add this code to my_register_stair_and_slab:
  872. -- for _,x in ipairs({"","Inner ","Outer "}) do print(("S(%q)"):format(x..desc_stair)) end
  873. -- print(("S(%q)"):format(desc_slab))
  874. --[[
  875. S("Wooden Stair")
  876. S("Inner Wooden Stair")
  877. S("Outer Wooden Stair")
  878. S("Wooden Slab")
  879. S("Jungle Wood Stair")
  880. S("Inner Jungle Wood Stair")
  881. S("Outer Jungle Wood Stair")
  882. S("Jungle Wood Slab")
  883. S("Pine Wood Stair")
  884. S("Inner Pine Wood Stair")
  885. S("Outer Pine Wood Stair")
  886. S("Pine Wood Slab")
  887. S("Acacia Wood Stair")
  888. S("Inner Acacia Wood Stair")
  889. S("Outer Acacia Wood Stair")
  890. S("Acacia Wood Slab")
  891. S("Aspen Wood Stair")
  892. S("Inner Aspen Wood Stair")
  893. S("Outer Aspen Wood Stair")
  894. S("Aspen Wood Slab")
  895. S("Stone Stair")
  896. S("Inner Stone Stair")
  897. S("Outer Stone Stair")
  898. S("Stone Slab")
  899. S("Cobblestone Stair")
  900. S("Inner Cobblestone Stair")
  901. S("Outer Cobblestone Stair")
  902. S("Cobblestone Slab")
  903. S("Mossy Cobblestone Stair")
  904. S("Inner Mossy Cobblestone Stair")
  905. S("Outer Mossy Cobblestone Stair")
  906. S("Mossy Cobblestone Slab")
  907. S("Stone Brick Stair")
  908. S("Inner Stone Brick Stair")
  909. S("Outer Stone Brick Stair")
  910. S("Stone Brick Slab")
  911. S("Stone Block Stair")
  912. S("Inner Stone Block Stair")
  913. S("Outer Stone Block Stair")
  914. S("Stone Block Slab")
  915. S("Desert Stone Stair")
  916. S("Inner Desert Stone Stair")
  917. S("Outer Desert Stone Stair")
  918. S("Desert Stone Slab")
  919. S("Desert Cobblestone Stair")
  920. S("Inner Desert Cobblestone Stair")
  921. S("Outer Desert Cobblestone Stair")
  922. S("Desert Cobblestone Slab")
  923. S("Desert Stone Brick Stair")
  924. S("Inner Desert Stone Brick Stair")
  925. S("Outer Desert Stone Brick Stair")
  926. S("Desert Stone Brick Slab")
  927. S("Desert Stone Block Stair")
  928. S("Inner Desert Stone Block Stair")
  929. S("Outer Desert Stone Block Stair")
  930. S("Desert Stone Block Slab")
  931. S("Sandstone Stair")
  932. S("Inner Sandstone Stair")
  933. S("Outer Sandstone Stair")
  934. S("Sandstone Slab")
  935. S("Sandstone Brick Stair")
  936. S("Inner Sandstone Brick Stair")
  937. S("Outer Sandstone Brick Stair")
  938. S("Sandstone Brick Slab")
  939. S("Sandstone Block Stair")
  940. S("Inner Sandstone Block Stair")
  941. S("Outer Sandstone Block Stair")
  942. S("Sandstone Block Slab")
  943. S("Desert Sandstone Stair")
  944. S("Inner Desert Sandstone Stair")
  945. S("Outer Desert Sandstone Stair")
  946. S("Desert Sandstone Slab")
  947. S("Desert Sandstone Brick Stair")
  948. S("Inner Desert Sandstone Brick Stair")
  949. S("Outer Desert Sandstone Brick Stair")
  950. S("Desert Sandstone Brick Slab")
  951. S("Desert Sandstone Block Stair")
  952. S("Inner Desert Sandstone Block Stair")
  953. S("Outer Desert Sandstone Block Stair")
  954. S("Desert Sandstone Block Slab")
  955. S("Silver Sandstone Stair")
  956. S("Inner Silver Sandstone Stair")
  957. S("Outer Silver Sandstone Stair")
  958. S("Silver Sandstone Slab")
  959. S("Silver Sandstone Brick Stair")
  960. S("Inner Silver Sandstone Brick Stair")
  961. S("Outer Silver Sandstone Brick Stair")
  962. S("Silver Sandstone Brick Slab")
  963. S("Silver Sandstone Block Stair")
  964. S("Inner Silver Sandstone Block Stair")
  965. S("Outer Silver Sandstone Block Stair")
  966. S("Silver Sandstone Block Slab")
  967. S("Obsidian Stair")
  968. S("Inner Obsidian Stair")
  969. S("Outer Obsidian Stair")
  970. S("Obsidian Slab")
  971. S("Obsidian Brick Stair")
  972. S("Inner Obsidian Brick Stair")
  973. S("Outer Obsidian Brick Stair")
  974. S("Obsidian Brick Slab")
  975. S("Obsidian Block Stair")
  976. S("Inner Obsidian Block Stair")
  977. S("Outer Obsidian Block Stair")
  978. S("Obsidian Block Slab")
  979. S("Brick Stair")
  980. S("Inner Brick Stair")
  981. S("Outer Brick Stair")
  982. S("Brick Slab")
  983. S("Steel Block Stair")
  984. S("Inner Steel Block Stair")
  985. S("Outer Steel Block Stair")
  986. S("Steel Block Slab")
  987. S("Tin Block Stair")
  988. S("Inner Tin Block Stair")
  989. S("Outer Tin Block Stair")
  990. S("Tin Block Slab")
  991. S("Copper Block Stair")
  992. S("Inner Copper Block Stair")
  993. S("Outer Copper Block Stair")
  994. S("Copper Block Slab")
  995. S("Bronze Block Stair")
  996. S("Inner Bronze Block Stair")
  997. S("Outer Bronze Block Stair")
  998. S("Bronze Block Slab")
  999. S("Gold Block Stair")
  1000. S("Inner Gold Block Stair")
  1001. S("Outer Gold Block Stair")
  1002. S("Gold Block Slab")
  1003. S("Ice Stair")
  1004. S("Inner Ice Stair")
  1005. S("Outer Ice Stair")
  1006. S("Ice Slab")
  1007. S("Snow Block Stair")
  1008. S("Inner Snow Block Stair")
  1009. S("Outer Snow Block Stair")
  1010. S("Snow Block Slab")
  1011. --]]