LuaScript Xojo and Real Studio Plugin

LuaScriptContext.SetError Method (console safe)

Raises a error. Use this function from within a Xojo or Real Studio function that is registered to be exposed to Lua.

SetError(
   message as String)

Parameters

message
The message

Remarks

Dim context as LuaScriptContext
Dim value as Object

context = new LuaScriptContext(lua)

// Lua does not know how many parameters your function has so it will push all its got to the stack,
// your responsible for making sure your get the correct amount of them
if context.ParameterCount <> 2 then
    context.SetError("SetButtonText expects two parameters")
    return 0
end if

if not context.IsObject(1) then
    context.SetError("SetButtonText expects object in first parameter")
    return 0
end if

value = context.GetObject(1,false)

if value isa PushButton then
    PushButton(value).Caption = context.GetString(2,false)
end if

// We always return 1 here to tell Lua that all was good
return 1

See Also

LuaScriptContext Class