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
➜ Perlscript
➜ Calling script functions directly
Calling script functions directly
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Somec
(8 posts) Bio
|
Date
| Fri 02 Jan 2004 04:19 AM (UTC) |
Message
| I have a simple perl function which I want to call directly:
sub test {
foreach my $a (@_) {
$world->note("$a");
}
$world->note("done!");
}
$world->note("hello");
This was so that I could see what was being passed to the function.
but, when I called it:
Quote:
/test 1 2 3 test test 34
MUSHClient said there was an error.
After agonizing for a bit and wondering what in my script could be the problem, I tried to put the arguments in quotes:
Quote:
/test "1 2 3 test test 34"
And that worked fine.
So, I want to know...
Am I missing a setting that only allows one argument to scripts?
Is there something I can do to avoid having to quote multiple arguments (like quoting them automatically)?
What is being done with the additional arguments on the line? | Top |
|
Posted by
| Somec
(8 posts) Bio
|
Date
| Reply #1 on Fri 02 Jan 2004 04:36 AM (UTC) |
Message
| Crap, I should've put this in the general forum | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #2 on Fri 02 Jan 2004 05:36 AM (UTC) |
Message
| I see what you mean - however the error message is from PerlScript. I suggest that the script engine must want the arguments quoted. I'm not enough of an expert on Perl to say why. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Somec
(8 posts) Bio
|
Date
| Reply #3 on Fri 02 Jan 2004 05:49 AM (UTC) |
Message
| Well, I'll try it out for a bit more then. Does the client support multiple scripts running from multiple languages? I have the rest of the script working in Perl, and I just need to interface it with MUSHClient somehow.
I could just make the interface in Python or something and have that call the script functions. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #4 on Fri 02 Jan 2004 06:00 AM (UTC) |
Message
| Yes, you can have multiple languages if you put the script into a plugin. Each plugin can be written in a separate language.
However that shouldn't be necessary for your case. Whatever you are interfacing with the script (eg. an alias) can call the script with the arguments quoted as necessary. eg.
Alias match = foo *
Send = myscript_name "%1"
Send to = script
This would let you type "foo a b c d" (which becomes wildcard 1) which is then quoted by the alias and sent to the script. That should work OK. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Somec
(8 posts) Bio
|
Date
| Reply #5 on Fri 02 Jan 2004 06:47 AM (UTC) |
Message
| I had thought of doing that, but decided against it. I need some way to make the commands different from regular mud commands.
For example, I'll need a "save" command, and I can't have that as an alias and send that to the mud. Well, actually, I guess I can... I can just check to see if there are no arguments. But, that would require more aliases, more scripting, etc
Hmm... now that I think about it, that doesn't sound like a bad idea.
If I make an alias for "north" or "n" and have that alias call a script (which then sends north or n to the mud), will the function be called when a speedwalk is in progress? | Top |
|
Posted by
| Somec
(8 posts) Bio
|
Date
| Reply #6 on Fri 02 Jan 2004 07:14 AM (UTC) |
Message
| Ok, I've decided to just make a ".*" alias which sends %1 to the script like you've suggested. This'll make the commands different from regular mud commands. I'll just have to make a function which will call the appropriate functions.
The question on speedwalking still stands though :) I'll get around to testing it at some point, but it would be nice to just know hehe | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #7 on Fri 02 Jan 2004 08:45 AM (UTC) |
Message
| Ah, no. From memory, speedwalk substitution is not sent through the command processor.
If you wanted to do that you could do something like:
world.Execute world.EvaluateSpeedwalk ("ns 4e w") |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Somec
(8 posts) Bio
|
Date
| Reply #8 on Fri 02 Jan 2004 09:16 AM (UTC) |
Message
| Ah! It's ok then, I'll just make my own :) Thanks for the help Nick | 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.
20,649 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top