Beginner-ish question.

Posted by Bayle on Thu 12 Nov 2009 11:06 PM — 4 posts, 21,621 views.

#0
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!
#1
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.
Amended on Fri 13 Nov 2009 12:42 AM by Blainer
#2
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.
Australia Forum Administrator #3
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.