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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Beginner-ish question.

Beginner-ish question.

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


Posted by Bayle   (5 posts)  [Biography] 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!
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] 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.
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] 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
[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.


14,305 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at HostDash]