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

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

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

Post by Vadi » Fri Apr 08, 2011 11:14 pm

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

Who is online

Users browsing this forum: Google [Bot] and 4 guests