Rename many items with misleading technical names
[minetest_hades/hades_revisited.git] / mods / staffgaia / init.lua
blob372ccb616f5c9a97ca4e06351ba4279731954a02
1 -- WTPFL Licenses
2 staffgaia = {}
4 local conv = function(pos)
5 local nodename = minetest.get_node(pos).name
6 if nodename == "default:ash" or nodename == "default:fertile_sand" or nodename == "default:stone_baked" or nodename == "default:stone" or nodename == "default:cobble" or nodename == "default:mossystone" or nodename == "default:tuff" or nodename == "default:tuff_baked" or nodename == "default:mossytuff" or nodename == "default:mossycobble" then
7 -- minetest.remove_node(pos)
8 minetest.set_node(pos, {name="default:dirt"})
9 minetest.check_for_falling(pos)
10 end
11 end
13 cotrig = function(pos)
14 for dx=-4,4 do
15 for dz=-4,4 do
16 for dy=1,-1,-1 do
17 pos.x = pos.x+dx
18 pos.y = pos.y+dy
19 pos.z = pos.z+dz
21 if math.abs(dx)<4 and math.abs(dy)<1 and math.abs(dz)<4 then
22 conv(pos)
23 end
24 pos.x = pos.x-dx
25 pos.y = pos.y-dy
26 pos.z = pos.z-dz
27 end
28 end
29 end
30 end
32 function staffgaia.staff_on_use(itemstack, user, pointed_thing, uses)
33 local pt = pointed_thing
34 -- check if pointing at a node
35 if not pt then
36 return
37 end
38 if pt.type ~= "node" then
39 return
40 end
43 local under = minetest.get_node(pt.under)
44 local p = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z}
45 local above = minetest.get_node(p)
48 -- return if any of the nodes is not registered
49 if not minetest.registered_nodes[under.name] then
50 return
51 end
52 if not minetest.registered_nodes[above.name] then
53 return
54 end
57 -- check if the node above the pointed thing is air
58 if above.name ~= "air" then
59 return
60 end
63 cotrig(pt.under)
64 if not minetest.settings:get_bool("creative_mode") then
65 itemstack:add_wear(65535/(uses-1))
66 end
67 return itemstack
68 end
70 minetest.register_tool("staffgaia:staff", {
71 description = "Staff of Gaia",
72 inventory_image = "staff_of_gaia.png",
75 on_use = function(itemstack, user, pointed_thing)
76 return staffgaia.staff_on_use(itemstack, user, pointed_thing, 99)
77 end,
80 minetest.register_craftitem("staffgaia:head", {
81 description = "Head of the Staff of Gaia",
82 inventory_image = "staffgaia_head.png",
85 minetest.register_craftitem("staffgaia:shaft", {
86 description = "Shaft of the Staff of Gaia",
87 inventory_image = "staffgaia_shaft.png",
90 minetest.register_craft({
91 output = "staffgaia:head",
92 recipe = {
93 {"default:sapphire", "default:mese_crystal", "default:sapphire"},
94 {"default:mese_crystal", "default:diamond", "default:mese_crystal"},
95 {"default:emerald", "default:mese_crystal", "default:emerald"},
99 minetest.register_craft({
100 output = "staffgaia:shaft",
101 recipe = {
102 {"", "default:ruby", ""},
103 {"", "default:ruby", ""},
104 {"", "default:tree", ""},
107 minetest.register_craft({
108 output = "staffgaia:staff",
109 recipe = {
110 {"", "staffgaia:head", ""},
111 {"", "staffgaia:shaft", ""},