Gammon Forum
Entire forum
MUSHclient
General
World.Sends processed for aliases?
World.Sends processed for aliases?
|
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Neurowiz
(17 posts) bio
|
Date
| Fri 20 Dec 2002 03:35 AM (UTC) |
Message
| OK, albiet this is probably a strange question, please bear with me.
I need my keypad to be in two modes, normal and Player vs. Player mode.
I've used some of Nick's great ideas and have the following example:
The 0 keypad key sends KP10 (bear with me) to the world. My alias KP* picks it up.
I have a function called keypadAction that does the following:
Sub keypadAction(a,b,c)
Dim key
key = CInt(trim(c(1)))
world.send Keypad(key, currKeypad)
End Sub
OK, so Keypad(x,y) is an array that has the various actions that I want to have happen. So far so good. Here's an example for Keypad 0 (which is the 10th element in my array, hence the KP10)
Keypad(KEY0, NORMAL) = "look"
Keypad(KEY0, PVP) = "actionDsl"
Now comes the nasty bit. If I'm in normal mode, Keypad 0 key will do a "look". If I'm in PVP mode, I *want* the value sent through world.send to be processed as an alias, so that I can set an alias called "actionDSL" and run a script.
Problem is that it won't work. It *seems* as if because I'm running a current alias (KP*) and calling a script, that I can't go ahead and have another alias run... or world.send doesn't run through the aliases. I haven't actually searched for that particular issue, so I guess I should.. but help? In some cases, when I'm in PVP mode, I'm going to need to run scripts based on the keypad key I've pressed, rather than just a simple send to the world... and I want it to be nice and reconfigurable, hence why I don't hardcode things.
Thanks! | top |
|
Posted by
| Magnum
Canada (580 posts) bio
|
Date
| Reply #1 on Fri 20 Dec 2002 05:23 AM (UTC) Amended on Fri 20 Dec 2002 05:27 AM (UTC) by Magnum
|
Message
| Text sent via World.Send (or World.LogSend) is not processed by the alias engine.
You'll have to script some other arrangement to do what you want.
In VBS:
Sub OnKeyPress (AliasName, AliasLine, arrWildcards)
If currKeypad = "1" Then
Keypress_Normal arrWildcards(1)
Else ' Assume currKeypad is "2"
Keypress_PvP arrWildcards(1)
End Sub
Sub Keypress_Normal (Keynumber)
Dim key
key = CInt(Trim(Keynumber))
World.LogSend Keypad(key, currKeypad)
End Sub
Sub Keypress_Pvp (Keynumber)
Dim key
key = CInt(Trim(Keynumber))
'...
End Sub
What you do where the '... line is placed is up to you. You might put the name of the subroutine as a value in your array and then use 'GlobalExecute', or you might use a CASE\IF structure to check the value and call the corresponding script. |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | top |
|
Posted by
| Nick Gammon
Australia (22,990 posts) bio
Forum Administrator |
Date
| Reply #2 on Sun 22 Dec 2002 01:30 AM (UTC) |
Message
| Magnum is right, world.sends aren't processed through alias recognition. I can imagine some rather nasty loops if they were.
eg.
Match on: xyzzy
Alias calls: DoXYZZY
sub DoXYZZY does world.send "xyzzy"
This matches the alias again.
Alias calls the sub again.
And so on indefinitely.
I would do what he suggests - call a sub which tests the PVP mode flag and sends the appropriate thing according to that. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Nick Gammon
Australia (22,990 posts) bio
Forum Administrator |
Date
| Reply #3 on Thu 03 Apr 2003 05:39 AM (UTC) |
Message
|
Quote:
Now comes the nasty bit. If I'm in normal mode, Keypad 0 key will do a "look". If I'm in PVP mode, I *want* the value sent through world.send to be processed as an alias, so that I can set an alias called "actionDSL" and run a script.
See new script command: world.Execute
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
13,150 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
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.