> ## Documentation Index
> Fetch the complete documentation index at: https://docs.selvut.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Wynn Spell

> Use the Wynn and Spell APIs from a script.

Save as `wynn_spell_helper.lua`.

```lua theme={null}
Script.meta({
  name = "Wynn Spell Helper",
  description = "Commands for checking Wynn state and queueing spells."
})

local powderThreshold = Setting.number("Powder Threshold", {
  default = 0.99,
  min = 0,
  max = 1,
  step = 0.01
})

Script.command("wstate", {
  description = "Print current Wynn state"
}, function()
  local health = Wynn.health()
  local mana = Wynn.mana()
  Chat.log("Class: " .. tostring(Wynn.class() or "unknown"))
  Chat.log("HP: " .. tostring(health and health.current or "?") .. "/" .. tostring(health and health.max or "?"))
  Chat.log("Mana: " .. tostring(mana and mana.current or "?") .. "/" .. tostring(mana and mana.max or "?"))
end)

Script.command("spellname", {
  description = "Print the detected spell name for a slot",
  usage = "spellname <slot>",
  parameters = {
    { name = "slot", type = "int", required = true }
  }
}, function(args, slot)
  Chat.log(Spell.name(slot) or "unknown")
end)

Script.command("combo", {
  description = "Queue a spell and a melee after it finishes",
  usage = "combo <spell>",
  parameters = {
    { name = "spell", type = "string", required = true }
  }
}, function(args, spell)
  Async.run(function()
    if not Spell.castAndWait(spell, { timeoutMs = 1500 }) then
      Chat.log("Could not cast " .. spell)
      return
    end
    Spell.meleeAndWait({ timeoutMs = 750 })
  end)
end)

Script.on("tick", function()
  if not Script.throttle("powder", 1000) then return end
  if Wynn.powderReady(powderThreshold.get()) then
    Chat.log("Powder special ready")
  end
end)
```

Waiting APIs run from `Async.run(...)` or another background callback, not directly from a client-thread event.
