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