40 lines
1002 B
Lua
Raw Normal View History

2014-05-10 09:35:17 -05:00
magic = { }
local magic_file = minetest.get_worldpath().."/magic"
local magicpath = minetest.get_modpath("magic")
magic.player_magic = default.deserialize_from_file(magic_file)
dofile(magicpath.."/api.lua")
function magic.update_magic(player,name)
local s = skills.get_skill(name,SKILL_MAGIC)
2014-05-11 20:49:35 -05:00
local baseAdj = 2
2014-05-10 09:35:17 -05:00
if magic.player_magic[name] ~= nil then
if default.player_get_animation(player) == "lay" then
baseAdj = baseAdj + 3
end
if default.player_get_animation(player) == "sit" then
baseAdj = baseAdj + 1
end
local adj = baseAdj * ( s.level / 10 )
magic.player_magic[name] = magic.player_magic[name] + adj
if magic.player_magic[name] > 20 then
magic.player_magic[name] = 20
end
if magic.player_magic[name] < 0 then
magic.player_magic[name] = 0
end
else
magic.player_magic[name] = 20
end
end
minetest.register_on_shutdown(function()
default.serialize_to_file(magic_file,magic.player_magic)
2014-05-11 20:49:35 -05:00
end)
-- load magic spells
dofile(magicpath.."/thunder.lua")