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