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