Lua bindings for magic
Based on the work made by @bharbich in !2765 (closed).
For now I don't add bindings for active magic effects.
A few usage examples:
-- print available spells
local mySpells = types.Actor.spells(self)
for _, spell in pairs(mySpells) do print(spell.id) end
-- print available spells (equivalent)
local mySpells = types.Actor.spells(self)
for i = 1, #mySpells do print(mySpells[i].id) end
-- add ALL spells that exist in the world
local mySpells = types.Actor.spells(self)
for _, spell in pairs(core.magic.spells) do
if spell.type == core.magic.SPELL_TYPE.Spell then
mySpells:add(spell)
end
end
-- add specific spell
types.Actor.spells(self):add('thunder fist')
-- check specific spell
local mySpells = types.Actor.spells(self)
if mySpells['thunder fist'] then print('I have thunder fist') end