nodes.lua 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  1. local S = gold_and_gem.gettext
  2. local border_block_materials = {
  3. { "golden", " with golden border"},
  4. { "mithril", " with Mithril-border" }
  5. }
  6. minetest.register_node("gold_and_gem:golden_mithril_block", {
  7. description = "Mithril Block with golden border",
  8. tiles = {"goldgem_golden_mithril_block.png"},
  9. is_ground_content = false,
  10. groups = {bendy=3,cracky=2,level=1},
  11. sounds = default.node_sound_stone_defaults(),
  12. })
  13. minetest.register_node("gold_and_gem:mithril_goldblock", {
  14. description = "Gold Block with Mithril-border",
  15. tiles = {"goldgem_mithril_gold_block.png"},
  16. is_ground_content = false,
  17. groups = {bendy=3,cracky=2,level=1},
  18. sounds = default.node_sound_stone_defaults(),
  19. })
  20. for i in ipairs(border_block_materials) do
  21. local border = border_block_materials[i][1]
  22. local name = border_block_materials[i][2]
  23. minetest.register_node("gold_and_gem:"..border.."_diamondblock", {
  24. description = "Diamond Block"..name,
  25. tiles = {"goldgem_"..border.."_diamond_block.png"},
  26. is_ground_content = false,
  27. groups = {cracky=1,level=3},
  28. sounds = default.node_sound_stone_defaults(),
  29. })
  30. minetest.register_node("gold_and_gem:"..border.."_glass", {
  31. description = "Glass"..name,
  32. drawtype = "glasslike",
  33. tiles = {"goldgem_"..border.."_glass.png"},
  34. paramtype = "light",
  35. inventory_image = minetest.inventorycube("goldgem_"..border.."_glass.png"),
  36. sunlight_propagates = true,
  37. is_ground_content = false,
  38. groups = {cracky=3,oddly_breakable_by_hand=3},
  39. sounds = default.node_sound_glass_defaults(),
  40. })
  41. minetest.register_node("gold_and_gem:"..border.."_silver_block", {
  42. description = "Silver Block"..name,
  43. tiles = {"goldgem_"..border.."_silver_block.png"},
  44. is_ground_content = false,
  45. groups = {bendy=3,cracky=2,level=1},
  46. sounds = default.node_sound_stone_defaults(),
  47. })
  48. minetest.register_node("gold_and_gem:"..border.."_amethystblock", {
  49. description = "Amethyst Block"..name,
  50. tiles = {"goldgem_"..border.."_amethyst_block.png"},
  51. is_ground_content = false,
  52. groups = {bendy=3,cracky=2,level=1},
  53. sounds = default.node_sound_stone_defaults(),
  54. })
  55. minetest.register_node("gold_and_gem:"..border.."_emeraldblock", {
  56. description = "Emerald Block"..name,
  57. tiles = {"goldgem_"..border.."_emerald_block.png"},
  58. is_ground_content = false,
  59. groups = {bendy=3,cracky=2,level=1},
  60. sounds = default.node_sound_stone_defaults(),
  61. })
  62. minetest.register_node("gold_and_gem:"..border.."_rubyblock", {
  63. description = "Ruby Block"..name,
  64. tiles = {"goldgem_"..border.."_ruby_block.png"},
  65. is_ground_content = false,
  66. groups = {bendy=3,cracky=2,level=1},
  67. sounds = default.node_sound_stone_defaults(),
  68. })
  69. minetest.register_node("gold_and_gem:"..border.."_sapphireblock", {
  70. description = "Sapphire Block"..name,
  71. tiles = {"goldgem_"..border.."_sapphire_block.png"},
  72. is_ground_content = false,
  73. groups = {bendy=3,cracky=2,level=1},
  74. sounds = default.node_sound_stone_defaults(),
  75. })
  76. minetest.register_node("gold_and_gem:"..border.."_topazblock", {
  77. description = "Topaz Block"..name,
  78. tiles = {"goldgem_"..border.."_topaz_block.png"},
  79. is_ground_content = false,
  80. groups = {bendy=3,cracky=2,level=1},
  81. sounds = default.node_sound_stone_defaults(),
  82. })
  83. minetest.register_node("gold_and_gem:"..border.."_crystal_glass", {
  84. description = "Crystal Glass"..name,
  85. drawtype = "glasslike",
  86. inventory_image = minetest.inventorycube("goldgem_"..border.."_crystal_glass.png"),
  87. tiles = {"goldgem_"..border.."_crystal_glass.png"},
  88. paramtype = "light",
  89. sunlight_propagates = true,
  90. is_ground_content = false,
  91. groups = {cracky=3},
  92. sounds = default.node_sound_glass_defaults(),
  93. })
  94. minetest.register_node("gold_and_gem:"..border.."_taliniteblock", {
  95. description = "Talinite Block"..name,
  96. tiles = {"goldgem_"..border.."_talinite_block.png"},
  97. is_ground_content = false,
  98. light_source = 14,
  99. groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2},
  100. sounds = default.node_sound_stone_defaults(),
  101. })
  102. end
  103. local table_borders = {
  104. {"gold_glass","Gold"},
  105. {"mithril_glass","Mithril"},
  106. {"ruby_glass","Ruby"},
  107. {"emerald_glass","Emerald"}
  108. }
  109. for i in ipairs(table_borders) do
  110. local material = table_borders[i][1]
  111. local border = table_borders[i][2]
  112. -- small square tables
  113. minetest.register_node("gold_and_gem:"..material.."_table_small_square_b", {
  114. description = S("Glass Table (Small, Square) with "..border.." Border"),
  115. drawtype = "nodebox",
  116. tiles = {
  117. "goldgem_"..material.."_table_small_square_tb.png",
  118. "goldgem_"..material.."_table_small_square_tb.png",
  119. "goldgem_"..material.."_table_small_square_edges.png",
  120. "goldgem_"..material.."_table_small_square_edges.png",
  121. "goldgem_"..material.."_table_small_square_edges.png",
  122. "goldgem_"..material.."_table_small_square_edges.png"
  123. },
  124. wield_image = "goldgem_"..material.."_table_small_square_tb.png",
  125. inventory_image = "goldgem_"..material.."_table_small_square_tb.png",
  126. sunlight_propagates = true,
  127. paramtype = "light",
  128. walkable = true,
  129. groups = { snappy = 3 },
  130. sounds = default.node_sound_glass_defaults(),
  131. paramtype2 = "facedir",
  132. node_box = {
  133. type = "fixed",
  134. fixed = {
  135. { -0.4375, -0.5, -0.5, 0.4375, -0.4375, 0.5 },
  136. { -0.5, -0.5, -0.4375, 0.5, -0.4375, 0.4375 }
  137. },
  138. },
  139. selection_box = {
  140. type = "fixed",
  141. fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 },
  142. },
  143. on_place = minetest.rotate_node
  144. })
  145. minetest.register_node("gold_and_gem:"..material.."_table_small_square_t", {
  146. description = S("Glass Table (Small, Square) with "..border.." Border"),
  147. drawtype = "nodebox",
  148. tiles = {
  149. "goldgem_"..material.."_table_small_square_tb.png",
  150. "goldgem_"..material.."_table_small_square_tb.png",
  151. "goldgem_"..material.."_table_small_square_edges.png",
  152. "goldgem_"..material.."_table_small_square_edges.png",
  153. "goldgem_"..material.."_table_small_square_edges.png",
  154. "goldgem_"..material.."_table_small_square_edges.png"
  155. },
  156. sunlight_propagates = true,
  157. paramtype = "light",
  158. walkable = true,
  159. groups = { snappy = 3, not_in_creative_inventory=1 },
  160. sounds = default.node_sound_glass_defaults(),
  161. paramtype2 = "facedir",
  162. node_box = {
  163. type = "fixed",
  164. fixed = {
  165. { -0.4375, 0.4375, -0.5, 0.4375, 0.5, 0.5 },
  166. { -0.5, 0.4375, -0.4375, 0.5, 0.5, 0.4375 }
  167. },
  168. },
  169. selection_box = {
  170. type = "fixed",
  171. fixed = { -0.5, 0.4375, -0.5, 0.5, 0.5, 0.5 },
  172. },
  173. drop = "gold_and_gem:"..material.."_table_small_square_b"
  174. })
  175. minetest.register_node("gold_and_gem:"..material.."_table_small_square_s", {
  176. description = S("Glass Table (Small, Square) with "..border.." Border"),
  177. drawtype = "nodebox",
  178. tiles = {
  179. "goldgem_"..material.."_table_small_square_edges.png",
  180. "goldgem_"..material.."_table_small_square_edges.png",
  181. "goldgem_"..material.."_table_small_square_edges.png",
  182. "goldgem_"..material.."_table_small_square_edges.png",
  183. "goldgem_"..material.."_table_small_square_tb.png",
  184. "goldgem_"..material.."_table_small_square_tb.png"
  185. },
  186. sunlight_propagates = true,
  187. paramtype = "light",
  188. walkable = true,
  189. groups = { snappy = 3, not_in_creative_inventory=1 },
  190. sounds = default.node_sound_glass_defaults(),
  191. paramtype2 = "facedir",
  192. node_box = {
  193. type = "fixed",
  194. fixed = {
  195. { -0.4375, -0.5, 0.4375, 0.4375, 0.5, 0.5 },
  196. { -0.5, -0.4375, 0.4375, 0.5, 0.4375, 0.5 }
  197. }
  198. },
  199. selection_box = {
  200. type = "fixed",
  201. fixed = { -0.5, -0.5, 0.4375, 0.5, 0.5, 0.5 },
  202. },
  203. drop = "gold_and_gem:"..material.."_table_small_square_b"
  204. })
  205. -- small round tables
  206. minetest.register_node("gold_and_gem:"..material.."_table_small_round_b", {
  207. description = S("Glass Table (Small, Round) with "..border.." Border"),
  208. drawtype = "nodebox",
  209. tiles = {
  210. "goldgem_"..material.."_table_small_round_tb.png",
  211. "goldgem_"..material.."_table_small_round_tb.png",
  212. "goldgem_"..material.."_table_small_round_edges.png",
  213. "goldgem_"..material.."_table_small_round_edges.png",
  214. "goldgem_"..material.."_table_small_round_edges.png",
  215. "goldgem_"..material.."_table_small_round_edges.png"
  216. },
  217. wield_image = "goldgem_"..material.."_table_small_round_tb.png",
  218. inventory_image = "goldgem_"..material.."_table_small_round_tb.png",
  219. sunlight_propagates = true,
  220. paramtype = "light",
  221. walkable = true,
  222. groups = { snappy = 3 },
  223. sounds = default.node_sound_glass_defaults(),
  224. paramtype2 = "facedir",
  225. node_box = {
  226. type = "fixed",
  227. fixed = {
  228. { -0.25, -0.5, -0.5, 0.25, -0.4375, 0.5 },
  229. { -0.375, -0.5, -0.4375, 0.375, -0.4375, 0.4375 },
  230. { -0.5, -0.5, -0.25, 0.5, -0.4375, 0.25 },
  231. { -0.4375, -0.5, -0.375, 0.4375, -0.4375, 0.375 },
  232. { -0.25, -0.5, -0.5, 0.25, -0.4375, 0.5 },
  233. }
  234. },
  235. selection_box = {
  236. type = "fixed",
  237. fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 },
  238. },
  239. on_place = minetest.rotate_node
  240. })
  241. minetest.register_node("gold_and_gem:"..material.."_table_small_round_t", {
  242. description = S("Glass Table (Small, Round) with "..border.." Border"),
  243. drawtype = "nodebox",
  244. tiles = {
  245. "goldgem_"..material.."_table_small_round_tb.png",
  246. "goldgem_"..material.."_table_small_round_tb.png",
  247. "goldgem_"..material.."_table_small_round_edges.png",
  248. "goldgem_"..material.."_table_small_round_edges.png",
  249. "goldgem_"..material.."_table_small_round_edges.png",
  250. "goldgem_"..material.."_table_small_round_edges.png"
  251. },
  252. sunlight_propagates = true,
  253. paramtype = "light",
  254. walkable = true,
  255. groups = { snappy = 3, not_in_creative_inventory=1 },
  256. sounds = default.node_sound_glass_defaults(),
  257. paramtype2 = "facedir",
  258. node_box = {
  259. type = "fixed",
  260. fixed = {
  261. { -0.25, 0.4375, -0.5, 0.25, 0.5, 0.5 },
  262. { -0.375, 0.4375, -0.4375, 0.375, 0.5, 0.4375 },
  263. { -0.5, 0.4375, -0.25, 0.5, 0.5, 0.25 },
  264. { -0.4375, 0.4375, -0.375, 0.4375, 0.5, 0.375 },
  265. { -0.25, 0.4375, -0.5, 0.25, 0.5, 0.5 },
  266. }
  267. },
  268. selection_box = {
  269. type = "fixed",
  270. fixed = { -0.5, 0.4375, -0.5, 0.5, 0.5, 0.5 },
  271. },
  272. drop = "gold_and_gem:"..material.."_table_small_round_b"
  273. })
  274. minetest.register_node("gold_and_gem:"..material.."_table_small_round_s", {
  275. description = S("Glass Table (Small, Round) with "..border.." Border"),
  276. drawtype = "nodebox",
  277. tiles = {
  278. "goldgem_"..material.."_table_small_round_edges.png",
  279. "goldgem_"..material.."_table_small_round_edges.png",
  280. "goldgem_"..material.."_table_small_round_edges.png",
  281. "goldgem_"..material.."_table_small_round_edges.png",
  282. "goldgem_"..material.."_table_small_round_tb.png",
  283. "goldgem_"..material.."_table_small_round_tb.png"
  284. },
  285. sunlight_propagates = true,
  286. paramtype = "light",
  287. walkable = true,
  288. groups = { snappy = 3, not_in_creative_inventory=1 },
  289. sounds = default.node_sound_glass_defaults(),
  290. paramtype2 = "facedir",
  291. node_box = {
  292. type = "fixed",
  293. fixed = {
  294. { -0.25, -0.5, 0.4375, 0.25, 0.5, 0.5 },
  295. { -0.375, -0.4375, 0.4375, 0.375, 0.4375, 0.5 },
  296. { -0.5, -0.25, 0.4375, 0.5, 0.25, 0.5 },
  297. { -0.4375, -0.375, 0.4375, 0.4375, 0.375, 0.5 },
  298. { -0.25, -0.5, 0.4375, 0.25, 0.5, 0.5 },
  299. }
  300. },
  301. selection_box = {
  302. type = "fixed",
  303. fixed = { -0.5, -0.5, 0.4375, 0.5, 0.5, 0.5 },
  304. },
  305. drop = "gold_and_gem:"..material.."_table_small_round_b"
  306. })
  307. -- Large square table pieces
  308. minetest.register_node("gold_and_gem:"..material.."_table_large_b", {
  309. description = S("Glass Table (Large) with "..border.." Border"),
  310. drawtype = "nodebox",
  311. tiles = {
  312. "goldgem_"..material.."_table_large_tb.png",
  313. "goldgem_"..material.."_table_large_tb.png",
  314. "goldgem_"..material.."_table_large_edges.png",
  315. "goldgem_"..material.."_table_large_edges.png",
  316. "goldgem_"..material.."_table_large_edges.png",
  317. "goldgem_"..material.."_table_large_edges.png"
  318. },
  319. wield_image = "goldgem_"..material.."_table_large_tb.png",
  320. inventory_image = "goldgem_"..material.."_table_large_tb.png",
  321. sunlight_propagates = true,
  322. paramtype = "light",
  323. walkable = true,
  324. groups = { snappy = 3 },
  325. sounds = s,
  326. paramtype2 = "facedir",
  327. node_box = {
  328. type = "fixed",
  329. fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 },
  330. },
  331. selection_box = {
  332. type = "fixed",
  333. fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 },
  334. },
  335. on_place = minetest.rotate_node
  336. })
  337. minetest.register_node("gold_and_gem:"..material.."_table_large_t", {
  338. description = S("Glass Table (Large) with "..border.." Border"),
  339. drawtype = "nodebox",
  340. tiles = {
  341. "goldgem_"..material.."_table_large_tb.png",
  342. "goldgem_"..material.."_table_large_tb.png",
  343. "goldgem_"..material.."_table_large_edges.png",
  344. "goldgem_"..material.."_table_large_edges.png",
  345. "goldgem_"..material.."_table_large_edges.png",
  346. "goldgem_"..material.."_table_large_edges.png"
  347. },
  348. wield_image ="goldgem_"..material.."_table_large_tb.png",
  349. inventory_image = "goldgem_"..material.."_table_large_tb.png",
  350. sunlight_propagates = true,
  351. paramtype = "light",
  352. walkable = true,
  353. groups = { snappy = 3, not_in_creative_inventory=1 },
  354. sounds = s,
  355. paramtype2 = "facedir",
  356. node_box = {
  357. type = "fixed",
  358. fixed = { -0.5, 0.4375, -0.5, 0.5, 0.5, 0.5 },
  359. },
  360. selection_box = {
  361. type = "fixed",
  362. fixed = { -0.5, 0.4375, -0.5, 0.5, 0.5, 0.5 },
  363. },
  364. drop = "goldgem_"..material.."_table_large_b"
  365. })
  366. minetest.register_node("gold_and_gem:"..material.."_table_large_s", {
  367. description = S("Glass Table (Large) with "..border.." Border"),
  368. drawtype = "nodebox",
  369. tiles = {
  370. "goldgem_"..material.."_table_large_edges.png",
  371. "goldgem_"..material.."_table_large_edges.png",
  372. "goldgem_"..material.."_table_large_edges.png",
  373. "goldgem_"..material.."_table_large_edges.png",
  374. "goldgem_"..material.."_table_large_tb.png",
  375. "goldgem_"..material.."_table_large_tb.png"
  376. },
  377. wield_image = "goldgem_"..material.."_table_large_tb.png",
  378. inventory_image = "goldgem_"..material.."_table_large_tb.png",
  379. sunlight_propagates = true,
  380. paramtype = "light",
  381. walkable = true,
  382. groups = { snappy = 3, not_in_creative_inventory=1 },
  383. sounds = s,
  384. paramtype2 = "facedir",
  385. node_box = {
  386. type = "fixed",
  387. fixed = { -0.5, -0.5, 0.4375, 0.5, 0.5, 0.5 },
  388. },
  389. selection_box = {
  390. type = "fixed",
  391. fixed = { -0.5, -0.5, 0.4375, 0.5, 0.5, 0.5 },
  392. },
  393. drop ="goldgem_"..material.."_table_large_b"
  394. })
  395. minetest.register_alias("gold_and_gem_"..material.."_table_large","gold_and_gem_"..material.."_table_large_b")
  396. minetest.register_alias("gold_and_gem_"..material.."_table_small_square","gold_and_gem_"..material.."_table_small_square_b")
  397. minetest.register_alias("gold_and_gem_"..material.."_table_small_round", "gold_and_gem_"..material.."_table_small_round_b")
  398. end
  399. local function placeRubyLamp(itemstack, placer, pointed_thing)
  400. if pointed_thing.type ~= "node" then
  401. return itemstack
  402. end
  403. local p0 = pointed_thing.under
  404. local p1 = pointed_thing.above
  405. local param2 = 0
  406. local dir = {
  407. x = p1.x - p0.x,
  408. y = p1.y - p0.y,
  409. z = p1.z - p0.z
  410. }
  411. param2 = minetest.dir_to_facedir(dir,false)
  412. local correct_rotation={
  413. [0]=0,
  414. [1]=1,
  415. [2]=2,
  416. [3]=3
  417. }
  418. if p0.y == p1.y then
  419. --place torch on wall
  420. minetest.add_node(p1, {name="gold_and_gem:ruby_lamp_wall",param2=correct_rotation[param2]})
  421. else
  422. --place torch on floor
  423. minetest.add_node(p1, {name="gold_and_gem:ruby_lamp"})
  424. --return minetest.item_place(itemstack, placer, pointed_thing, param2)
  425. end
  426. itemstack:take_item()
  427. return itemstack
  428. end
  429. local function placeEmeraldLamp(itemstack, placer, pointed_thing)
  430. if pointed_thing.type ~= "node" then
  431. return itemstack
  432. end
  433. local p0 = pointed_thing.under
  434. local p1 = pointed_thing.above
  435. local param2 = 0
  436. local dir = {
  437. x = p1.x - p0.x,
  438. y = p1.y - p0.y,
  439. z = p1.z - p0.z
  440. }
  441. param2 = minetest.dir_to_facedir(dir,false)
  442. local correct_rotation={
  443. [0]=0,
  444. [1]=1,
  445. [2]=2,
  446. [3]=3
  447. }
  448. if p0.y == p1.y then
  449. --place torch on wall
  450. minetest.add_node(p1, {name="gold_and_gem:emerald_lamp_wall",param2=correct_rotation[param2]})
  451. else
  452. --place torch on floor
  453. minetest.add_node(p1, {name="gold_and_gem:emerald_lamp"})
  454. --return minetest.item_place(itemstack, placer, pointed_thing, param2)
  455. end
  456. itemstack:take_item()
  457. return itemstack
  458. end
  459. local function placeTopazLamp(itemstack, placer, pointed_thing)
  460. if pointed_thing.type ~= "node" then
  461. return itemstack
  462. end
  463. local p0 = pointed_thing.under
  464. local p1 = pointed_thing.above
  465. local param2 = 0
  466. local dir = {
  467. x = p1.x - p0.x,
  468. y = p1.y - p0.y,
  469. z = p1.z - p0.z
  470. }
  471. param2 = minetest.dir_to_facedir(dir,false)
  472. local correct_rotation={
  473. [0]=0,
  474. [1]=1,
  475. [2]=2,
  476. [3]=3
  477. }
  478. if p0.y == p1.y then
  479. --place torch on wall
  480. minetest.add_node(p1, {name="gold_and_gem:topaz_lamp_wall",param2=correct_rotation[param2]})
  481. else
  482. --place torch on floor
  483. minetest.add_node(p1, {name="gold_and_gem:topaz_lamp"})
  484. --return minetest.item_place(itemstack, placer, pointed_thing, param2)
  485. end
  486. itemstack:take_item()
  487. return itemstack
  488. end
  489. local function placeSapphireLamp(itemstack, placer, pointed_thing)
  490. if pointed_thing.type ~= "node" then
  491. return itemstack
  492. end
  493. local p0 = pointed_thing.under
  494. local p1 = pointed_thing.above
  495. local param2 = 0
  496. local dir = {
  497. x = p1.x - p0.x,
  498. y = p1.y - p0.y,
  499. z = p1.z - p0.z
  500. }
  501. param2 = minetest.dir_to_facedir(dir,false)
  502. local correct_rotation={
  503. [0]=0,
  504. [1]=1,
  505. [2]=2,
  506. [3]=3
  507. }
  508. if p0.y == p1.y then
  509. --place torch on wall
  510. minetest.add_node(p1, {name="gold_and_gem:sapphire_lamp_wall",param2=correct_rotation[param2]})
  511. else
  512. --place torch on floor
  513. minetest.add_node(p1, {name="gold_and_gem:sapphire_lamp"})
  514. --return minetest.item_place(itemstack, placer, pointed_thing, param2)
  515. end
  516. itemstack:take_item()
  517. return itemstack
  518. end
  519. local function placeAmethystLamp(itemstack, placer, pointed_thing)
  520. if pointed_thing.type ~= "node" then
  521. return itemstack
  522. end
  523. local p0 = pointed_thing.under
  524. local p1 = pointed_thing.above
  525. local param2 = 0
  526. local dir = {
  527. x = p1.x - p0.x,
  528. y = p1.y - p0.y,
  529. z = p1.z - p0.z
  530. }
  531. param2 = minetest.dir_to_facedir(dir,false)
  532. local correct_rotation={
  533. [0]=0,
  534. [1]=1,
  535. [2]=2,
  536. [3]=3
  537. }
  538. if p0.y == p1.y then
  539. --place torch on wall
  540. minetest.add_node(p1, {name="gold_and_gem:amethyst_lamp_wall",param2=correct_rotation[param2]})
  541. else
  542. --place torch on floor
  543. minetest.add_node(p1, {name="gold_and_gem:amethyst_lamp"})
  544. --return minetest.item_place(itemstack, placer, pointed_thing, param2)
  545. end
  546. itemstack:take_item()
  547. return itemstack
  548. end
  549. local gemlamps = {
  550. {"ruby_lamp","Ruby Lamp",placeRubyLamp},
  551. {"amethyst_lamp","Amethyst Lamp", placeAmethystLamp},
  552. {"emerald_lamp","Emerald Lamp", placeEmeraldLamp},
  553. {"sapphire_lamp","Sapphire Lamp", placeSapphireLamp},
  554. {"topaz_lamp","Topaz Lamp", placeTopazLamp}
  555. }
  556. for i in ipairs(gemlamps) do
  557. local lamp = gemlamps[i][1]
  558. local lamp_name = gemlamps[i][2]
  559. local l_func = gemlamps[i][3]
  560. minetest.register_node("gold_and_gem:"..lamp, {
  561. description = lamp_name,
  562. drawtype = "nodebox",
  563. node_box = {
  564. type = "fixed",
  565. fixed = {
  566. {-0.125, -0.5, -0.25, 0.125, -0.4375, 0.25}, -- NodeBox1
  567. {-0.25, -0.5, -0.125, 0.25, -0.4375, 0.125}, -- NodeBox2
  568. {-0.1875, -0.5, -0.1875, 0.1875, -0.4375, 0.1875}, -- NodeBox3
  569. {-0.125, -0.4375, -0.1875, 0.125, -0.375, 0.1875}, -- NodeBox4
  570. {-0.1875, -0.4375, -0.125, 0.1875, -0.375, 0.125}, -- NodeBox5
  571. {-0.0625, -0.375, -0.0625, 0.0625, -0.0625, 0.0625}, -- NodeBox6
  572. {-0.125, -0.0625, -0.125, 0.125, 0.0625, 0.125}, -- NodeBox7
  573. {-0.25, 0.0625, -0.25, 0.25, 0.25, 0.25}, -- NodeBox8
  574. {-0.125, 0.0625, -0.3125, 0.125, 0.25, 0.3125}, -- NodeBox9
  575. {-0.3125, 0.0625, -0.125, 0.3125, 0.25, 0.125}, -- NodeBox10
  576. {-0.125, 0.25, 0.25, 0.125, 0.5, 0.375}, -- NodeBox11
  577. {-0.375, 0.25, -0.125, -0.25, 0.5, 0.125}, -- NodeBox12
  578. {-0.125, 0.25, -0.375, 0.125, 0.5, -0.25}, -- NodeBox13
  579. {0.25, 0.25, -0.125, 0.375, 0.5, 0.125}, -- NodeBox14
  580. {0.125, 0.25, -0.3125, 0.25, 0.5, -0.1875}, -- NodeBox15
  581. {0.1875, 0.25, -0.25, 0.3125, 0.5, -0.125}, -- NodeBox16
  582. {-0.25, 0.25, -0.3125, -0.125, 0.5, -0.1875}, -- NodeBox17
  583. {-0.3125, 0.25, -0.25, -0.1875, 0.5, -0.125}, -- NodeBox18
  584. {-0.3125, 0.25, 0.125, -0.1875, 0.5, 0.25}, -- NodeBox19
  585. {-0.25, 0.25, 0.1875, -0.125, 0.5, 0.3125}, -- NodeBox20
  586. {0.1875, 0.25, 0.125, 0.3125, 0.5, 0.25}, -- NodeBox21
  587. {0.125, 0.25, 0.1875, 0.25, 0.5, 0.3125}, -- NodeBox22
  588. }
  589. },
  590. selection_box = {
  591. type = "fixed",
  592. fixed = { -0.4, -0.5, -0.4, 0.4, 0.5, 0.4 },
  593. },
  594. tiles = {
  595. {name="goldgem_"..lamp.."_top_anim.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}},
  596. {name="goldgem_"..lamp.."_bottom_anim.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}},
  597. {name="goldgem_"..lamp.."_side_anim.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}}
  598. },
  599. paramtype = "light",
  600. on_place = l_func,
  601. sunlight_propagates = true,
  602. is_ground_content = false,
  603. light_source = 12,
  604. groups = {choppy=2,dig_immediate=3},
  605. --legacy_wallmounted = true,
  606. sounds = default.node_sound_defaults(),
  607. })
  608. minetest.register_node("gold_and_gem:"..lamp.."_wall", {
  609. description = lamp_name.." Wall",
  610. drawtype = "nodebox",
  611. node_box = {
  612. type = "fixed",
  613. fixed = {
  614. {-0.0625, -0.1875, -0.0625, 0.0625, -0.0625, 0.0625}, -- NodeBox6
  615. {-0.125, -0.0625, -0.125, 0.125, 0.0625, 0.125}, -- NodeBox7
  616. {-0.25, 0.0625, -0.25, 0.25, 0.25, 0.25}, -- NodeBox8
  617. {-0.125, 0.0625, -0.3125, 0.125, 0.25, 0.3125}, -- NodeBox9
  618. {-0.3125, 0.0625, -0.125, 0.3125, 0.25, 0.125}, -- NodeBox10
  619. {-0.125, 0.25, 0.25, 0.125, 0.5, 0.375}, -- NodeBox11
  620. {-0.375, 0.25, -0.125, -0.25, 0.5, 0.125}, -- NodeBox12
  621. {-0.125, 0.25, -0.375, 0.125, 0.5, -0.25}, -- NodeBox13
  622. {0.25, 0.25, -0.125, 0.375, 0.5, 0.125}, -- NodeBox14
  623. {0.125, 0.25, -0.3125, 0.25, 0.5, -0.1875}, -- NodeBox15
  624. {0.1875, 0.25, -0.25, 0.3125, 0.5, -0.125}, -- NodeBox16
  625. {-0.25, 0.25, -0.3125, -0.125, 0.5, -0.1875}, -- NodeBox17
  626. {-0.3125, 0.25, -0.25, -0.1875, 0.5, -0.125}, -- NodeBox18
  627. {-0.3125, 0.25, 0.125, -0.1875, 0.5, 0.25}, -- NodeBox19
  628. {-0.25, 0.25, 0.1875, -0.125, 0.5, 0.3125}, -- NodeBox20
  629. {0.1875, 0.25, 0.125, 0.3125, 0.5, 0.25}, -- NodeBox21
  630. {0.125, 0.25, 0.1875, 0.25, 0.5, 0.3125}, -- NodeBox22
  631. {-0.0625, -0.25, -0.125, 0.0625, -0.125, 0}, -- NodeBox24
  632. {-0.0625, -0.3125, -0.25, 0.0625, -0.1875, -0.0625}, -- NodeBox25
  633. {-0.0625, -0.375, -0.375, 0.0625, -0.25, -0.1875}, -- NodeBox26
  634. {-0.125, -0.4375, -0.5, 0.125, -0.1875, -0.375}, -- NodeBox27
  635. {-0.125, -0.5, -0.5, 0.125, -0.125, -0.4375}, -- NodeBox28
  636. {-0.1875, -0.4375, -0.5, 0.1875, -0.1875, -0.4375}, -- NodeBox29
  637. }
  638. },
  639. selection_box = {
  640. type = "fixed",
  641. fixed = { -0.4, -0.5, -0.4, 0.4, 0.5, 0.4 },
  642. },
  643. tiles = {
  644. {name="goldgem_"..lamp.."_top_anim.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}},
  645. {name="goldgem_"..lamp.."_wall_bottom_anim.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}},
  646. {name="goldgem_"..lamp.."_side_anim.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}}
  647. },
  648. paramtype = "light",
  649. on_place = l_func,
  650. paramtype2 = "facedir",
  651. sunlight_propagates = true,
  652. is_ground_content = false,
  653. light_source = 12,
  654. groups = {choppy=2,dig_immediate=3, not_in_creative_inventory=1},
  655. --legacy_wallmounted = true,
  656. sounds = default.node_sound_defaults(),
  657. drop ="gold_and_gem:"..lamp
  658. })
  659. end
  660. minetest.register_node("gold_and_gem:pillar", {
  661. tiles = {
  662. "technic_marble.png",
  663. "technic_marble.png",
  664. "technic_marble.png",
  665. "technic_marble.png",
  666. "technic_marble.png",
  667. "technic_marble.png"
  668. },
  669. description = "Marble Pillar",
  670. drawtype = "nodebox",
  671. paramtype = "light",
  672. is_ground_content = true,
  673. groups = {cracky=3},
  674. sounds = default.node_sound_stone_defaults(),
  675. node_box = {
  676. type = "fixed",
  677. fixed = {
  678. {-0.375, -0.5, -0.125, 0.375, 0.5, 0.125}, -- pillar_1
  679. {-0.125, -0.5, -0.375, 0.125, 0.5, 0.375}, -- pillar_2
  680. {-0.25, -0.5, -0.3125, 0.25, 0.5, 0.3125}, -- pillar_3
  681. {-0.3125, -0.5, -0.25, 0.3125, 0.5, 0.25}, -- pillar_4
  682. }
  683. }
  684. })
  685. minetest.register_node("gold_and_gem:pillar_ground", {
  686. tiles = {
  687. "technic_marble.png",
  688. "technic_marble.png",
  689. "technic_marble.png",
  690. "technic_marble.png",
  691. "technic_marble.png",
  692. "technic_marble.png"
  693. },
  694. description = "Marble Pillar Ground",
  695. drawtype = "nodebox",
  696. paramtype = "light",
  697. is_ground_content = true,
  698. groups = {cracky=3},
  699. sounds = default.node_sound_stone_defaults(),
  700. node_box = {
  701. type = "fixed",
  702. fixed = {
  703. {-0.375, -0.5, -0.125, 0.375, 0.5, 0.125}, -- pillar_1
  704. {-0.125, -0.5, -0.375, 0.125, 0.5, 0.375}, -- pillar_2
  705. {-0.25, -0.5, -0.3125, 0.25, 0.5, 0.3125}, -- pillar_3
  706. {-0.3125, -0.5, -0.25, 0.3125, 0.5, 0.25}, -- pillar_4
  707. {-0.4375, -0.4375, -0.4375, 0.4375, -0.375, 0.4375}, -- ground_1
  708. {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}, -- ground_2
  709. }
  710. }
  711. })
  712. minetest.register_node("gold_and_gem:pillar_top", {
  713. tiles = {
  714. "technic_marble.png",
  715. "technic_marble.png",
  716. "technic_marble.png",
  717. "technic_marble.png",
  718. "technic_marble.png",
  719. "technic_marble.png"
  720. },
  721. description = "Marble Pillar Top",
  722. drawtype = "nodebox",
  723. paramtype = "light",
  724. is_ground_content = true,
  725. groups = {cracky=3},
  726. sounds = default.node_sound_stone_defaults(),
  727. node_box = {
  728. type = "fixed",
  729. fixed = {
  730. {-0.375, -0.5, -0.125, 0.375, 0.5, 0.125}, -- pillar_1
  731. {-0.125, -0.5, -0.375, 0.125, 0.5, 0.375}, -- pillar_2
  732. {-0.25, -0.5, -0.3125, 0.25, 0.5, 0.3125}, -- pillar_3
  733. {-0.3125, -0.5, -0.25, 0.3125, 0.5, 0.25}, -- pillar_4
  734. {-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5}, -- top_1
  735. {-0.4375, 0.375, -0.4375, 0.4375, 0.4375, 0.4375}, -- top_2
  736. }
  737. }
  738. })
  739. local mats = {
  740. {"gold","Gold"},
  741. {"silver","Silver"}
  742. }
  743. for i in ipairs(mats) do
  744. local mat = mats[i][1]
  745. local name = mats[i][2]
  746. minetest.register_node("gold_and_gem:pillar_"..mat, {
  747. tiles = {
  748. "technic_marble.png",
  749. "technic_marble.png",
  750. "goldgem_pillar_front_"..mat..".png",
  751. "goldgem_pillar_back_"..mat..".png",
  752. "goldgem_pillar_right_"..mat..".png",
  753. "goldgem_pillar_left_"..mat..".png"
  754. },
  755. description = "Marble Pillar "..name,
  756. drawtype = "nodebox",
  757. paramtype = "light",
  758. is_ground_content = true,
  759. groups = {cracky=3},
  760. sounds = default.node_sound_stone_defaults(),
  761. node_box = {
  762. type = "fixed",
  763. fixed = {
  764. {-0.375, -0.5, -0.125, 0.375, 0.5, 0.125}, -- pillar_1
  765. {-0.125, -0.5, -0.375, 0.125, 0.5, 0.375}, -- pillar_2
  766. {-0.25, -0.5, -0.3125, 0.25, 0.5, 0.3125}, -- pillar_3
  767. {-0.3125, -0.5, -0.25, 0.3125, 0.5, 0.25}, -- pillar_4
  768. }
  769. }
  770. })
  771. minetest.register_node("gold_and_gem:pillar_ground_"..mat, {
  772. tiles = {
  773. "technic_marble.png",
  774. "technic_marble.png",
  775. "goldgem_pillar_front_"..mat.."_bottom.png",
  776. "goldgem_pillar_back_"..mat.."_bottom.png",
  777. "goldgem_pillar_right_"..mat.."_bottom.png",
  778. "goldgem_pillar_left_"..mat..".png"
  779. },
  780. description = "Marble Pillar Ground "..name,
  781. drawtype = "nodebox",
  782. paramtype = "light",
  783. is_ground_content = true,
  784. groups = {cracky=3},
  785. sounds = default.node_sound_stone_defaults(),
  786. node_box = {
  787. type = "fixed",
  788. fixed = {
  789. {-0.375, -0.5, -0.125, 0.375, 0.5, 0.125}, -- pillar_1
  790. {-0.125, -0.5, -0.375, 0.125, 0.5, 0.375}, -- pillar_2
  791. {-0.25, -0.5, -0.3125, 0.25, 0.5, 0.3125}, -- pillar_3
  792. {-0.3125, -0.5, -0.25, 0.3125, 0.5, 0.25}, -- pillar_4
  793. {-0.4375, -0.4375, -0.4375, 0.4375, -0.375, 0.4375}, -- ground_1
  794. {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}, -- ground_2
  795. }
  796. }
  797. })
  798. minetest.register_node("gold_and_gem:pillar_top_"..mat, {
  799. tiles = {
  800. "technic_marble.png",
  801. "technic_marble.png",
  802. "goldgem_pillar_front_"..mat.."_top.png",
  803. "goldgem_pillar_back_"..mat..".png",
  804. "goldgem_pillar_right_"..mat.."_top.png",
  805. "goldgem_pillar_left_"..mat.."_top.png"
  806. },
  807. description = "Marble Pillar Top "..name,
  808. drawtype = "nodebox",
  809. paramtype = "light",
  810. is_ground_content = true,
  811. groups = {cracky=3},
  812. sounds = default.node_sound_stone_defaults(),
  813. node_box = {
  814. type = "fixed",
  815. fixed = {
  816. {-0.375, -0.5, -0.125, 0.375, 0.5, 0.125}, -- pillar_1
  817. {-0.125, -0.5, -0.375, 0.125, 0.5, 0.375}, -- pillar_2
  818. {-0.25, -0.5, -0.3125, 0.25, 0.5, 0.3125}, -- pillar_3
  819. {-0.3125, -0.5, -0.25, 0.3125, 0.5, 0.25}, -- pillar_4
  820. {-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5}, -- top_1
  821. {-0.4375, 0.375, -0.4375, 0.4375, 0.4375, 0.4375}, -- top_2
  822. }
  823. }
  824. })
  825. end