]> git.lizzy.rs Git - Crafter.git/blob - mods/main/nodes.lua
24eb062dd149d74ce83a8e5bb0035492320ed450
[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
281 minetest.register_node("main:waterflow", {
282         description = "Water Flow",
283         drawtype = "flowingliquid",
284         waving = 3,
285         tiles = {"water_static.png"},
286         special_tiles = {
287                 {
288                         name = "water_flow.png",
289                         backface_culling = false,
290                         animation = {
291                                 type = "vertical_frames",
292                                 aspect_w = 16,
293                                 aspect_h = 16,
294                                 length = 0.5,
295                         },
296                 },
297                 {
298                         name = "water_flow.png",
299                         backface_culling = true,
300                         animation = {
301                                 type = "vertical_frames",
302                                 aspect_w = 16,
303                                 aspect_h = 16,
304                                 length = 0.5,
305                         },
306                 },
307         },
308         alpha = 191,
309         paramtype = "light",
310         paramtype2 = "flowingliquid",
311         walkable = false,
312         pointable = false,
313         diggable = false,
314         buildable_to = true,
315         is_ground_content = false,
316         drop = "",
317         drowning = 1,
318         liquidtype = "flowing",
319         liquid_alternative_flowing = "main:waterflow",
320         liquid_alternative_source = "main:water",
321         liquid_viscosity = 1,
322         post_effect_color = {a = 103, r = 30, g = 60, b = 90},
323         groups = {water = 1, liquid = 1, notInCreative = 1, cools_lava = 1,pathable = 1},
324         --sounds = default.node_sound_water_defaults(),
325 })
326
327 --[[
328
329 minetest.register_node("default:lava_source", {
330         description = S("Lava Source"),
331         drawtype = "liquid",
332         tiles = {
333                 {
334                         name = "default_lava_source_animated.png",
335                         backface_culling = false,
336                         animation = {
337                                 type = "vertical_frames",
338                                 aspect_w = 16,
339                                 aspect_h = 16,
340                                 length = 3.0,
341                         },
342                 },
343                 {
344                         name = "default_lava_source_animated.png",
345                         backface_culling = true,
346                         animation = {
347                                 type = "vertical_frames",
348                                 aspect_w = 16,
349                                 aspect_h = 16,
350                                 length = 3.0,
351                         },
352                 },
353         },
354         paramtype = "light",
355         light_source = default.LIGHT_MAX - 1,
356         walkable = false,
357         pointable = false,
358         diggable = false,
359         buildable_to = true,
360         is_ground_content = false,
361         drop = "",
362         drowning = 1,
363         liquidtype = "source",
364         liquid_alternative_flowing = "default:lava_flowing",
365         liquid_alternative_source = "default:lava_source",
366         liquid_viscosity = 7,
367         liquid_renewable = false,
368         damage_per_second = 4 * 2,
369         post_effect_color = {a = 191, r = 255, g = 64, b = 0},
370         groups = {lava = 3, liquid = 2, igniter = 1},
371 })
372
373 minetest.register_node("default:lava_flowing", {
374         description = S("Flowing Lava"),
375         drawtype = "flowingliquid",
376         tiles = {"default_lava.png"},
377         special_tiles = {
378                 {
379                         name = "default_lava_flowing_animated.png",
380                         backface_culling = false,
381                         animation = {
382                                 type = "vertical_frames",
383                                 aspect_w = 16,
384                                 aspect_h = 16,
385                                 length = 3.3,
386                         },
387                 },
388                 {
389                         name = "default_lava_flowing_animated.png",
390                         backface_culling = true,
391                         animation = {
392                                 type = "vertical_frames",
393                                 aspect_w = 16,
394                                 aspect_h = 16,
395                                 length = 3.3,
396                         },
397                 },
398         },
399         paramtype = "light",
400         paramtype2 = "flowingliquid",
401         light_source = default.LIGHT_MAX - 1,
402         walkable = false,
403         pointable = false,
404         diggable = false,
405         buildable_to = true,
406         is_ground_content = false,
407         drop = "",
408         drowning = 1,
409         liquidtype = "flowing",
410         liquid_alternative_flowing = "default:lava_flowing",
411         liquid_alternative_source = "default:lava_source",
412         liquid_viscosity = 7,
413         liquid_renewable = false,
414         damage_per_second = 4 * 2,
415         post_effect_color = {a = 191, r = 255, g = 64, b = 0},
416         groups = {lava = 3, liquid = 2, igniter = 1,
417                 not_in_creative_inventory = 1},
418 })
419
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 })