mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-24 17:50:37 +01:00
Added amulets
- Added amulets' API - Added some amulets
This commit is contained in:
parent
ef6f0d3127
commit
01c6adb660
31
mods/runes/amulets.lua
Normal file
31
mods/runes/amulets.lua
Normal file
@ -0,0 +1,31 @@
|
||||
-- Amulets
|
||||
|
||||
runes.functions.register_amulet("snake", "Snake Amulet", 10, 5 )
|
||||
runes.functions.register_amulet("scorpion", "Scorpion Amulet", 5, 7 )
|
||||
runes.functions.register_amulet("cactus", "Cactus Amulet", 5, 10 )
|
||||
runes.functions.register_amulet("eye", "Eye Amulet", 3, 20 )
|
||||
runes.functions.register_amulet("anubis", "Anubis' Amulet", 3, 25 )
|
||||
runes.functions.register_amulet("horus", "Horus' Amulet", 2, 40 )
|
||||
runes.functions.register_amulet("thot", "Thot's Amulet", 2, 45 )
|
||||
runes.functions.register_amulet("osiris", "Osiris' Amulet", 2, 50 )
|
||||
runes.functions.register_amulet("ra", "Ra's Amulet", 1, 100)
|
||||
|
||||
-- Globalstep checking for the amulets
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local inv = player:get_inventory()
|
||||
local basemana = mana.settings.default_max
|
||||
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
|
||||
basemana = basemana + (manadiff * itemcount)
|
||||
end
|
||||
end
|
||||
end
|
||||
if basemana ~= mana.settings.default_max then
|
||||
mana.setmax(player:get_player_name(), basemana)
|
||||
end
|
||||
end
|
||||
end)
|
@ -5,6 +5,7 @@ runes = {}
|
||||
runes.datas = {}
|
||||
runes.datas.handlers = {}
|
||||
runes.datas.items = {}
|
||||
runes.datas.amulets = {}
|
||||
runes.functions = {}
|
||||
|
||||
-- Simple rune register function
|
||||
@ -197,3 +198,15 @@ runes.functions.connect = function(itemname, callback, handler)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Amulets
|
||||
|
||||
runes.functions.register_amulet = function(name, desc, maxcount, manadiff)
|
||||
minetest.register_craftitem("runes:" .. name .. "_amulet", {
|
||||
description = desc,
|
||||
inventory_image = "runes_" .. name .. "_amulet.png",
|
||||
groups = {amulet = 1},
|
||||
stack_max = maxcount,
|
||||
})
|
||||
runes.datas.amulets[name] = manadiff
|
||||
end
|
||||
|
@ -9,7 +9,10 @@ dofile(modpath.."/api.lua")
|
||||
-- Then the rune themselves
|
||||
dofile(modpath.."/registration.lua")
|
||||
|
||||
-- And the handlers
|
||||
-- The handlers
|
||||
dofile(modpath.."/handlers.lua")
|
||||
|
||||
-- The amulets
|
||||
dofile(modpath.."/amulets.lua")
|
||||
|
||||
minetest.log("action","[runes] Mod loaded")
|
||||
|
Loading…
Reference in New Issue
Block a user