2015-04-27 15:29:47 +02:00
|
|
|
-- Amulets
|
2015-04-29 23:45:14 +02:00
|
|
|
runes.functions.register_amulet("silver_cross", "Silver Cross", 1, 25 )
|
|
|
|
runes.functions.register_amulet("minotaur_eye", "Minotaur Eye", 1, 50 )
|
2015-05-14 23:22:07 +02:00
|
|
|
runes.functions.register_amulet("hellfire", "Hellfire Amulet", 1, 75 )
|
|
|
|
runes.functions.register_amulet("grim_reaper", "Grim Reaper's Amulet", 1, 100)
|
2015-04-27 15:29:47 +02:00
|
|
|
|
2015-04-29 23:45:14 +02:00
|
|
|
-- Recipes
|
|
|
|
minetest.register_craft({
|
2015-04-30 00:13:49 +02:00
|
|
|
output = "runes:silver_cross_amulet",
|
2015-04-29 23:45:14 +02:00
|
|
|
recipe = {
|
|
|
|
{"", "farming:cotton", ""},
|
2016-06-03 21:52:52 +02:00
|
|
|
{"default:silver_ingot", "default:silver_ingot", "default:silver_ingot"},
|
|
|
|
{"", "default:silver_ingot", ""},
|
2015-04-29 23:45:14 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2015-04-30 00:13:49 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "runes:minotaur_eye_amulet",
|
2015-04-29 23:45:14 +02:00
|
|
|
recipe = {
|
|
|
|
{"", "darkage:chain", ""},
|
|
|
|
{"technic:brass_ingot", "mobs:minotaur_eye", "technic:brass_ingot"},
|
|
|
|
{"", "mesecons_materials:glue", ""},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2015-04-30 00:13:49 +02:00
|
|
|
output = "runes:hellfire_amulet",
|
2015-04-29 23:45:14 +02:00
|
|
|
recipe = {
|
|
|
|
{"", "darkage:chain", ""},
|
|
|
|
{"mobs:lava_orb", "default:diamondblock", "mobs:lava_orb"},
|
|
|
|
{"default:obsidian", "bucket:bucket_lava", "default:obsidian"},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2015-04-30 00:13:49 +02:00
|
|
|
output = "runes:grim_reaper_amulet",
|
2015-04-29 23:45:14 +02:00
|
|
|
recipe = {
|
2015-07-15 12:37:33 +02:00
|
|
|
{"", "runes:hellfire_amulet", ""},
|
2015-04-30 00:13:49 +02:00
|
|
|
{"nether:white", "runes:black_magic_block", "nether:white"},
|
2016-06-03 21:52:52 +02:00
|
|
|
{"", "default:mithrilblock", ""},
|
2015-04-29 23:45:14 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2015-04-30 00:13:49 +02:00
|
|
|
output = "runes:black_magic_block",
|
2015-04-29 23:45:14 +02:00
|
|
|
recipe = {
|
2015-07-15 12:37:33 +02:00
|
|
|
{"nether:white", "runes:hellfire_amulet", "default:obsidian"},
|
2015-04-29 23:45:14 +02:00
|
|
|
{"default:nyancat", "nether:tree", "default:mese"},
|
2016-06-03 21:52:52 +02:00
|
|
|
{"default:obsidian", "default:mithrilblock", "nether:white"},
|
2015-04-29 23:45:14 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Nodes
|
2015-04-30 00:13:49 +02:00
|
|
|
minetest.register_node("runes:black_magic_block", {
|
2015-04-29 23:45:14 +02:00
|
|
|
description = "Black Magic Block",
|
2015-04-30 00:13:49 +02:00
|
|
|
tiles = {"runes_black_magic_block.png"},
|
2015-04-29 23:45:14 +02:00
|
|
|
is_ground_content = true,
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
groups = {crumbly=3},
|
|
|
|
sounds = default.node_sound_sand_defaults(),
|
2015-05-14 23:22:07 +02:00
|
|
|
})
|
2015-04-27 15:29:47 +02:00
|
|
|
|
|
|
|
-- Globalstep checking for the amulets
|
2017-04-19 23:58:33 +02:00
|
|
|
tmpdata = {}
|
|
|
|
loop = function()
|
2015-04-27 15:29:47 +02:00
|
|
|
for _, player in pairs(minetest.get_connected_players()) do
|
|
|
|
local inv = player:get_inventory()
|
2017-04-19 23:58:33 +02:00
|
|
|
local pname = player:get_player_name()
|
|
|
|
local basemana = mana.getmax(pname) - (tmpdata[pname] or 0) -- Baseline mana, without any amulets
|
|
|
|
local addons = 0
|
2015-04-27 15:29:47 +02:00
|
|
|
for index, item in pairs(inv:get_list("main")) do
|
|
|
|
local itemname = item:get_name()
|
|
|
|
local itemcount = item:get_count()
|
|
|
|
for name, manadiff in pairs(runes.datas.amulets) do
|
|
|
|
if itemname == "runes:" .. name .. "_amulet" then
|
2017-04-19 23:58:33 +02:00
|
|
|
addons = addons + (manadiff * itemcount)
|
2017-04-24 13:30:31 +02:00
|
|
|
--print("Detected " .. name)
|
2015-04-27 15:29:47 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-04-19 23:58:33 +02:00
|
|
|
mana.setmax(pname, basemana + addons)
|
|
|
|
tmpdata[pname] = addons
|
2015-04-27 15:29:47 +02:00
|
|
|
end
|
2017-04-19 23:58:33 +02:00
|
|
|
minetest.after(1, loop)
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.after(0, loop)
|
2017-04-24 13:30:31 +02:00
|
|
|
|
|
|
|
minetest.register_on_leaveplayer(function(player)
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
mana.setmax(pname, mana.getmax(pname) - tmpdata[pname]) -- Reset
|
|
|
|
tmpdata[pname] = nil
|
|
|
|
mana.save_to_file(pname) -- Double class since we aren't sure mana hasn't already saved (it probably did)
|
|
|
|
end)
|