Alias/timer/trigger script callbacks

Posted by Twisol on Sat 13 Feb 2010 04:06 AM — 11 posts, 41,321 views.

USA #0
When calling the function named in the 'script' field of aliases/timers/triggers, would it be possible to send the internal name, regardless of whether it's not named? To be clear, I meant that if you have an unnamed alias, I want to be sent "*alias1234" as the name, not "" (empty string). This is important so I can get at the details/options of the alias that was used, regardless of the status of its name.
USA #1
I'd like this as well. A lot of my triggers/aliases are not named.

Alternatively, I'd be happy if say, the error returned the 'match' and 'sequence' number of a trigger, or alias. This would also help immensely.
USA #2
Agreed.
Netherlands #3
Good idea. Never needed it, but I don't see any harm for plugin compatibility in practice. The chance someone will check for an empty name when handling the trigger script will not be likely to contain specialized handling, only handling for not calling a dozen functions which would obviously not work with an empty name.

However, in cases that people do use the name to radically change the logic of a trigger, I have to both question the sanity of using the same trigger for named and unnamed triggers, as they clearly aren't much alike. As a temporary solution, such scripts should be adjusted to check the first few lines of the script for *alias/*trigger, or maybe a plain * as I don't think it is an allowed character for names anyhow.
#4
hello ;)
USA #5
Worstje said:
However, in cases that people do use the name to radically change the logic of a trigger

It's not so much about treating unnamed triggers differently than treating them all the same, whether they're named or not.

EDIT: In the case that you're talking about other people who check "" - it's not quite clear which you meant - and treat them differently based on that, then I agree.
Amended on Sat 13 Feb 2010 07:08 PM by Twisol
Netherlands #6
I was indeed talking about if-checks like 'if name ~= "" then DoDifferentStuffWithValidName(name) else DoWeirdStuffForUnnamedThingy(name) end' :)
Amended on Sat 13 Feb 2010 08:22 PM by Worstje
USA #7
Right, yeah. Anyone who did that would be crazier than I am.
Australia Forum Administrator #8
It wasn't easy to do, but I have incorporated this suggestion in version 4.50. [commit 2919843]

The main problem was that trigger/alias/timer *pointers* were being passed around, which means that at that stage they are divorced from whatever name they were stored in the map with.

Now every trigger/timer/alias script function should be given a non-empty name, with the first character being "*" if the name was not assigned by a human. This name can be used in GetTriggerInfo, GetTimerInfo, GetAliasInfo.
USA #9
Also GetAliasOption and the like as well, I hope? Both *Option and *Info work this way in the current version, I want to make sure it wasn't changed inadvertently.

(Actually, I imagine that any Alias, Trigger, or Timer function that accepts a name should work as expected, not just the Option/Info ones)


Also: Thanks, Nick!
Australia Forum Administrator #10
I think a while ago all those functions were changed to accept the internal names (so you could use GetAliasList for example).