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