Page 1 of 1

Anyone can try this?

Posted: Sat Sep 30, 2017 1:00 am
by noblestone
I have thousands of mobs handed over to me in xml file from someone using cmud.

Code is:

<trigger priority="26300">
<pattern>This large Earth Elemental looks enraged</pattern>
<value>kill elemental!</value>
</trigger>

What is the easiest way to convert them into mudlet code in xml and import? It is already tendious feeding one by one. Thanks

Re: Anyone can try this?

Posted: Sat Sep 30, 2017 12:07 pm
by Jor'Mox
So, I would just use a simple find/replace like this:
Pattern: <trigger [^>]+>\n<pattern>([^<]+)</pattern>\n<value>([^<]+)</value>\n</trigger>
Replacement: permSubstringTrigger("\1","From CMud",{"\1"},[[send("\2")]])

I ran that in TextWrangler and got exactly the replacement I would want out of it. Then you could just copy/paste the whole thing into a script, run it once (by saving the script), then delete the script, with all the triggers made for you. Depending on what you were using to do the find/replace operation, you might have to tweak things a bit, but it shouldn't be too hard.

Re: Anyone can try this?

Posted: Mon Oct 02, 2017 7:41 pm
by noblestone
Still doesnt make sense to me, I am talking about in text writer, the export from triggers looks like below, how to convert above to below?

<name>Giths</name>
<script>send(&quot;k gi&quot;)</script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList>
<string>A githyanki works at subterfuge</string>
</regexCodeList>
<regexCodePropertyList>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
</regexCodePropertyList>
</Trigger>
</TriggerPackage>

Re: Anyone can try this?

Posted: Mon Oct 02, 2017 9:03 pm
by Jor'Mox
Well, I'm sure you could do that, but it seems like that would be a lot more work than just turning it into something you could copy/paste into a blank script in Mudlet, rather than importing via an XML. Realistically though, doing the replacement for one isn't too different from doing the replacement for the other, there is just MORE, so there is a higher chance that you will make a mistake somewhere.

Edit: I mean, which is easier, writing a single line of code per trigger, or writing a few dozen lines of XML code per trigger?

Re: Anyone can try this?

Posted: Tue Oct 03, 2017 5:31 am
by noblestone
To be sure I am understanding

click triggers, create new one, name is conventer

paste is #1 box Pattern: <trigger [^>]+>\n<pattern>([^<]+)</pattern>\n<value>([^<]+)</value>\n</trigger>

then paste in box below: permSubstringTrigger("\1","From CMud",{"\1"},[[send("\2")]])

Then, how do i run that xml file from cmud, import it? Explain please. Thanks

Re: Anyone can try this?

Posted: Tue Oct 03, 2017 11:18 am
by Jor'Mox
No. You open a find/replace window in a good text editor that can do a grep style find/replace, put the pattern in the "find" box, and the replacement in the "replace" box, and then hit "replace all". Then you copy the results into a blank script in Mudlet, which will then execute the code, making all the triggers for you.

Re: Anyone can try this?

Posted: Tue Oct 03, 2017 11:58 pm
by noblestone
Strange, followed your instruction, using BBEdit, grep clicked, and find / replace prior ur suggestion, hit replace all, kept popping up saying Not Found.

Re: Anyone can try this?

Posted: Wed Oct 04, 2017 1:32 am
by Jor'Mox
Maybe there is something not in the example you have here that is messing up the pattern recognition? I use TextWrangler, which is basically the free version of BBEdit (and I downloaded the trial of BBEdit just to double check), and by copy/pasting your example and my pattern, it found a match.