init.lua 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. --LIGHTS+
  2. --updated 12/11/2013
  3. --Mod adding simple on/off lights by qwrwed.
  4. -- License is WTFPL, textures are by VanessaE and paramat, code for flat lights
  5. -- is by LionsDen.
  6. -- Mod updated and made compatible with MustTest, by MustTest.
  7. --Node Definitions and Functions
  8. local lights = {
  9. {"lightsplus:light", "lightsplus:light_on", "Light", "lightsplus_light.png", "", "", "facedir", ""},
  10. {"lightsplus:gold_light", "lightsplus:gold_light_on", "Gold Light", "lightsplus_gold_light.png", "", "facedir", "", ""},
  11. {"lightsplus:slab_light", "lightsplus:slab_light_on", "Slab Light", "lightsplus_light.png", "light", "facedir", "nodebox", {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},},},
  12. {"lightsplus:gold_slab_light", "lightsplus:gold_slab_light_on", "Gold Slab Light", "lightsplus_gold_light.png", "light", "facedir", "nodebox", {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},},},
  13. {"lightsplus:flat_light", "lightsplus:flat_light_on", "Flat Light", "lightsplus_light.png", "light", "facedir", "nodebox", {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -7/16, 0.5},},},
  14. {"lightsplus:gold_flat_light", "lightsplus:gold_flat_light_on", "Gold Flat Light", "lightsplus_gold_light.png", "light", "facedir", "nodebox", {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -7/16, 0.5},},},
  15. }
  16. for _, row in ipairs(lights) do
  17. local off = row[1]
  18. local on = row[2]
  19. local desc = row[3]
  20. local tiles = row[4]
  21. local paramtype = row[5]
  22. local paramtype2 = row[6]
  23. local drawtype = row[7]
  24. local nodebox = row[8]
  25. local dig_group = "glass"
  26. if off:find("flat") then
  27. dig_group = "bigitem"
  28. end
  29. minetest.register_node(off, {
  30. description = desc,
  31. tiles = { tiles },
  32. groups = utility.dig_groups(dig_group),
  33. paramtype = paramtype,
  34. paramtype2 = paramtype2,
  35. drawtype = drawtype,
  36. node_box = nodebox,
  37. selection_box = nodebox,
  38. on_punch = function(pos, node, puncher)
  39. minetest.swap_node(pos, {name=on, param2=node.param2})
  40. end,
  41. on_place = minetest.rotate_and_place
  42. })
  43. minetest.register_node(on, {
  44. description = desc .. " (Active)",
  45. drop = off,
  46. tiles = { tiles },
  47. light_source = 14,
  48. groups = utility.dig_groups(dig_group, {not_in_creative_inventory=1}),
  49. paramtype = paramtype,
  50. paramtype2 = paramtype2,
  51. drawtype = drawtype,
  52. node_box = nodebox,
  53. selection_box = nodebox,
  54. on_punch = function(pos, node, puncher)
  55. minetest.swap_node(pos, {name=off, param2=node.param2})
  56. end,
  57. on_place = minetest.rotate_and_place
  58. })
  59. end
  60. -- CRAFTING
  61. --Light
  62. minetest.register_craft({
  63. output = "lightsplus:light",
  64. recipe = {
  65. {'plastic:plastic_sheeting', 'plastic:plastic_sheeting', 'plastic:plastic_sheeting'},
  66. {'plastic:plastic_sheeting', 'moreblocks:super_glow_glass', 'plastic:plastic_sheeting'},
  67. {'plastic:plastic_sheeting', 'plastic:plastic_sheeting', 'plastic:plastic_sheeting'},
  68. }
  69. })
  70. --Gold Light
  71. minetest.register_craft({
  72. type = "shapeless",
  73. output = "lightsplus:gold_light",
  74. recipe = {'lightsplus:light', 'default:gold_ingot'},
  75. })
  76. --Gold Slab Light
  77. minetest.register_craft({
  78. output = '"lightsplus:gold_slab_light" 6',
  79. recipe = {
  80. {'lightsplus:gold_light', 'lightsplus:gold_light', 'lightsplus:gold_light'},
  81. }
  82. })
  83. --Gold Light from Slabs
  84. minetest.register_craft({
  85. output = '"lightsplus:gold_light"',
  86. recipe = {
  87. {'lightsplus:gold_slab_light'},
  88. {'lightsplus:gold_slab_light'},
  89. }
  90. })
  91. --Slab Light
  92. minetest.register_craft({
  93. output = '"lightsplus:slab_light" 6',
  94. recipe = {
  95. {'lightsplus:light', 'lightsplus:light', 'lightsplus:light'},
  96. }
  97. })
  98. --Light from Slabs
  99. minetest.register_craft({
  100. output = '"lightsplus:light"',
  101. recipe = {
  102. {'lightsplus:slab_light'},
  103. {'lightsplus:slab_light'},
  104. }
  105. })
  106. --Flat Light
  107. minetest.register_craft({
  108. output = '"lightsplus:flat_light" 16',
  109. recipe = {
  110. {'lightsplus:light'},
  111. }
  112. })
  113. --Slab Light from Flat Light
  114. minetest.register_craft({
  115. type = "shapeless",
  116. output = "lightsplus:slab_light",
  117. recipe = {'lightsplus:flat_light', 'lightsplus:flat_light', 'lightsplus:flat_light', 'lightsplus:flat_light', 'lightsplus:flat_light', 'lightsplus:flat_light', 'lightsplus:flat_light', 'lightsplus:flat_light'},
  118. })
  119. --Gold Flat Light
  120. minetest.register_craft({
  121. output = '"lightsplus:gold_flat_light" 16',
  122. recipe = {
  123. {'lightsplus:gold_light'},
  124. }
  125. })
  126. --Gold Slab from Gold Flat Lights
  127. minetest.register_craft({
  128. type = "shapeless",
  129. output = "lightsplus:gold_slab_light",
  130. recipe = {'lightsplus:gold_flat_light', 'lightsplus:gold_flat_light', 'lightsplus:gold_flat_light', 'lightsplus:gold_flat_light', 'lightsplus:gold_flat_light', 'lightsplus:gold_flat_light', 'lightsplus:gold_flat_light', 'lightsplus:gold_flat_light'},
  131. })
  132. minetest.register_alias("newlights:light", "lightsplus:light")
  133. minetest.register_alias("newlights:light_on", "lightsplus:light_on")
  134. minetest.register_alias("newlights:slab_light", "lightsplus:flat_light")
  135. minetest.register_alias("newlights:slab_light_on", "lightsplus:flat_light_on")
  136. minetest.register_alias("lightsplus:light_flat", "lightsplus:flat_light")
  137. minetest.register_alias("lightsplus:slab_light_wall", "lightsplus:slab_light")
  138. minetest.register_alias("lightsplus:slab_light_wall_on", "lightsplus:slab_light_on")
  139. minetest.register_alias("lightsplus:slab_light_inv", "lightsplus:slab_light")
  140. minetest.register_alias("lightsplus:slab_light_inv_on", "lightsplus:slab_light_on")
  141. minetest.register_alias("lightsplus:light_gold", "lightsplus:gold_light")
  142. minetest.register_alias("lightsplus:light_on_gold", "lightsplus:gold_light_on")
  143. minetest.register_alias("lightsplus:slab_light_gold", "lightsplus:gold_slab_light")
  144. minetest.register_alias("lightsplus:slab_light_on_gold", "lightsplus:gold_slab_light_on")
  145. minetest.register_alias("lightsplus:slab_light_wall_gold", "lightsplus:gold_slab_light")
  146. minetest.register_alias("lightsplus:slab_light_wall_on_gold", "lightsplus:gold_slab_light_on")
  147. minetest.register_alias("lightsplus:slab_light_inv_gold", "lightsplus:gold_slab_light")
  148. minetest.register_alias("lightsplus:slab_light_inv_on_gold", "lightsplus:gold_slab_light_on")
  149. minetest.register_alias("lightsplus:light_flat", "lightsplus:flat_light")
  150. minetest.register_alias("lightsplus:light_flat_on", "lightsplus:flat_light_on")
  151. minetest.register_alias("lightsplus:light_flat_gold", "lightsplus:gold_flat_light")
  152. minetest.register_alias("lightsplus:light_flat_on_gold", "lightsplus:gold_flat_light_on")
  153. -- Register the function for use (optional, uncomment the following line to enable)
  154. -- print("[Lights+] Loaded!")