init.lua 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. local light_source = 14
  30. if off:find("slab") then
  31. light_source = 12
  32. elseif off:find("flat") then
  33. light_source = 8
  34. end
  35. minetest.register_node(off, {
  36. description = desc,
  37. tiles = { tiles },
  38. groups = utility.dig_groups(dig_group),
  39. paramtype = paramtype,
  40. paramtype2 = paramtype2,
  41. drawtype = drawtype,
  42. node_box = nodebox,
  43. selection_box = nodebox,
  44. on_punch = function(pos, node, puncher)
  45. minetest.swap_node(pos, {name=on, param2=node.param2})
  46. end,
  47. on_place = minetest.rotate_and_place
  48. })
  49. minetest.register_node(on, {
  50. description = desc .. " (Active)",
  51. drop = off,
  52. tiles = { tiles },
  53. light_source = light_source,
  54. groups = utility.dig_groups(dig_group, {not_in_creative_inventory=1}),
  55. paramtype = paramtype,
  56. paramtype2 = paramtype2,
  57. drawtype = drawtype,
  58. node_box = nodebox,
  59. selection_box = nodebox,
  60. on_punch = function(pos, node, puncher)
  61. minetest.swap_node(pos, {name=off, param2=node.param2})
  62. end,
  63. on_place = minetest.rotate_and_place
  64. })
  65. end
  66. -- CRAFTING
  67. --Light
  68. minetest.register_craft({
  69. output = "lightsplus:light",
  70. recipe = {
  71. {'plastic:plastic_sheeting', 'plastic:plastic_sheeting', 'plastic:plastic_sheeting'},
  72. {'plastic:plastic_sheeting', 'moreblocks:super_glow_glass', 'plastic:plastic_sheeting'},
  73. {'plastic:plastic_sheeting', 'plastic:plastic_sheeting', 'plastic:plastic_sheeting'},
  74. }
  75. })
  76. --Gold Light
  77. minetest.register_craft({
  78. type = "shapeless",
  79. output = "lightsplus:gold_light",
  80. recipe = {'lightsplus:light', 'default:gold_ingot'},
  81. })
  82. --Gold Slab Light
  83. minetest.register_craft({
  84. output = '"lightsplus:gold_slab_light" 6',
  85. recipe = {
  86. {'lightsplus:gold_light', 'lightsplus:gold_light', 'lightsplus:gold_light'},
  87. }
  88. })
  89. --Gold Light from Slabs
  90. minetest.register_craft({
  91. output = '"lightsplus:gold_light"',
  92. recipe = {
  93. {'lightsplus:gold_slab_light'},
  94. {'lightsplus:gold_slab_light'},
  95. }
  96. })
  97. --Slab Light
  98. minetest.register_craft({
  99. output = '"lightsplus:slab_light" 6',
  100. recipe = {
  101. {'lightsplus:light', 'lightsplus:light', 'lightsplus:light'},
  102. }
  103. })
  104. --Light from Slabs
  105. minetest.register_craft({
  106. output = '"lightsplus:light"',
  107. recipe = {
  108. {'lightsplus:slab_light'},
  109. {'lightsplus:slab_light'},
  110. }
  111. })
  112. --Flat Light
  113. minetest.register_craft({
  114. output = '"lightsplus:flat_light" 16',
  115. recipe = {
  116. {'lightsplus:light'},
  117. }
  118. })
  119. --Slab Light from Flat Light
  120. minetest.register_craft({
  121. type = "shapeless",
  122. output = "lightsplus:slab_light",
  123. recipe = {
  124. 'lightsplus:flat_light',
  125. 'lightsplus:flat_light',
  126. 'lightsplus:flat_light',
  127. 'lightsplus:flat_light',
  128. 'lightsplus:flat_light',
  129. 'lightsplus:flat_light',
  130. 'lightsplus:flat_light',
  131. 'lightsplus:flat_light'
  132. },
  133. })
  134. --Gold Flat Light
  135. minetest.register_craft({
  136. output = '"lightsplus:gold_flat_light" 16',
  137. recipe = {
  138. {'lightsplus:gold_light'},
  139. }
  140. })
  141. --Gold Slab from Gold Flat Lights
  142. minetest.register_craft({
  143. type = "shapeless",
  144. output = "lightsplus:gold_slab_light",
  145. recipe = {
  146. 'lightsplus:gold_flat_light',
  147. 'lightsplus:gold_flat_light',
  148. 'lightsplus:gold_flat_light',
  149. 'lightsplus:gold_flat_light',
  150. 'lightsplus:gold_flat_light',
  151. 'lightsplus:gold_flat_light',
  152. 'lightsplus:gold_flat_light',
  153. 'lightsplus:gold_flat_light'
  154. },
  155. })
  156. minetest.register_alias("newlights:light", "lightsplus:light")
  157. minetest.register_alias("newlights:light_on", "lightsplus:light_on")
  158. minetest.register_alias("newlights:slab_light", "lightsplus:flat_light")
  159. minetest.register_alias("newlights:slab_light_on", "lightsplus:flat_light_on")
  160. minetest.register_alias("lightsplus:slab_light_wall", "lightsplus:slab_light")
  161. minetest.register_alias("lightsplus:slab_light_wall_on", "lightsplus:slab_light_on")
  162. minetest.register_alias("lightsplus:slab_light_inv", "lightsplus:slab_light")
  163. minetest.register_alias("lightsplus:slab_light_inv_on", "lightsplus:slab_light_on")
  164. minetest.register_alias("lightsplus:light_gold", "lightsplus:gold_light")
  165. minetest.register_alias("lightsplus:light_on_gold", "lightsplus:gold_light_on")
  166. minetest.register_alias("lightsplus:slab_light_gold", "lightsplus:gold_slab_light")
  167. minetest.register_alias("lightsplus:slab_light_on_gold", "lightsplus:gold_slab_light_on")
  168. minetest.register_alias("lightsplus:slab_light_wall_gold", "lightsplus:gold_slab_light")
  169. minetest.register_alias("lightsplus:slab_light_wall_on_gold", "lightsplus:gold_slab_light_on")
  170. minetest.register_alias("lightsplus:slab_light_inv_gold", "lightsplus:gold_slab_light")
  171. minetest.register_alias("lightsplus:slab_light_inv_on_gold", "lightsplus:gold_slab_light_on")
  172. minetest.register_alias("lightsplus:light_flat", "lightsplus:flat_light")
  173. minetest.register_alias("lightsplus:light_flat_on", "lightsplus:flat_light_on")
  174. minetest.register_alias("lightsplus:light_flat_gold", "lightsplus:gold_flat_light")
  175. minetest.register_alias("lightsplus:light_flat_on_gold", "lightsplus:gold_flat_light_on")