Colors

Posted by CanadianChris on Thu 03 Jun 2004 12:57 AM — 8 posts, 27,779 views.

#0
Hi there,

I'm having some trouble setting up a script that has a trigger that is color-sensitive.

Say the trigger is waiting for a blue line, what is the code I use for the trigger?

Thanks :)
#1
I know how to set the trigger colors using the user-interface. But I want to know how to code the actual script for it instead of doing it through MUSH itself.
Australia Forum Administrator #2

One approach is to use ImportXML. This lets you set up things (like triggers) using the XML syntax that is used in the world file. What you could do is set one up using the GUI user-interface, and then copy it to the clipboard. This would give you the format. Then use that function to create additional ones whenever you want.

Another approach is to use SetTriggerOption - this lets you change trigger configurations for the things that are not directly supported by AddTrigger.

USA #3
Youll probably going to end up using the SetTriggerOption, because it sounds like youre using a script to make a trigger, or change the match color, or whatnot.

Via scripting, the XML thing would require a lot of work you dont need.
Australia Forum Administrator #4
A lot of work? Just a single call, to set up the trigger exactly how you want it. Otherwise you have to add it, and then maybe do three or four SetTriggerOption calls to get it exactly right.
USA #5
Its a lot of overhead to importxml via a script, to just change an option.

I guess it depends on whether hes changing his trigger to match on different colors, or if hes making new ones.

I was under the impression he was changing it via script.
Australia Forum Administrator #6
In the debug build of MUSHclient, which is typically about 5 times as slow as the release build, I got this figure importing a fairly complex trigger:


Time taken: ImportXML = 0.000726 seconds.


That is less than 1/1000 th. of a second to import a trigger via ImportXML.

Hang on a tic, I'll check the release build ...


Time taken: ImportXML = 0.000189 seconds.


Yep, about 4 times as fast. So, you could import over 5,000 triggers using ImportXML in under a second. Since I am assuming he will want to do a couple every now and then, I don't think the overhead is a big worry.

Plus, as I said, to do an AddTrigger, followed by four or five SetTriggerOption calls, will probably take as long, due to the overhead of setting up scripting calls inside COM.
USA #7
My point was, if he wasnt adding, merely changing a trigger, as if sometimes he wanted to match on red, and others on blue. Anyway, its moot.

I was talking about scripting overhead, not resources, simply ease in coding. But again, its been covered.