GetTriggerWildcard doesn't work with unlabelled triggers (Python)

Posted by Cadari on Sun 06 Jul 2008 03:56 PM — 3 posts, 15,197 views.

#0
Hello. Just as the title says, if the trigger doesn't have a label,

def trigger_proc(name, line, wildcards):
    world.GetTriggerWildcard(name, '1')

GetTriggerWildcard returns None. Lua scripts don't have such a problem, while Python ones do. Any way to make it work without labelling all the triggers?

P.S. I think it's more suited for the General section. Please move, if I'm wrong.
Amended on Sun 06 Jul 2008 03:58 PM by Cadari
Australia Forum Administrator #1
Actually it behaves the same in Lua. The name field on a trigger function is empty, if the trigger name is empty.

To solve your specific problem, simply index into the wildcards array:


def trigger_proc(name, line, wildcards):
    world.Note (wildcards [0])


Other approaches are:

  • Give the triggers a name, if you want to query named wildcards.
  • Use "send to script" and use %1 (or whatever) to have the trigger contents placed inside your script.


#2
Got it, thank you, Nick.