instant hole

master
Izzy 2019-08-17 19:29:16 -06:00
parent 2e1e30374c
commit 4652ee2660
4 changed files with 76 additions and 8 deletions

View File

@ -174,7 +174,7 @@ minetest.register_node("potions:treasure_seed", {
local spawn_treasure = function(pos, node)
print("treasure at " .. dump(pos))
-- print("treasure at " .. dump(pos))
minetest.set_node(pos, {name="air"})
pos.y = pos.y - 5
@ -317,17 +317,17 @@ minetest.register_node("potions:small_chest", {
minetest.register_node("potions:divining_block", {
description = "Divining Block",
tiles = {"default_mese.png"},
tiles = {"default_silver_sandstone_brick.png"},
groups = {crumbly = 3},
sounds = default.node_sound_dirt_defaults(),
on_punch = function(pos, node, player)
if potions.get_manna(player) > 20 then
if potions.get_manna(player) > 50 then
local p = minetest.find_node_near(pos, 50, {"group:divinable"})
print(dump(p))
-- print(dump(p))
if p then
local dx = p.x - pos.x
@ -361,7 +361,7 @@ minetest.register_node("potions:divining_block", {
end
potions.add_manna(player, -20)
potions.add_manna(player, -50)
end
@ -370,3 +370,24 @@ minetest.register_node("potions:divining_block", {
})
minetest.register_craft({
output = 'potions:divining_block',
recipe = {
{'','',''},
{'','group:leaves',''},
{'default:silver_sandstone_block', 'default:silver_sandstone_block', 'default:silver_sandstone_block'},
}
})
minetest.register_craft({
output = 'potions:instant_hole',
recipe = {
{'default:dirt','potions:arcane_book','default:dirt'},
{'', 'default:ladder', ''},
{'', 'default:ladder', ''},
}
})

View File

@ -345,7 +345,7 @@ function potions.register_geode(name, opts)
geode_name = name,
})
print("++++++++ ore registration "..name)
-- print("++++++++ ore registration "..name)
minetest.register_ore({
ore_type = "scatter",
ore = "potions:geode_seed_"..name,
@ -413,12 +413,12 @@ minetest.register_abm({
local yoff = math.min(math.max(-pos.y, 0), 1000) / 1000
local rarity = potions.geodes[name].rarity
print("geode " .. rarity)
-- print("geode " .. rarity)
if math.random(rarity + 10 - math.floor(yoff*10)) > 1 then
minetest.set_node(pos, {name="default:stone"})
return
end
print("growing")
-- print("growing")
local w = math.random(4) == 1

View File

@ -23,6 +23,7 @@ dofile(modpath.."/structures/coffer_dam.lua")
dofile(modpath.."/structures/bridge.lua")
dofile(modpath.."/structures/tunnel.lua")
dofile(modpath.."/structures/island.lua")
dofile(modpath.."/structures/hole.lua")
dofile(modpath.."/util/spiral.lua")
dofile(modpath.."/util/spawn.lua")

46
structures/hole.lua Normal file
View File

@ -0,0 +1,46 @@
local function make_hole(pos, depth)
for d = 0,depth do
local p = {x=pos.x, y=pos.y-d, z=pos.z}
minetest.set_node(p, {name="default:ladder", param2 = 3})
end
end
minetest.register_craftitem("potions:instant_hole", {
description = "Instant Hole",
inventory_image = "default_dirt_with_grass.png",
wield_image = "default_dirt_with_grass.png",
on_use = function(itemstack, player, pointed_thing)
local pos = pointed_thing.under
if not pos then
return
end
local dist = 100 -- vector.distance(pos, pos2)
dist = potions.use_manna(player, dist)
if dist < 2 then
return
end
make_hole(pos, dist)
itemstack:take_item()
return itemstack
end,
})