properties.lua 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. -- Test Nodes: Node property tests
  2. local S = minetest.get_translator("testnodes")
  3. -- Is supposed to fall when it doesn't rest on solid ground
  4. minetest.register_node("testnodes:falling", {
  5. description = S("Falling Node"),
  6. tiles = {
  7. "testnodes_node.png",
  8. "testnodes_node.png",
  9. "testnodes_node_falling.png",
  10. },
  11. groups = { falling_node = 1, dig_immediate = 3 },
  12. })
  13. -- Same as falling node, but will stop falling on top of liquids
  14. minetest.register_node("testnodes:falling_float", {
  15. description = S("Falling+Floating Node"),
  16. groups = { falling_node = 1, float = 1, dig_immediate = 3 },
  17. tiles = {
  18. "testnodes_node.png",
  19. "testnodes_node.png",
  20. "testnodes_node_falling.png",
  21. },
  22. color = "cyan",
  23. })
  24. -- This node attaches to the floor and drops as item
  25. -- when the floor is gone.
  26. minetest.register_node("testnodes:attached", {
  27. description = S("Floor-Attached Node"),
  28. tiles = {
  29. "testnodes_attached_top.png",
  30. "testnodes_attached_bottom.png",
  31. "testnodes_attached_side.png",
  32. },
  33. groups = { attached_node = 1, dig_immediate = 3 },
  34. })
  35. -- This node attaches to the side of a node and drops as item
  36. -- when the node it attaches to is gone.
  37. minetest.register_node("testnodes:attached_wallmounted", {
  38. description = S("Wallmounted Attached Node"),
  39. paramtype2 = "wallmounted",
  40. tiles = {
  41. "testnodes_attachedw_top.png",
  42. "testnodes_attachedw_bottom.png",
  43. "testnodes_attachedw_side.png",
  44. },
  45. groups = { attached_node = 1, dig_immediate = 3 },
  46. })
  47. -- Jump disabled
  48. minetest.register_node("testnodes:nojump", {
  49. description = S("Non-jumping Node"),
  50. groups = {disable_jump=1, dig_immediate=3},
  51. tiles = {"testnodes_nojump_top.png", "testnodes_nojump_side.png"},
  52. })
  53. -- Jump disabled plant
  54. minetest.register_node("testnodes:nojump_walkable", {
  55. description = S("Non-jumping Plant Node"),
  56. drawtype = "plantlike",
  57. groups = {disable_jump=1, dig_immediate=3},
  58. walkable = false,
  59. tiles = {"testnodes_nojump_top.png"},
  60. })
  61. -- Climbable up and down with jump and sneak keys
  62. minetest.register_node("testnodes:climbable", {
  63. description = S("Climbable Node"),
  64. climbable = true,
  65. walkable = false,
  66. paramtype = "light",
  67. sunlight_propagates = true,
  68. is_ground_content = false,
  69. tiles ={"testnodes_climbable_side.png"},
  70. drawtype = "glasslike",
  71. groups = {dig_immediate=3},
  72. })
  73. -- Climbable only downwards with sneak key
  74. minetest.register_node("testnodes:climbable_nojump", {
  75. description = S("Downwards-climbable Node"),
  76. climbable = true,
  77. walkable = false,
  78. groups = {disable_jump=1, dig_immediate=3},
  79. drawtype = "glasslike",
  80. tiles ={"testnodes_climbable_nojump_side.png"},
  81. paramtype = "light",
  82. sunlight_propagates = true,
  83. })
  84. -- A liquid in which you can't rise
  85. minetest.register_node("testnodes:liquid_nojump", {
  86. description = S("Non-jumping Liquid Source Node"),
  87. liquidtype = "source",
  88. liquid_range = 1,
  89. liquid_viscosity = 0,
  90. liquid_alternative_flowing = "testnodes:liquidflowing_nojump",
  91. liquid_alternative_source = "testnodes:liquid_nojump",
  92. liquid_renewable = false,
  93. groups = {disable_jump=1, dig_immediate=3},
  94. walkable = false,
  95. drawtype = "liquid",
  96. tiles = {"testnodes_liquidsource.png^[colorize:#FF0000:127"},
  97. special_tiles = {
  98. {name = "testnodes_liquidsource.png^[colorize:#FF0000:127", backface_culling = false},
  99. {name = "testnodes_liquidsource.png^[colorize:#FF0000:127", backface_culling = true},
  100. },
  101. use_texture_alpha = "blend",
  102. paramtype = "light",
  103. pointable = false,
  104. liquids_pointable = true,
  105. buildable_to = true,
  106. is_ground_content = false,
  107. post_effect_color = {a = 70, r = 255, g = 0, b = 200},
  108. })
  109. -- A liquid in which you can't rise (flowing variant)
  110. minetest.register_node("testnodes:liquidflowing_nojump", {
  111. description = S("Non-jumping Flowing Liquid Node"),
  112. liquidtype = "flowing",
  113. liquid_range = 1,
  114. liquid_viscosity = 0,
  115. liquid_alternative_flowing = "testnodes:liquidflowing_nojump",
  116. liquid_alternative_source = "testnodes:liquid_nojump",
  117. liquid_renewable = false,
  118. groups = {disable_jump=1, dig_immediate=3},
  119. walkable = false,
  120. drawtype = "flowingliquid",
  121. tiles = {"testnodes_liquidflowing.png^[colorize:#FF0000:127"},
  122. special_tiles = {
  123. {name = "testnodes_liquidflowing.png^[colorize:#FF0000:127", backface_culling = false},
  124. {name = "testnodes_liquidflowing.png^[colorize:#FF0000:127", backface_culling = false},
  125. },
  126. use_texture_alpha = "blend",
  127. paramtype = "light",
  128. paramtype2 = "flowingliquid",
  129. pointable = false,
  130. liquids_pointable = true,
  131. buildable_to = true,
  132. is_ground_content = false,
  133. post_effect_color = {a = 70, r = 255, g = 0, b = 200},
  134. })
  135. -- Nodes that modify fall damage (various damage modifiers)
  136. for i=-100, 100, 25 do
  137. if i ~= 0 then
  138. local subname, descnum
  139. if i < 0 then
  140. subname = "m"..math.abs(i)
  141. descnum = tostring(i)
  142. else
  143. subname = tostring(i)
  144. descnum = S("+@1", i)
  145. end
  146. local tex, color, desc
  147. if i > 0 then
  148. local val = math.floor((i/100)*255)
  149. tex = "testnodes_fall_damage_plus.png"
  150. color = { b=0, g=255-val, r=255, a=255 }
  151. desc = S("Fall Damage Node (+@1%)", i)
  152. else
  153. tex = "testnodes_fall_damage_minus.png"
  154. if i == -100 then
  155. color = { r=0, b=0, g=255, a=255 }
  156. else
  157. local val = math.floor((math.abs(i)/100)*255)
  158. color = { r=0, b=255, g=255-val, a=255 }
  159. end
  160. desc = S("Fall Damage Node (-@1%)", math.abs(i))
  161. end
  162. minetest.register_node("testnodes:damage"..subname, {
  163. description = desc,
  164. groups = {fall_damage_add_percent=i, dig_immediate=3},
  165. tiles = { tex },
  166. is_ground_content = false,
  167. color = color,
  168. })
  169. end
  170. end
  171. -- Bouncy nodes (various bounce levels)
  172. for i=20, 180, 20 do
  173. local val = math.floor(((i-20)/200)*255)
  174. minetest.register_node("testnodes:bouncy"..i, {
  175. description = S("Bouncy Node (@1%)", i),
  176. groups = {bouncy=i, dig_immediate=3},
  177. tiles ={"testnodes_bouncy.png"},
  178. is_ground_content = false,
  179. color = { r=255, g=255-val, b=val, a=255 },
  180. })
  181. end
  182. -- Slippery nodes (various slippery levels)
  183. for i=1, 5 do
  184. minetest.register_node("testnodes:slippery"..i, {
  185. description = S("Slippery Node (@1)", i),
  186. tiles ={"testnodes_slippery.png"},
  187. is_ground_content = false,
  188. groups = {slippery=i, dig_immediate=3},
  189. color = { r=0, g=255, b=math.floor((i/5)*255), a=255 },
  190. })
  191. end
  192. -- By placing something on the node, the node itself will be replaced
  193. minetest.register_node("testnodes:buildable_to", {
  194. description = S("Replacable Node"),
  195. buildable_to = true,
  196. tiles = {"testnodes_buildable_to.png"},
  197. is_ground_content = false,
  198. groups = {dig_immediate=3},
  199. })
  200. -- Nodes that deal damage to players that are inside them.
  201. -- Negative damage nodes should heal.
  202. for d=-3,3 do
  203. if d ~= 0 then
  204. local sub, tile
  205. if d > 0 then
  206. sub = tostring(d)
  207. tile = "testnodes_damage.png"
  208. else
  209. sub = "m" .. tostring(math.abs(d))
  210. tile = "testnodes_damage_neg.png"
  211. end
  212. if math.abs(d) == 2 then
  213. tile = tile .. "^[colorize:#000000:70"
  214. elseif math.abs(d) == 3 then
  215. tile = tile .. "^[colorize:#000000:140"
  216. end
  217. minetest.register_node("testnodes:damage_"..sub, {
  218. description = S("Damage Node (@1 damage per second)", d),
  219. damage_per_second = d,
  220. walkable = false,
  221. is_ground_content = false,
  222. drawtype = "allfaces",
  223. paramtype = "light",
  224. sunlight_propagates = true,
  225. tiles = { tile },
  226. groups = {dig_immediate=3},
  227. })
  228. end
  229. end
  230. -- Causes drowning damage
  231. minetest.register_node("testnodes:drowning_1", {
  232. description = S("Drowning Node (@1 damage)", 1),
  233. drowning = 1,
  234. walkable = false,
  235. is_ground_content = false,
  236. drawtype = "allfaces",
  237. paramtype = "light",
  238. sunlight_propagates = true,
  239. tiles = { "testnodes_drowning.png" },
  240. groups = {dig_immediate=3},
  241. })