[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Status line from prompt, using new partial-line plugin callback

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Status line from prompt, using new partial-line plugin callback
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 01 Mar 2004 07:48 PM (UTC)  quote  ]
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Gore   (207 posts)  [Biography] bio
Date Mon 01 Mar 2004 04:14 AM (UTC)  quote  ]
Message
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?
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Fri 27 Feb 2004 08:54 PM (UTC)  quote  ]
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Tarbor   (5 posts)  [Biography] bio
Date Fri 27 Feb 2004 09:40 AM (UTC)  quote  ]
Message
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...

Is there any way to accomplish this?
[Go to top] top

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Sun 22 Feb 2004 07:21 AM (UTC)  quote  ]
Message
Thank you.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sun 22 Feb 2004 06:55 AM (UTC)  quote  ]
Message
I meant this... Change this:




sub OnPluginPartialLine (sText)
Dim regEx, Matches, Match

'
' Make a regular expression to match on the line:
'
'  
  Set regEx = New RegExp

...



to



Dim regEx

'
' Make a regular expression to match on the line:
'
'  
  Set regEx = New RegExp

sub OnPluginPartialLine (sText)
Dim  Matches, Match



The line "set regex = New RegExp" is the one I mentioned to "move outside the sub". That is, put that line outside the "sub ... end sub" sequence.

Also, delete the line "set regex = nothing"


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Sun 22 Feb 2004 06:22 AM (UTC)  quote  ]
Message
Like this?


<![CDATA[
sub OnPluginPartialLine (sText)
Dim regEx, Matches, Match
]]>

  Set regEx = New RegExp

  regEx.Pattern = "&regexp_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
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sat 21 Feb 2004 11:05 AM (UTC)  quote  ]
Message
I meant to move it outside the sub, and to remove the line that sets it to nothing.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Sat 21 Feb 2004 08:37 AM (UTC)  quote  ]
Message
Actually, the regex is simpler:

  <!ENTITY regexp_match 
   "^(.*?)\<(.*?)hp (.*?)sp (.*?)st\>(.*?)" 
  >


I have that line you suggested already:

<!--  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 = "&regexp_match;"

<![CDATA[

'
'  Execute regular expression
'

  Set Matches = regEx.Execute (sText)
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sat 21 Feb 2004 08:26 AM (UTC)  quote  ]
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Sat 21 Feb 2004 07:48 AM (UTC)  quote  ]

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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sat 14 Feb 2004 10:15 PM (UTC)  quote  ]
Message
No, CallPlugin calls other plugins.

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.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Sat 14 Feb 2004 09:25 PM (UTC)  quote  ]
Message
Eh, I think you missed my point.
Isnt there something you can make the 'pluginId' field in CallPlugin to call from the main world?

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sat 14 Feb 2004 07:47 PM (UTC)  quote  ]
Message
Yes, you could use CallPlugin, but why bother?

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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Sat 14 Feb 2004 07:57 AM (UTC)  quote  ]
Message
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.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

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.


9,053 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]