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