Wizards of Lua

The Art of Spell Crafting


Spells - Finding Spells

The Spells module provides access to all Spell objects currently loaded.

Here is an overview of the Spells functions:

Function Parameters Results
 find  criteria table

Functions

Below you find short descriptions about each of the functions and some examples about how to use them in your spells.


find (criteria) -> table

The ‘find’ function returns a table of Spell objects that match the given criteria. The criteria is a table of key-value pairs.

The following keys are supported:

Example

Printing the number of all active spells.

found = Spells.find()
print(#found)

Example

Printing the position of the first spell called “welcome”:

found = Spells.find({name="welcome"})[1]
print(found.pos)

Example

Printing the positions of all active spells in a 10-meter range.

found = Spells.find({maxradius=10})
for _,s in pairs(found) do
  print(s.pos)
end

Example

Printing the names of all active spells owned by player “mickkay”.

found = Spells.find({owner="mickkay"})
for _,e in pairs(found) do
  print(e.name)
end