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