Well, you don't use a trigger, you use a plugin script, and do a regular expression parse (or a straight compare) inside the plugin, along the lines of the example I gave.
I don't think I understand how this works.. say I have this for code:
Quote:
<triggers>
<trigger
enabled="y"
group="echos"
keep_evaluating="y"
match="^(\d+?)h\, (\d+?)m .*?"
regexp="y"
script="echo_health"
sequence="100"
>
</trigger>
</triggers>
SUb Echo_Health (a,b,wildcard)
dim health, mana
health = wildcard(1)
mana = wildcard(2)
World.ColourNote "black", "white", "Health: " & health & " Mana: " & mana
End Sub
Could you explain how I could use the partial-line plugin callback to make this happen before a new-line comes through?
Not directly. Why do that? Do you want to do something with the number in the main world that can't be done in the plugin? What would that be?
If you must, what you could do is make (say) a 1-second timer, that does a GetPluginVariable, thus pulling the number from the plugin, rather than pushing it to the main script.
However my suggestion is to take whatever processing you want to do in your main script file, and move that to a plugin, either the one which does the partial-line plugin callback, or another one.
If you put it into another one the partial-line plugin can do a CallPlugin to tell the other plugin about the new prompt data.
I know plugin variables are meant to be local -
But in this special case it would be nice to pass the information gathered from the prompt like current hitpoints to my main script file...
<![CDATA[
sub OnPluginPartialLine (sText)
Dim regEx, Matches, Match
]]>
Set regEx = New RegExp
regEx.Pattern = "®exp_match;"
<![CDATA[
'
' Execute regular expression
'
Set Matches = regEx.Execute (sText)
'
' Exit if no match
'
if Matches.Count = 0 then
Set regEx = Nothing
Set Matches = Nothing
exit sub
end if
Set Match = Matches.Item (0)
InfoClear
DoPrompt
End Sub
<!-- Script -->
<script>
<![CDATA[
sub OnPluginPartialLine (sText)
Dim regEx, Matches, Match
'
' Make a regular expression to match on the line:
'
'
Set regEx = New RegExp
'
' exit CDATA block so we can use the trigger entity
'
]]>
regEx.Pattern = "®exp_match;"
<![CDATA[
'
' Execute regular expression
'
Set Matches = regEx.Execute (sText)
I hadn't noticed it when I tested, but potentially anything that does extra work for every line received could slow things down.
When you say "similar" is the regular expression more complex?
Try removing parts, like, keep the plugin but make it exit before doing the regular expression.
One problem is that the regular expression is a COM object that is instantiated in every call, that might be slow. If that is the part that is slow, you could put the line:
Set regEx = New RegExp
into global scope (with other relevant changes) so the regular expression object always exists.
Amended on Sat 21 Feb 2004 07:49 AM (UTC) by Johnathan Allen
Message
Using OnPluginPartialLine in an application similar to the second plugin you posted, I get a 'bounce', or a lag in line display. If I uninstall the plugin I'm using, the text I recieve flows smoothly on the screen. If I reinstall it, there seems to be lag generated by the call. I'm using a 900mhz pentium with 512 mb of ram, on win2k pro, with nothing but MUSHclient running (I've got less than 90mb of mem usage) on a 1.5mb cable connection. I'm wondering if anyone else is getting this.
Each plugin executes in its own script space, the main world script space is not available to plugins.
CallPlugin was implemented to let plugin writers write a "utility" plugin that does things that might want to be shared between plugins.
Quote:
So basically, I dont want to just display the value that I get from prompt in my statusbar. I also want to do things with them, so I've made a subroutine that is called by trigger whenever I get the prompt. But it seems I cant call it from the plugin.
My response to that requirement is to simply move the script subroutine into either the plugin I demonstrated below, or, if you want to keep them separate, into another plugin and then use CallPlugin to call it in the other plugin.
You would need to write a second plugin, then the first plugin needs to be modified anyway, to call the second plugin. Then you need to make sure that both plugins are loaded, and in the right order. Then you need to check in the first plugin that the second plugin is in fact there.
Seems simpler to me to just modify the plugin. My second plugin above shows that idea. It calls another subroutine inside the same plugin.
Couldnt you use CallPlugin? (to call something from your world via plugin?)
you can do it between plugins, and I know its been mentioned about using the main world, I just dont remember what you use as a pluginID. Maybe Im just imagining things, but I thought this was doable.
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.