| Message |
Gold *and* quest points, eh? Better get started ...
I thought this rang a bell. There is a forum thread about PHP:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=5075
The major problem with the version at the time (in that thread) was that errors in PHP would cause MUSHclient to immediately exit. I guess the script designers thought that making the program exit on error was a good idea.
This seems to be fixed in version 5.1.1.
First thing is, you need 2 downloads from the www.php.net site:
php-5.1.1-Win32.zip
pecl-5.1.1-Win32.zip
The first one has the "core" PHP in it, the second one has the important DLL:
php5activescript.dll
This last file is what MUSHclient needs to register, which has the script engine in it.
What I did was unzipped both files (you need to make a root directory for them, as the archive does not have a "top" directory), eg.
c:\php.5.1.1\
You can probably unzip both archives into the same directory, but at the very least you need to copy php5activescript.dll to be in the same directory as the files from the php-5.1.1-Win32.zip download.
Then you should be able to use the "Register DLL" button in the MUSHclient script window to make it recognise the DLL. Personally I couldn't, so I had to run :
regsvr32 php5activescript.dll
I'm not sure if you will have regsvr32 installed on your PC, if not try to get a copy from the Microsoft site somewhere under developers tools. However only do that if the script engine is still not recognised.
Having done that, you should be able to use PHP from MUSHclient. For a start, try this, in the command window:
/$world->Note ("Hello, world");
Also try:
/$world->Note (phpversion());
You should see 5.1.1 displayed.
Problems with using script file
The major thing I still couldn't get working was calling a script in the script file using the "fill in the script name in the box" method that MUSHclient has always used.
As a test, I had this in my script file:
function f ($alias_name, $alias_output, $wildcards)
{
$world->Note("in f");
$world->Note("name = " . $alias_name);
$world->Note("output = " . $alias_output);
$world->Note("wildcards = " . $wildcards);
}
$world->Note("test.php loaded");
When loading that I see "test.php loaded", so the file was processed OK.
Now if I make an alias:
<aliases>
<alias
name="blah"
script="f"
match="test"
enabled="y"
sequence="100"
>
</alias>
</aliases>
I get the error message "The alias (blah) subroutine named "f" could not be found.".
However, I can call the function manually:
/f (1, 2, 3);
I see:
in f
name = 1
output = 2
wildcards = 3
So, the function exists and can be called. Maybe you have to somehow "export" the function so the script engine can detect it? Don't know how to do that.
However you can work around that by sticking to "send to script", or calling a function in your script file from "send to script", like this:
<aliases>
<alias
match="test"
enabled="y"
send_to="12"
sequence="100"
>
<send>f ("blah", "%0", "%1");</send>
</alias>
</aliases>
This behaviour is not exactly the same as the normal MUSHclient alias function call, as not all 10 wildcards are passed to the function, however you simply script around that.
Having said all that, I would recommend taking a look at Lua as an alternative script engine. In many ways it is similar to use to PHP, and has some nice features. :) |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|