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.
Entire forum
➜ MUSHclient
➜ Perlscript
➜ Beginning Perl
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| SugarAndTheSun
(7 posts) Bio
|
Date
| Fri 27 Aug 2004 10:21 PM (UTC) |
Message
| I'm beginning Perl and MUSCHclient (I gave up on ZMUD, a shame as I was just deciding to get into advanced scripting, it gave to many issues over my 3 year time I used it) and I could truly use some help. I wrote my Perl script, I saved it with the proper extension, yet when I go to 'plug it in' MUSH can't handle it. I then found out (through a simple question) that MUSH uses its own 'form' of Perl and the other languages. And that's why
>>> print "hello world"
wouldn't work. Made sense. I just figured baby steps. So where can I find a good beginners guide to Perl that is written for MUSH in terms of a forum topic? ALl the online libraries I've found all start with what I did and that won't work and they're obviously not in the form I see for Perl, Python, VB and Java. Sorry if it's a silly question I'm just quite confused and I'd really like to add a few plugins. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #1 on Fri 27 Aug 2004 10:55 PM (UTC) |
Message
| MC doesnt use its own form. It just has its own callbacks. It has its own interface with the script engine, you are still working with stock script engines (which means you can still do everything they can, with some exceptions (things like infinite loops etc).
Your best bet is actually to look at the examplescript (included in MC, in the scripts subdirectory), or look at the "list of inbuilt functions" from the MC main page. (or in the forums, the MC forum, then its at the top). They all include examples for all the languages.
For example, if we were to print hello world (just to the screen, for the user to see, not the server), you would use note:
$world->note("Hello World");
But if you wanted to send it to the server, you'd use the send function instead:
$world->Send("Hello World");
So itll take some familiarity with the things that are availiable to you, but your best bet is to scan over the list of functions (its downloadable, in the updated help file) read up about the ones that you think are pertinant, and look at examples.
Nick: Send function examples, why are your quotes escaped?
|
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| SugarAndTheSun
(7 posts) Bio
|
Date
| Reply #2 on Fri 27 Aug 2004 11:21 PM (UTC) |
Message
| Thanks. I already figured some things out too. Found some more information in the help file. Now I wonder why is it that that
$world->AddAlias("frenzy_target", "ftar", "frenzy rat", $eEnabled, "");
$world->AddAlias("get_target", "gtar", "get rat", $eEnabled, "");
will not create two aliases when I plug them in? It does exactly as the Help files state yet it doesn't seem to work. And my next question will be if the plugin wizard's purpose is just to turn what you currently have into a script for others to plugin?
<aliases>
<alias
script="OnHelp"
match="PerlScript_Version:help"
enabled="y"
>
</alias>
</aliases>
I see that from a script that came with MUSH in perl but that seems like much work and quite organized and I also know it came from the plugin wizard. I'm so confused, gyar. So where does knowing Perl come in handy if what I see is you can't create an alias like the help file states and all these aliases I see in scripts are created by a wizard.
| Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #3 on Sat 28 Aug 2004 12:56 AM (UTC) |
Message
| Most aliases you use will be done through Mushclient, and not perl.
Youll only use perl in scripting, which isnt creating the aliases themselves, but it can be used to enhance what an alias can do (calculations, logic, etc).
The world files (and plugins) are stored in XML, which you can edit in any text editor.
The plugin wizard takes what you have in your world file, and exports it for plugins. Its more of a distribution sort of thing, but there are some things you can do with plugins that you cant normally in the script file (plugin callbacks).
Unlike other clients, you DONT need to have a script which contains all your aliases (you wont use addalias/addtrigger etc very often, unless youre creating dynamic triggers/aliases). You put them in your world, and they stay there. Your script file only does scripting, it doesnt do much to the world. (well, you COULD start fresh and load a script file, but theres not a lot of practical purpose in that).
However, with the addition of "send to script" its become more common that instead of an alias/trigger calling a routine in your script file, you put the subroutine contents in the "send" box, and then "send to" script. It allows for even more modulation (and it makes transporting and plugin creation a lot easier). Which leaves your script file for communal routines, and more complex routines.
Also, if youre just typing those things into the world window, you will need to prepend the script prefix (default is \ I believe). And enable scripting and switch to perl (game > config > scripting).
And then if you check, you should find they are created.
Although, if youre starting off adding things, you might be better off "importing" them (XML) or pasting them via their respective dialogs (triggers/aliases/timers).
Both formats will use XML, but importXML will allow you to paste aliases/triggers/timers at the same time.
Of course, you can also just edit your world file with a text editor. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Shadowfyr
USA (1,788 posts) Bio
|
Date
| Reply #4 on Sat 28 Aug 2004 06:46 PM (UTC) |
Message
| I believe he may also be confused as to what a plugin actually is and what a script is.
Scripts come in four forms-
1. A stand alone 'main' script. This must be pointed to in the scripting options and contains only the script code.
2. Plugin inbedded. This is a script that is found in the <script></script> block of a plugin.
3. Object imbedded. This is a few lines of script in the 'send' field of an alias, trigger or timer, which has the 'send to script' option turned on.
4. Immediate. This is executed in the command window and requires you start the command with the immediate script symbol, which is normally \.
By contrast zMud only supports-
1. Preloaded. Loaded and installed with the world file.
2. Immediate. Sort of like Mushclients, but uses # to designate a script command.
Generally zMud makes no real distinction as to 'which' type it is dealing with. Mushclient has to, since it doesn't understand the language itself, so integration between the client and the script requires a sort of proxy, provided by callbacks and special client commands. This is why some things don't work the same. Loops in zMud would simply execute more or less in parallel to the client, in Mushclient they freeze the client until finished, since the client itself has no way to know when the 'loop' statement is hit and control must be temporarilly returned to the client. Though it would be nice if that did happen.
In any case, I am guessing that when you say you tried to 'plugin' your script you tried to install it in the plugin system. This won't work, since Mushclient plugins are XML files that merely include a script segment. In general, in order to create a plugin, you put your script into the 'main' script under the scripting settings, then create any triggers, aliases, etc. you need in Mushclient. Once you are sure it works right, you use the plugin wizard to generate a file containing selected triggers, aliases and timers along with the segment of script from the main file you need for it.
This is slightly more complicated than zMuds 'everything is a script' concept, but it does allow you to design modular sets of features that anyone else can later plugin to the client without the slightest fuss. It also maintains a more object oriented design for features. Variables and even function that 'could' conflict in zMud can't with a plugin. Much like a seperate object in C++ or VB, each plugin can have the any number of the same named functions, each doing something just for that plugin. Talking to a plugin is a bit harder that to objects though. Though a slightly better method than the callplugin one can be found on these forums. It uses an alias to call fake a call, so you can have things like variable numbers of arguments, etc., which callplugin doesn't allow.
Hope this clears some things up. ;) | Top |
|
Posted by
| Ekerim
Sweden (18 posts) Bio
|
Date
| Reply #6 on Fri 05 Aug 2005 12:44 AM (UTC) Amended on Fri 05 Aug 2005 12:47 AM (UTC) by Ekerim
|
Message
| I realize the topic is old (yes, I can read the timestamps in the thread :) but you guys completely failed to answer this guys first question and now I have the same problem and I coulden't find the answer by searching the forums so I will post it here.
The question was...
> Now I wonder why is it that that
>
> $world->AddAlias("frenzy_target", "ftar", "frenzy rat", $eEnabled, "");
> $world->AddAlias("get_target", "gtar", "get rat", $eEnabled, "");
>
> will not create two aliases when I plug them in? It does exactly as the Help files state yet it doesn't seem to work.
$world->AddAlias() refuses to add ANY alias...it simply doesn't work.
I found the cause of this while scrolling through the example PerlScript that came with the client.
In the script $eEnabled is commented out and I realized that the reason AddAlias() is failing could be because $eEnabled is not defined in the client. I tried adding a 1 instead of $eEnabled and sure enough the alias was added.
It seems $eEnabled is not defined which would in perl be equal to beeing zero.
Soo...just add a 1 and everything should work. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #7 on Fri 05 Aug 2005 05:57 AM (UTC) |
Message
| eEnabled is commented out in the alias and timer definitions because it is a duplicate of the one in the triggers. eEnabled IS defined.
However, when you use it in your client, you probably haven't included the constants, and as such, eEnabled is not defined. The AddAlias function doesn't return anything (or generate an error) if you pass it bad parameters.
eEnabled being 0 wouldn't cause it to be not added, the trigger would simply not be enabled.
We don't mind you digging up old posts (actually, we'd prefer it, provided you're ontopic, if everyone would search before posting, chances are their questions would be answered before having to be asked).
And yes, we didn't address his alias question before, because usually when people come from Z or tintin or whatnot, they're used to having scripts that they run each time and set up their client, mushclient does it differently (with worlds, etc), so they'd be wasting their time having a startup script type thing (and losing the ability to store some things, like variables and stuff, unless their scripts updated themseles). It's more important to address the most likely reason he was adding plain old aliases, and steer him to the 'mushclient way of doing things'. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Ekerim
Sweden (18 posts) Bio
|
Date
| Reply #8 on Fri 05 Aug 2005 11:55 AM (UTC) |
Message
| $world->note( "eEnabled is NOT defined." ) if ( ! defined $eEnabled );
...in my scriptfile says $eEnabled is not defined, that is what I based my theory on :)
How do I include the constants, I had thought they would be automagically defined for me. I haven't found any documentation about how to include the constants, is there a .pm file somewhere I can use ?
Thanks for the answers, hopefully you can tell me how to "include the constants" too :)
Cheers. | 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.
25,771 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top