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
Anyone can try this?
Re: Anyone can try this?
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.
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.
-
- Posts: 154
- Joined: Sun Jul 29, 2012 6:50 am
Re: Anyone can try this?
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("k gi")</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>
<name>Giths</name>
<script>send("k gi")</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?
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?
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?
-
- Posts: 154
- Joined: Sun Jul 29, 2012 6:50 am
Re: Anyone can try this?
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
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?
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.
-
- Posts: 154
- Joined: Sun Jul 29, 2012 6:50 am
Re: Anyone can try this?
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?
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.