]> git.lizzy.rs Git - Crafter.git/blob - mods/main/nodes.lua
13c602025b7c19012c7b546f9676ff23150ebc99
[Crafter.git] / mods / main / nodes.lua
1 --ore def with required tool
2 local ores = {"coal","iron","gold","diamond"}
3 local tool = {"main:woodpick","main:stonepick","main:ironpick","main:goldpick","main:diamondpick"}
4 for id,ore in pairs(ores) do
5         local tool_required = {}
6         for i = id,5 do
7                 table.insert(tool_required, tool[i])
8         end
9
10         local drops = {"main:"..ore.."ore"}
11         if ore == "diamond" then drops = {"main:diamond"} elseif ore == "coal" then drops = {"main:coal"} end
12         
13         minetest.register_node("main:"..ore.."ore", {
14                 description = ore:gsub("^%l", string.upper).." Ore",
15                 tiles = {"stone.png^"..ore.."ore.png"},
16                 groups = {stone = id, pathable = 1},
17                 sounds = main.stoneSound(),
18                 --light_source = 14,--debugging ore spawn
19                 drop = {
20                         max_items = 1,
21                         items= {
22                                 {
23                                         rarity = 0,
24                                         tools = tool_required,
25                                         items = drops,
26                                 },
27                                 },
28                         },
29                 })
30 end
31
32 minetest.register_node("main:stone", {
33     description = "Stone",
34     tiles = {"stone.png"},
35     groups = {stone = 1, hand = 1,pathable = 1},
36     sounds = main.stoneSound(),
37     drop = {
38                 max_items = 1,
39                 items= {
40                         {
41                                 rarity = 0,
42                                 tools = tool,
43                                 items = {"main:cobble"},
44                         },
45                         },
46                 },
47         })
48
49 minetest.register_node("main:cobble", {
50     description = "Cobblestone",
51     tiles = {"cobble.png"},
52     groups = {stone = 1, pathable = 1},
53     sounds = main.stoneSound(),
54     drop = {
55                 max_items = 1,
56                 items= {
57                         {
58                                 rarity = 0,
59                                 tools = tool,
60                                 items = {"main:cobble"},
61                         },
62                         },
63                 },
64 })
65
66 minetest.register_node("main:glass", {
67     description = "Glass",
68     tiles = {"glass.png"},
69     drawtype = "glasslike",
70         paramtype = "light",
71         sunlight_propagates = true,
72         is_ground_content = false,
73     groups = {glass = 1, pathable = 1},
74     sounds = main.stoneSound({
75                 footstep = {name = "glass_footstep", gain = 0.4},
76         dug =  {name = "break_glass", gain = 0.4},
77         }),
78     drop = "",
79         })
80
81 minetest.register_node("main:dirt", {
82     description = "Dirt",
83     tiles = {"dirt.png"},
84     groups = {dirt = 1, soil=1,pathable = 1, farm_tillable=1},
85     sounds = main.dirtSound(),
86     paramtype = "light",
87 })
88
89 minetest.register_node("main:grass", {
90     description = "Grass",
91     tiles = {"grass.png"},
92     groups = {grass = 1, soil=1,pathable = 1, farm_tillable=1},
93     sounds = main.dirtSound(),
94     drop="main:dirt",
95 })
96
97 minetest.register_node("main:sand", {
98     description = "Sand",
99     tiles = {"sand.png"},
100     groups = {sand = 1, falling_node = 1,pathable = 1},
101     sounds = main.sandSound(),
102 })
103
104 minetest.register_node("main:gravel", {
105     description = "Gravel",
106     tiles = {"gravel.png"},
107     groups = {sand = 1, falling_node = 1,pathable = 1},
108     sounds = main.dirtSound(),
109     drop = {
110                 max_items = 1,
111                 items= {
112                  {
113                         -- Only drop if using a tool whose name is identical to one
114                         -- of these.
115                         rarity = 10,
116                         items = {"main:flint"},
117                         -- Whether all items in the dropped item list inherit the
118                         -- hardware coloring palette color from the dug node.
119                         -- Default is 'false'.
120                         --inherit_color = true,
121                 },
122                 {
123                         -- Only drop if using a tool whose name is identical to one
124                         -- of these.
125                         --tools = {"main:shears"},
126                         rarity = 0,
127                         items = {"main:gravel"},
128                         -- Whether all items in the dropped item list inherit the
129                         -- hardware coloring palette color from the dug node.
130                         -- Default is 'false'.
131                         --inherit_color = true,
132                 },
133         }},
134 })
135
136 minetest.register_node("main:tree", {
137     description = "Tree",
138     tiles = {"treeCore.png","treeCore.png","treeOut.png","treeOut.png","treeOut.png","treeOut.png"},
139     groups = {wood = 1, tree = 1, pathable = 1, flammable=1},
140     sounds = main.woodSound(),
141     --set metadata so treecapitator doesn't destroy houses
142     on_place = function(itemstack, placer, pointed_thing)
143                 if not pointed_thing.type == "node" then
144                         return
145                 end
146                 
147                 local sneak = placer:get_player_control().sneak
148                 local noddef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name]
149                 if not sneak and noddef.on_rightclick then
150                         minetest.item_place(itemstack, placer, pointed_thing)
151                         return
152                 end
153                 
154                 local pos = pointed_thing.above
155                 minetest.item_place_node(itemstack, placer, pointed_thing)
156                 local meta = minetest.get_meta(pos)
157                 meta:set_string("placed", "true")       
158                 return(itemstack)
159         end,
160         --treecapitator - move treecapitator into own file using override
161         on_dig = function(pos, node, digger)
162         
163                 --check if wielding axe?
164                 
165                 local meta = minetest.get_meta(pos)
166                 if not meta:contains("placed") then
167                         --remove tree
168                         for y = -6,6 do
169                                 local name = minetest.get_node(vector.new(pos.x,pos.y+y,pos.z)).name
170                                 --print(y)
171                                 if name == "main:tree" or name == "redstone:node_activated_tree" then
172                                         minetest.node_dig(vector.new(pos.x,pos.y+y,pos.z), node, digger)
173                                 end
174                         end
175                 else
176                         minetest.node_dig(pos, node, digger)
177                 end     
178         end
179 })
180
181 minetest.register_node("main:wood", {
182     description = "Wood",
183     tiles = {"wood.png"},
184     groups = {wood = 1, pathable = 1,flammable=1},
185     sounds = main.woodSound(),
186 })
187
188 minetest.register_node("main:leaves", {
189     description = "Leaves",
190     drawtype = "allfaces_optional",
191         waving = 1,
192         walkable = false,
193         climbable = true,
194         paramtype = "light",
195         is_ground_content = false,      
196     tiles = {"leaves.png"},
197     groups = {leaves = 1, leafdecay = 1,flammable=1},
198     sounds = main.grassSound(),
199     drop = {
200                 max_items = 1,
201                 items= {
202                  {
203                         -- Only drop if using a tool whose name is identical to one
204                         -- of these.
205                         rarity = 10,
206                         items = {"main:sapling"},
207                         -- Whether all items in the dropped item list inherit the
208                         -- hardware coloring palette color from the dug node.
209                         -- Default is 'false'.
210                         --inherit_color = true,
211                 },
212                 {
213                         -- Only drop if using a tool whose name is identical to one
214                         -- of these.
215                         tools = {"main:shears"},
216                         rarity = 2,
217                         items = {"main:leaves"},
218                         -- Whether all items in the dropped item list inherit the
219                         -- hardware coloring palette color from the dug node.
220                         -- Default is 'false'.
221                         --inherit_color = true,
222                 },
223                 {
224                         -- Only drop if using a tool whose name is identical to one
225                         -- of these.
226                         tools = {"main:shears"},
227                         rarity = 2,
228                         items = {"main:stick"},
229                         -- Whether all items in the dropped item list inherit the
230                         -- hardware coloring palette color from the dug node.
231                         -- Default is 'false'.
232                         --inherit_color = true,
233                 },
234                 {
235                         -- Only drop if using a tool whose name is identical to one
236                         -- of these.
237                         tools = {"main:shears"},
238                         rarity = 6,
239                         items = {"main:apple"},
240                         -- Whether all items in the dropped item list inherit the
241                         -- hardware coloring palette color from the dug node.
242                         -- Default is 'false'.
243                         --inherit_color = true,
244                 },
245                 },
246     },
247 })
248
249 minetest.register_node("main:water", {
250         description = "Water Source",
251         drawtype = "liquid",
252         waving = 3,
253         tiles = {
254                 {
255                         name = "water_source.png",
256                         backface_culling = false,
257                         animation = {
258                                 type = "vertical_frames",
259                                 aspect_w = 16,
260                                 aspect_h = 16,
261                                 length = 1,
262                         },
263                 },
264                 {
265                         name = "water_source.png",
266                         backface_culling = true,
267                         animation = {
268                                 type = "vertical_frames",
269                                 aspect_w = 16,
270                                 aspect_h = 16,
271                                 length = 1,
272                         },
273                 },
274         },
275         alpha = 191,
276         paramtype = "light",
277         walkable = false,
278         pointable = false,
279         diggable = false,
280         buildable_to = true,
281         is_ground_content = false,
282         drop = "",
283         drowning = 1,
284         liquidtype = "source",
285         liquid_alternative_flowing = "main:waterflow",
286         liquid_alternative_source = "main:water",
287         liquid_viscosity = 1,
288         post_effect_color = {a = 103, r = 30, g = 60, b = 90},
289         groups = {water = 1, liquid = 1, cools_lava = 1, bucket = 1, source = 1,pathable = 1},
290         --sounds = default.node_sound_water_defaults(),
291         
292         --water explodes in the nether
293         on_construct = function(pos)
294                 if pos.y <= -10033 then
295                         tnt(pos,10)
296                 end
297         end,
298 })
299
300 minetest.register_node("main:waterflow", {
301         description = "Water Flow",
302         drawtype = "flowingliquid",
303         waving = 3,
304         tiles = {"water_static.png"},
305         special_tiles = {
306                 {
307                         name = "water_flow.png",
308                         backface_culling = false,
309                         animation = {
310                                 type = "vertical_frames",
311                                 aspect_w = 16,
312                                 aspect_h = 16,
313                                 length = 0.5,
314                         },
315                 },
316                 {
317                         name = "water_flow.png",
318                         backface_culling = true,
319                         animation = {
320                                 type = "vertical_frames",
321                                 aspect_w = 16,
322                                 aspect_h = 16,
323                                 length = 0.5,
324                         },
325                 },
326         },
327         selection_box = {
328             type = "fixed",
329             fixed = {
330                 {0, 0, 0, 0, 0, 0},
331             },
332         },
333         alpha = 191,
334         paramtype = "light",
335         paramtype2 = "flowingliquid",
336         walkable = false,
337         pointable = false,
338         diggable = false,
339         buildable_to = true,
340         is_ground_content = false,
341         drop = "",
342         drowning = 1,
343         liquidtype = "flowing",
344         liquid_alternative_flowing = "main:waterflow",
345         liquid_alternative_source = "main:water",
346         liquid_viscosity = 1,
347         post_effect_color = {a = 103, r = 30, g = 60, b = 90},
348         groups = {water = 1, liquid = 1, notInCreative = 1, cools_lava = 1,pathable = 1},
349         --sounds = default.node_sound_water_defaults(),
350 })
351
352 minetest.register_node("main:lava", {
353         description = "Lava",
354         drawtype = "liquid",
355         tiles = {
356                 {
357                         name = "lava_source.png",
358                         backface_culling = false,
359                         animation = {
360                                 type = "vertical_frames",
361                                 aspect_w = 16,
362                                 aspect_h = 16,
363                                 length = 2.0,
364                         },
365                 },
366                 {
367                         name = "lava_source.png",
368                         backface_culling = true,
369                         animation = {
370                                 type = "vertical_frames",
371                                 aspect_w = 16,
372                                 aspect_h = 16,
373                                 length = 2.0,
374                         },
375                 },
376         },
377         paramtype = "light",
378         light_source = 13,
379         walkable = false,
380         pointable = false,
381         diggable = false,
382         buildable_to = true,
383         is_ground_content = false,
384         drop = "",
385         drowning = 1,
386         liquidtype = "source",
387         liquid_alternative_flowing = "main:lavaflow",
388         liquid_alternative_source = "main:lava",
389         liquid_viscosity = 7,
390         liquid_renewable = false,
391         damage_per_second = 4 * 2,
392         post_effect_color = {a = 191, r = 255, g = 64, b = 0},
393         groups = {lava = 3, liquid = 2, igniter = 1},
394 })
395
396 minetest.register_node("main:lavaflow", {
397         description = "Flowing Lava",
398         drawtype = "flowingliquid",
399         tiles = {"lava_flow.png"},
400         special_tiles = {
401                 {
402                         name = "lava_flow.png",
403                         backface_culling = false,
404                         animation = {
405                                 type = "vertical_frames",
406                                 aspect_w = 16,
407                                 aspect_h = 16,
408                                 length = 3.3,
409                         },
410                 },
411                 {
412                         name = "lava_flow.png",
413                         backface_culling = true,
414                         animation = {
415                                 type = "vertical_frames",
416                                 aspect_w = 16,
417                                 aspect_h = 16,
418                                 length = 3.3,
419                         },
420                 },
421         },
422         selection_box = {
423             type = "fixed",
424             fixed = {
425                 {0, 0, 0, 0, 0, 0},
426             },
427         },
428         paramtype = "light",
429         paramtype2 = "flowingliquid",
430         light_source = 13,
431         walkable = false,
432         pointable = false,
433         diggable = false,
434         buildable_to = true,
435         is_ground_content = false,
436         drop = "",
437         drowning = 1,
438         liquidtype = "flowing",
439         liquid_alternative_flowing = "main:lavaflow",
440         liquid_alternative_source = "main:lava",
441         liquid_viscosity = 7,
442         liquid_renewable = false,
443         damage_per_second = 2,
444         post_effect_color = {a = 191, r = 255, g = 64, b = 0},
445         groups = {lava = 3, liquid = 2, igniter = 1},
446 })
447
448 minetest.register_node("main:ladder", {
449         description = "Ladder",
450         drawtype = "signlike",
451         tiles = {"ladder.png"},
452         inventory_image = "ladder.png",
453         wield_image = "ladder.png",
454         paramtype = "light",
455         paramtype2 = "wallmounted",
456         sunlight_propagates = true,
457         walkable = false,
458         climbable = true,
459         is_ground_content = false,
460         node_placement_prediction = "",
461         selection_box = {
462                 type = "wallmounted",
463                 --wall_top = = <default>
464                 --wall_bottom = = <default>
465                 --wall_side = = <default>
466         },
467         groups = {wood = 1, flammable = 1, attached_node=1},
468         sounds = main.woodSound(),
469         on_place = function(itemstack, placer, pointed_thing)
470                 --copy from torch
471                 if pointed_thing.type ~= "node" then
472                         return itemstack
473                 end
474                 
475                 local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
476
477                 local fakestack = itemstack
478                 local retval = false
479                 if wdir > 1 then
480                         retval = fakestack:set_name("main:ladder")
481                 else
482                         return itemstack
483                 end
484                 
485                 if not retval then
486                         return itemstack
487                 end
488                 
489                 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
490                 
491                 if retval then
492                         minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
493                 end
494                 
495                 print(itemstack, retval)
496                 itemstack:set_name("main:ladder")
497
498                 return itemstack
499         end,
500 })