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