init.lua 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. if not minetest.global_exists("scaffolding") then scaffolding = {} end
  2. scaffolding.modpath = minetest.get_modpath("scaffolding")
  3. dofile(minetest.get_modpath("scaffolding").."/sort.lua")
  4. if not scaffolding.run_once then
  5. dofile(minetest.get_modpath("scaffolding").."/functions.lua")
  6. minetest.register_craftitem("scaffolding:scaffolding_wrench", {
  7. description = "Scaffolding Reinforcement & Chest Sorting Wrench",
  8. inventory_image = "scaffolding_wrench.png",
  9. on_use = function(...)
  10. return scaffolding.wrench_on_use(...)
  11. end,
  12. })
  13. minetest.register_node("scaffolding:scaffolding", {
  14. description = "Wooden Scaffolding",
  15. drawtype = "nodebox",
  16. tiles = {"scaffolding_wooden_scaffolding_top.png", "scaffolding_wooden_scaffolding_top.png", "scaffolding_wooden_scaffolding.png",
  17. "scaffolding_wooden_scaffolding.png", "scaffolding_wooden_scaffolding.png", "scaffolding_wooden_scaffolding.png"},
  18. paramtype = "light",
  19. paramtype2 = "facedir",
  20. climbable = true,
  21. walkable = false,
  22. groups = utility.dig_groups("scaffolding", {scaffolding=1}),
  23. sounds = default.node_sound_wood_defaults(),
  24. on_punch = function(pos, node, puncher)
  25. local tool = puncher:get_wielded_item():get_name()
  26. if tool and tool == "scaffolding:scaffolding_wrench" then
  27. node.name = "scaffolding:reinforced_scaffolding"
  28. minetest.add_node(pos, node)
  29. --puncher:get_inventory():add_item("main", ItemStack("scaffolding:scaffolding"))
  30. end
  31. end,
  32. --[[on_rightclick = function(pos, node, player, itemstack, pointed_thing)
  33. if itemstack:get_name() == "scaffolding:scaffolding_wrench" then
  34. node.name = "scaffolding:reinforced_scaffolding"
  35. minetest.add_node(pos, node)
  36. end
  37. end,
  38. on_punch = function(pos, node, puncher)
  39. local tool = puncher:get_wielded_item():get_name()
  40. if tool and tool == "scaffolding:scaffolding_wrench" then
  41. node.name = "air"
  42. minetest.add_node(pos, node)
  43. puncher:get_inventory():add_item("main", ItemStack("scaffolding:scaffolding"))
  44. end
  45. end,]]
  46. node_box = {
  47. type = "fixed",
  48. fixed = {
  49. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  50. },
  51. },
  52. selection_box = {
  53. type = "fixed",
  54. fixed = {
  55. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  56. },
  57. },
  58. _no_collapse_on_walkover = true,
  59. after_dig_node = function(pos, node, metadata, digger)
  60. default.dig_up(pos, node, digger)
  61. end,
  62. })
  63. minetest.register_node("scaffolding:reinforced_scaffolding", {
  64. description = "Wooden Scaffolding",
  65. drawtype = "nodebox",
  66. tiles = {"scaffolding_wooden_scaffolding.png^scaffolding_reinforced.png", "scaffolding_wooden_scaffolding.png^scaffolding_reinforced.png",
  67. "scaffolding_wooden_scaffolding.png^scaffolding_reinforced.png"},
  68. drop = "scaffolding:scaffolding",
  69. paramtype = "light",
  70. paramtype2 = "facedir",
  71. climbable = true,
  72. walkable = false,
  73. groups = utility.dig_groups("scaffolding", {scaffolding=1}),
  74. sounds = default.node_sound_wood_defaults(),
  75. _no_collapse_on_walkover = true,
  76. on_punch = function(pos, node, puncher)
  77. local tool = puncher:get_wielded_item():get_name()
  78. if tool and tool == "scaffolding:scaffolding_wrench" then
  79. node.name = "scaffolding:scaffolding"
  80. minetest.add_node(pos, node)
  81. --puncher:get_inventory():add_item("main", ItemStack("scaffolding:scaffolding"))
  82. end
  83. end,
  84. --[[ on_rightclick = function(pos, node, puncher)
  85. local tool = puncher:get_wielded_item():get_name()
  86. if tool and tool == "scaffolding:scaffolding_wrench" then
  87. node.name = "scaffolding:scaffolding"
  88. minetest.add_node(pos, node)
  89. end
  90. end,
  91. on_punch = function(pos, node, puncher)
  92. local tool = puncher:get_wielded_item():get_name()
  93. if tool and tool == "scaffolding:scaffolding_wrench" then
  94. node.name = "air"
  95. minetest.add_node(pos, node)
  96. puncher:get_inventory():add_item("main", ItemStack("scaffolding:scaffolding"))
  97. end
  98. end,]]
  99. node_box = {
  100. type = "fixed",
  101. fixed = {
  102. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  103. },
  104. },
  105. selection_box = {
  106. type = "fixed",
  107. fixed = {
  108. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  109. },
  110. },
  111. })
  112. minetest.register_node("scaffolding:platform", {
  113. description = "Wooden Platform",
  114. drawtype = "nodebox",
  115. tiles = {"scaffolding_wooden_scaffolding_top.png", "scaffolding_wooden_scaffolding_top.png", "scaffolding_wooden_scaffolding.png^scaffolding_platform.png"},
  116. paramtype = "light",
  117. paramtype2 = "facedir",
  118. climbable = false,
  119. walkable = true,
  120. groups = utility.dig_groups("scaffolding", {scaffolding=1}),
  121. sounds = default.node_sound_wood_defaults(),
  122. _no_collapse_on_walkover = true,
  123. on_punch = function(pos, node, puncher)
  124. local tool = puncher:get_wielded_item():get_name()
  125. if tool and tool == "scaffolding:scaffolding_wrench" then
  126. node.name = "scaffolding:reinforced_platform"
  127. minetest.add_node(pos, node)
  128. end
  129. end,
  130. node_box = {
  131. type = "fixed",
  132. fixed = {
  133. {-0.5, -0.3, -0.5, 0.5, 0.1, 0.5},
  134. },
  135. },
  136. selection_box = {
  137. type = "fixed",
  138. fixed = {
  139. {-0.5, -0.3, -0.5, 0.5, 0.1, 0.5},
  140. },
  141. },
  142. after_dig_node = function(pos, node, metadata, digger)
  143. scaffolding.dig_horx(pos, node, digger)
  144. scaffolding.dig_horx2(pos, node, digger)
  145. scaffolding.dig_horz(pos, node, digger)
  146. scaffolding.dig_horz2(pos, node, digger)
  147. end,
  148. })
  149. minetest.register_node("scaffolding:reinforced_platform", {
  150. description = "Wooden Platform",
  151. drawtype = "nodebox",
  152. tiles = {"scaffolding_wooden_scaffolding.png^scaffolding_reinforced.png", "scaffolding_wooden_scaffolding.png^scaffolding_reinforced.png", "scaffolding_wooden_scaffolding.png^scaffolding_platform.png"},
  153. drop = "scaffolding:platform",
  154. paramtype = "light",
  155. paramtype2 = "facedir",
  156. climbable = false,
  157. walkable = true,
  158. groups = utility.dig_groups("scaffolding", {scaffolding=1}),
  159. sounds = default.node_sound_wood_defaults(),
  160. _no_collapse_on_walkover = true,
  161. on_punch = function(pos, node, puncher)
  162. local tool = puncher:get_wielded_item():get_name()
  163. if tool and tool == "scaffolding:scaffolding_wrench" then
  164. node.name = "scaffolding:platform"
  165. minetest.add_node(pos, node)
  166. end
  167. end,
  168. node_box = {
  169. type = "fixed",
  170. fixed = {
  171. {-0.5, -0.3, -0.5, 0.5, 0.1, 0.5},
  172. },
  173. },
  174. selection_box = {
  175. type = "fixed",
  176. fixed = {
  177. {-0.5, -0.3, -0.5, 0.5, 0.1, 0.5},
  178. },
  179. },
  180. })
  181. minetest.register_node("scaffolding:iron_scaffolding", {
  182. description = "Iron Scaffolding",
  183. drawtype = "nodebox",
  184. tiles = {"scaffolding_iron_scaffolding_top.png", "scaffolding_iron_scaffolding_top.png", "scaffolding_iron_scaffolding.png",
  185. "scaffolding_iron_scaffolding.png", "scaffolding_iron_scaffolding.png", "scaffolding_iron_scaffolding.png"},
  186. paramtype = "light",
  187. paramtype2 = "facedir",
  188. climbable = true,
  189. walkable = false,
  190. groups = utility.dig_groups("scaffolding", {scaffolding=1}),
  191. sounds = default.node_sound_stone_defaults(),
  192. _no_collapse_on_walkover = true,
  193. node_box = {
  194. type = "fixed",
  195. fixed = {
  196. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  197. },
  198. },
  199. selection_box = {
  200. type = "fixed",
  201. fixed = {
  202. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  203. },
  204. },
  205. on_punch = function(pos, node, puncher)
  206. local tool = puncher:get_wielded_item():get_name()
  207. if tool and tool == "scaffolding:scaffolding_wrench" then
  208. node.name = "scaffolding:reinforced_iron_scaffolding"
  209. minetest.add_node(pos, node)
  210. --puncher:get_inventory():add_item("main", ItemStack("scaffolding:scaffolding"))
  211. end
  212. end,
  213. --[[on_rightclick = function(pos, node, puncher)
  214. local tool = puncher:get_wielded_item():get_name()
  215. if tool and tool == "scaffolding:scaffolding_wrench" then
  216. node.name = "scaffolding:reinforced_iron_scaffolding"
  217. minetest.add_node(pos, node)
  218. end
  219. end,
  220. on_punch = function(pos, node, puncher)
  221. local tool = puncher:get_wielded_item():get_name()
  222. if tool and tool == "scaffolding:scaffolding_wrench" then
  223. node.name = "air"
  224. minetest.add_node(pos, node)
  225. --puncher:get_inventory():remove_item("main", ItemStack("beer_test:tankard"))
  226. puncher:get_inventory():add_item("main", ItemStack("scaffolding:scaffolding"))
  227. end
  228. end,]]
  229. after_dig_node = function(pos, node, metadata, digger)
  230. default.dig_up(pos, node, digger)
  231. end,
  232. })
  233. minetest.register_node("scaffolding:reinforced_iron_scaffolding", {
  234. description = "Iron Scaffolding",
  235. drawtype = "nodebox",
  236. tiles = {"scaffolding_iron_scaffolding.png^scaffolding_reinforced.png", "scaffolding_iron_scaffolding.png^scaffolding_reinforced.png",
  237. "scaffolding_iron_scaffolding.png^scaffolding_reinforced.png"},
  238. drop = "scaffolding:iron_scaffolding",
  239. paramtype = "light",
  240. paramtype2 = "facedir",
  241. climbable = true,
  242. walkable = false,
  243. _no_collapse_on_walkover = true,
  244. groups = utility.dig_groups("scaffolding", {scaffolding=1}),
  245. sounds = default.node_sound_stone_defaults(),
  246. on_punch = function(pos, node, puncher)
  247. local tool = puncher:get_wielded_item():get_name()
  248. if tool and tool == "scaffolding:scaffolding_wrench" then
  249. node.name = "scaffolding:iron_scaffolding"
  250. minetest.add_node(pos, node)
  251. --puncher:get_inventory():add_item("main", ItemStack("scaffolding:scaffolding"))
  252. end
  253. end,
  254. --[[on_rightclick = function(pos, node, puncher)
  255. local tool = puncher:get_wielded_item():get_name()
  256. if tool and tool == "scaffolding:scaffolding_wrench" then
  257. node.name = "scaffolding:iron_scaffolding"
  258. minetest.add_node(pos, node)
  259. end
  260. end,
  261. on_punch = function(pos, node, puncher)
  262. local tool = puncher:get_wielded_item():get_name()
  263. if tool and tool == "scaffolding:scaffolding_wrench" then
  264. node.name = "air"
  265. minetest.add_node(pos, node)
  266. --puncher:get_inventory():remove_item("main", ItemStack("beer_test:tankard"))
  267. puncher:get_inventory():add_item("main", ItemStack("scaffolding:scaffolding"))
  268. end
  269. end,]]
  270. node_box = {
  271. type = "fixed",
  272. fixed = {
  273. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  274. },
  275. },
  276. selection_box = {
  277. type = "fixed",
  278. fixed = {
  279. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  280. },
  281. },
  282. })
  283. minetest.register_node("scaffolding:iron_platform", {
  284. description = "Iron Platform",
  285. drawtype = "nodebox",
  286. tiles = {"scaffolding_iron_scaffolding_top.png", "scaffolding_iron_scaffolding_top.png", "scaffolding_iron_scaffolding.png^scaffolding_platform.png"},
  287. paramtype = "light",
  288. paramtype2 = "facedir",
  289. climbable = false,
  290. walkable = true,
  291. groups = utility.dig_groups("scaffolding", {scaffolding=1}),
  292. sounds = default.node_sound_stone_defaults(),
  293. _no_collapse_on_walkover = true,
  294. on_punch = function(pos, node, puncher)
  295. local tool = puncher:get_wielded_item():get_name()
  296. if tool and tool == "scaffolding:scaffolding_wrench" then
  297. node.name = "scaffolding:reinforced_iron_platform"
  298. minetest.add_node(pos, node)
  299. end
  300. end,
  301. node_box = {
  302. type = "fixed",
  303. fixed = {
  304. {-0.5, -0.3, -0.5, 0.5, 0.1, 0.5},
  305. },
  306. },
  307. selection_box = {
  308. type = "fixed",
  309. fixed = {
  310. {-0.5, -0.3, -0.5, 0.5, 0.1, 0.5},
  311. },
  312. },
  313. after_dig_node = function(pos, node, metadata, digger)
  314. scaffolding.dig_horx(pos, node, digger)
  315. scaffolding.dig_horx2(pos, node, digger)
  316. scaffolding.dig_horz(pos, node, digger)
  317. scaffolding.dig_horz2(pos, node, digger)
  318. end,
  319. })
  320. minetest.register_node("scaffolding:reinforced_iron_platform", {
  321. description = "Iron Platform",
  322. drawtype = "nodebox",
  323. tiles = {"scaffolding_iron_scaffolding.png^scaffolding_reinforced.png", "scaffolding_iron_scaffolding.png^scaffolding_reinforced.png", "scaffolding_iron_scaffolding.png^scaffolding_platform.png"},
  324. drop = "scaffolding:iron_platform",
  325. paramtype = "light",
  326. paramtype2 = "facedir",
  327. climbable = false,
  328. walkable = true,
  329. groups = utility.dig_groups("scaffolding", {scaffolding=1}),
  330. sounds = default.node_sound_stone_defaults(),
  331. _no_collapse_on_walkover = true,
  332. on_punch = function(pos, node, puncher)
  333. local tool = puncher:get_wielded_item():get_name()
  334. if tool and tool == "scaffolding:scaffolding_wrench" then
  335. node.name = "scaffolding:iron_platform"
  336. minetest.add_node(pos, node)
  337. end
  338. end,
  339. node_box = {
  340. type = "fixed",
  341. fixed = {
  342. {-0.5, -0.3, -0.5, 0.5, 0.1, 0.5},
  343. },
  344. },
  345. selection_box = {
  346. type = "fixed",
  347. fixed = {
  348. {-0.5, -0.3, -0.5, 0.5, 0.1, 0.5},
  349. },
  350. },
  351. })
  352. ----------------------
  353. -- wood scaffolding --
  354. ----------------------
  355. minetest.register_craft({
  356. output = 'scaffolding:scaffolding 12',
  357. recipe = {
  358. {'group:wood', 'group:wood', 'group:wood'},
  359. {'group:stick', '', 'group:stick'},
  360. {'group:wood', 'group:wood', 'group:wood'},
  361. }
  362. })
  363. minetest.register_craft({
  364. output = 'scaffolding:scaffolding 4',
  365. recipe = {
  366. {'group:wood'},
  367. {'group:stick'},
  368. {'group:wood'},
  369. }
  370. })
  371. -- back to scaffolding --
  372. minetest.register_craft({
  373. output = 'scaffolding:scaffolding',
  374. recipe = {
  375. {'scaffolding:platform'},
  376. {'scaffolding:platform'},
  377. }
  378. })
  379. -- wood platforms --
  380. minetest.register_craft({
  381. output = 'scaffolding:platform 2',
  382. recipe = {
  383. {'scaffolding:scaffolding'},
  384. }
  385. })
  386. minetest.register_craft({
  387. output = 'scaffolding:platform 6',
  388. recipe = {
  389. {'scaffolding:scaffolding', 'scaffolding:scaffolding', 'scaffolding:scaffolding'},
  390. }
  391. })
  392. ----------------------
  393. -- iron scaffolding --
  394. ----------------------
  395. minetest.register_craft({
  396. output = 'scaffolding:iron_scaffolding 12',
  397. recipe = {
  398. {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
  399. {'group:stick', '', 'group:stick'},
  400. {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
  401. }
  402. })
  403. minetest.register_craft({
  404. output = 'scaffolding:iron_scaffolding 4',
  405. recipe = {
  406. {'default:steel_ingot'},
  407. {'group:stick'},
  408. {'default:steel_ingot'},
  409. }
  410. })
  411. -- back to scaffolding --
  412. minetest.register_craft({
  413. output = 'scaffolding:iron_scaffolding',
  414. recipe = {
  415. {'scaffolding:iron_platform'},
  416. {'scaffolding:iron_platform'},
  417. }
  418. })
  419. -- iron platforms --
  420. minetest.register_craft({
  421. output = 'scaffolding:iron_platform 2',
  422. recipe = {
  423. {'scaffolding:iron_scaffolding'},
  424. }
  425. })
  426. minetest.register_craft({
  427. output = 'scaffolding:iron_platform 6',
  428. recipe = {
  429. {'scaffolding:iron_scaffolding', 'scaffolding:iron_scaffolding', 'scaffolding:iron_scaffolding'},
  430. }
  431. })
  432. ------------
  433. -- wrench --
  434. ------------
  435. minetest.register_craft({
  436. output = 'scaffolding:scaffolding_wrench',
  437. recipe = {
  438. {'', 'default:steel_ingot', ''},
  439. {'', 'default:steel_ingot', 'default:steel_ingot'},
  440. {'default:steel_ingot', '', ''},
  441. }
  442. })
  443. local c = "scaffolding:core"
  444. local f = scaffolding.modpath .. "/init.lua"
  445. reload.register_file(c, f, false)
  446. scaffolding.run_once = true
  447. end