Llamar como
Platform.actions.call(fn, ...)
Registra la dependencia Platform.actions.call y luego llámala con ese nombre. Una llamada con espacio de nombres no pasa self: usa una llamada con dos puntos o pasa tú mismo el objeto.
Qué hace
Calls a native API function in protected mode and returns its first result only when Rotation Master can read it. Returns nil with "missing-api" when fn is not a function, "api-error" when the call raises an error, or "restricted-value" when the result is a secret value (Retail and Forever); a successful nil result returns nil with no reason.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
fn | function | nil | Native API function to call; any non-function yields missing-api. |
... | any | Arguments forwarded unchanged to fn. |
Retornos
| 1 | any | First result of fn (possibly nil), or nil on failure. Further results are discarded. |
|---|---|---|
| 2 | string | nil | missing-api, api-error or restricted-value on failure; nil on success. |
Ediciones
Las funciones auxiliares integradas se registran en todas las ediciones. Lo que cambia es la API del juego que leen; donde falta alguna, la función auxiliar recurre a una alternativa o devuelve nil con un motivo.
No lee directamente ninguna API del juego.
Valores secretos (Retail y Forever)
En Retail y Forever, el juego entrega a los addons valores secretos. Esta función auxiliar comprueba lo que lee (addon.Platform:CanReadValue) y, en lugar de un secreto que no puede comparar, devuelve nil con un motivo como restricted-value. Trata nil como no disponible, no como falso.
Cómo la llama el addon
Platform.actions.GetSpellRangeStatehasRange,why=call(nativeShape,id)Platform.actions.findSlotlocal slot,reason=call(FindSpellBookSlotBySpellID,id,pet)
Dependencias
platform(builtin:Platform/actions.lua:platform)
Código fuente
Platform/actions.lua, línea 44. Solo lectura en el juego; Duplicar crea una copia editable.
Platform.actions.call(fn, ...)
if type(fn)~="function" then return nil,"missing-api" end
local ok,value=pcall(fn,...)
if not ok then return nil,"api-error" end
if not platform:CanReadValue(value) then return nil,"restricted-value" end
return value