See if your function is running in an alias or a trigger

Post Reply
User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

See if your function is running in an alias or a trigger

Post by Vadi »

Needed a way to see if my function was being called from an alias or a trigger context, came up with this. Not extensively tested yet, and would love better methods:
Code: [show] | [select all] lua
local debug = require "debug"; local t = debug.traceback()

if string.find(t, "Alias", 1, true) then echo("in an alias!")
elseif string.find(t, "Trigger", 1, true) then echo("in a trigger!")
else echo("dunno where.") end

Post Reply