Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Beginner-ish question.

Beginner-ish question.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Bayle   (5 posts)  Bio
Date Thu 12 Nov 2009 11:06 PM (UTC)
Message
Greetings!

First off, I need to make the warning that I'm pretty much lost when it comes to Mushclient coding (except for simplistic stuff).

That said, I'm trying to make some plugins that will contain various aliases/triggers. All's well and good, but I cannot figure out how to make the plugin items recognize and otherwise manipulate my world variables.

For example, I have a world variable called target.

A plugin alias that should do "bite @target"

But so far, I can't make it see the variable I already have, and I keep hitting a "Variable 'target' is not defined" error.

Basically, I'd just want to know what I need to make my plugin triggers/aliases interact with variables I create in the world. (Use them, change them, etc.)

Many thanks in advance!
Top

Posted by Blainer   (191 posts)  Bio
Date Reply #1 on Fri 13 Nov 2009 12:28 AM (UTC)

Amended on Fri 13 Nov 2009 12:42 AM (UTC) by Blainer

Message
Not sure of the way to get a world variable from a plugin but I never do that. Nick made plugins to not interfere with each other. If I make a plugin with a variable named target and you install it it would override your world variable target.

I have a plugin that uses the world's target variable (or any variable you set) I use Execute to send stuff to the MUD. Then in the world I have an alias that catch's the command and sends it to the MUD with the target variable. Execute from a pluign forces the command to be tested against all the world files aliases just like a command entered from the command line.

In my plugin I have something like:
attack_type = "bite"
Execute("attack_alias " .. attack_type)


In my world file I have the alias:
<aliases>
  <alias
   match="attack_alias *"
   enabled="y"
   expand_variables="y"
   keep_evaluating="n"
   sequence="100"
  >
  <send>%1 @target</send>
  </alias>
</aliases>


So the plugin can do all the processing of which attack command is needed and then execute it. The attack_alias in the world file catches it and sends the attack command and the contents of the target variable to the MUD.

Template:copying For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
Top

Posted by Blainer   (191 posts)  Bio
Date Reply #2 on Fri 13 Nov 2009 12:51 AM (UTC)
Message
If this doesn't give you what you need you might consider putting the variable in the plugin.

You can have an alias / trigger in the plugin that sets or gets the variable. Then you'll have access to it from with in the plugin.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #3 on Fri 13 Nov 2009 02:29 AM (UTC)

Amended on Tue 26 Nov 2013 12:48 AM (UTC) by Nick Gammon

Message
Try looking at my video about making plugins:

How to make a plugin

You can in fact read the main world's variables but you are better off making the plugin self-contained, as Blainer said. If you establish a "target" variable inside the plugin, that same plugin can refer to it. Just don't try to refer to the main world's target variable.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


16,534 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.