Documentation › Lua

Spells and Npc

Spells gives the spells' data and their cooldown. Npc buys and sells in the open trade window.

Spells#

The data comes from the bot's spell list. The cooldown comes from the cooldown notices the server sends after each spell: until you use the spell once, it shows as ready.

Spells.getIdByWords(words)#

Spells.getIdByWords(words) → number

Spell id by its words. Returns -1 if it does not exist.

lua
local id = Spells.getIdByWords("exura vita")

Spells.getIdByName(name)#

Spells.getIdByName(name) → number

Spell id by its name. Returns -1 if it does not exist.

lua
local id = Spells.getIdByName("Ultimate Healing")

Spells.getDataById(id)#

Spells.getDataById(id) → table or nil

The spell's data:

FieldDescription
id, name, wordsId, name and words
primaryGroupGroup, as in Enums.SpellGroups
secondaryGroupAlways 0
vocationsList of vocations that use the spell
mana, level, cooldown, iconMana, minimum level, cooldown in ms and icon (extras)
lua
local s = Spells.getDataById(Spells.getIdByWords("exura vita"))
if s then print(s.name, s.mana, s.cooldown) end

Spells.isInCooldown(id)#

Spells.isInCooldown(id) → boolean

Whether the spell is on cooldown.

lua
local id = Spells.getIdByWords("exori gran")
if not Spells.isInCooldown(id) then Game.talk("exori gran") end

Spells.getLeftCooldownTime(id)#

Spells.getLeftCooldownTime(id) → number

Milliseconds until the spell is ready. Returns -1 when it is already ready or the time is unknown.

lua
print(Spells.getLeftCooldownTime(Spells.getIdByWords("utani hur")))

Spells.groupIsInCooldown(group)#

Spells.groupIsInCooldown(group) → boolean

Whether the spell group is on cooldown.

lua
if not Spells.groupIsInCooldown(Enums.SpellGroups.SPELLGROUP_HEALING) then Game.talk("exura") end

Spells.getLeftGroupCooldownTime(group)#

Spells.getLeftGroupCooldownTime(group) → number

Milliseconds until the group is ready, or -1.

lua
print(Spells.getLeftGroupCooldownTime(Enums.SpellGroups.SPELLGROUP_ATTACK))

Npc#

These work with the NPC's trade window open. To know whether it is open, use Client.isTradeShopOpen().

Npc.buy(itemId, count, ignoreCap, inBackpacks)#

Npc.buy(itemId, count, ignoreCap, inBackpacks) → true

ParameterTypeDescription
itemIdnumberItem to buy
countnumber, optionalDefault 1
ignoreCapboolean, optionalBuys even without cap (default false)
inBackpacksboolean, optionalBuys inside backpacks (default false)
lua
Game.talk("hi") wait(1000) Game.talk("trade") wait(1500)
if Client.isTradeShopOpen() then Npc.buy(268, 100) end

Npc.sell(itemId, count, ignoreEquipped)#

Npc.sell(itemId, count, ignoreEquipped) → true

ParameterTypeDescription
itemIdnumberItem to sell
countnumber, optionalDefault 1
ignoreEquippedboolean, optionalDoes not sell what is equipped (default true)
lua
Npc.sell(3357, 1) -- 3357 = plate armor