|
shibbidy joe Wanderer
Joined: 02 Nov 2002 Posts: 76 Location: Tuvalu
|
Posted: Mon Dec 23, 2002 5:44 pm
#WAIT problems |
Let me start by saying that the below script is my brainchild, and has many days of blood, sweat, and tears in it. That said, the problem I'm having is with the #wait command. It's my understanding that #wait causes the script to halt until something is received from the MUD. However, in my script it doesn't wait. It just sends the four commands:
K
A [username ommited]
G GS3
C
This causes much trouble, the script is supposed to encode the key and send it along as:
A [username] [encodedkey]
I've also tried changing the #wait to #wait 2000. No affect. Suggestions and remedies are greatly appriciated... The script follows, with comments inserted in brackets:
#reset
#var pickList {} {} {getChar}
#var szPassword {} {} {getChar}
#var szUsername {} {} {getChar}
#var szKey {} {} {getChar}
#var NewKey {} {} {getChar}
#var a {} {} {getChar}
#var Spacer {} {} {getChar}
#var end {} {} {getChar}
#var charLine {} {} {getChar}
#var howMany {} {} {getChar}
#var charID {} {} {getChar}
#var sessionID {} {} {getChar}
#var currentItem {} {} {getChar}
#trig {GAMEPORT=%d KEY=(&32)} {
#disconnect
#prompt sessionID {Enter your Gemstone III session ID}
#session {@{sessionID}}
%clip( %1)
#mess {Your login key has been copied to the clipboard.}
} {getChar}
#trig {(C%char( 9)?%char( 9)?%char( 9)?%char( 9)?%char( 9))(W_%upper( @{szUsername})_)???%s%w( %x)} {
#var charLine {%line}
#var charLine {%replace( @{charLine}, %1)}
#var charLine {%replace( @{charLine}, %2)}
#var charLine {%replace( @{charLine}, %3)}
#var charLine {%replace( @{charLine}, %d)}
#var charLine {%replace( @{charLine}, %char( 9), ~|)}
#var charLine {%replace( @{charLine}, %s)}
}
#PROMPT szUsername {Enter your username}
#PROMPT szPassword {Enter your password}
K
#WAIT [Here the MUD is supposed to return a 32 character key]
#VAR szKey {%quote( %copy( %line, 1, %len( @{szPassword})))} ""
#VAR a 1
#UNTIL (@{a} > %len( @{szPassword})) {
#ADD NewKey (%char( %bitxor( %ascii( %copy( @{szKey}, @{a}, 1)), %ascii( %copy( @{szPassword}, @{a}, 1))+32)-32))
#ADD A 1
} [Encode the key]
A%char( 9)%upper( @{szUsername})%char( 9)%lower( @{NewKey}) [Send it back]
#WAIT
G%char( 9)GS3
#WAIT
C
#wait
#until (@{howMany} < 1) {
#var currentItem {%item( @{howMany})}
%replace( @{charline}, @{currentItem}, @{currentItem}~:~#var pickedChar ~{~@currentItem~})
#ADD howMany -1
}
#var charLine {%replace( @{charline}, ~|, ~}~{)}
#pick {@charLine}
#var CharID {L%char( 9)W_%upper( @{szUsername})_@{pickedChar}%char( 9)PLAY}
#var howMany {%numitems( @{charLine})}
#t- getChar
-Shibbidy Joe.
This script was written for Simutronics' GemStone III, and will probably be deprecated before February 1 of next year. Oh well...
Edited for typos and clarity |
|
|
|
Darker GURU
Joined: 24 Sep 2000 Posts: 1237 Location: USA
|
Posted: Mon Dec 23, 2002 6:23 pm |
You should actually try to avoid #wait. Multiple #waits in a script actually cancel each other out, which is probably the issue you're having.
State triggers seem the answer to what you're after - they're in 6.40. You'd have to split this script into several smaller sections for that to work, but I think it'd be more reliable that what you've got.
Sorry I don't have examples - I don't have zMUD handy to test with from work. The help files should explain it enough to get you on the right path though.
zMUD 6 Online Help: All the power you'll ever need. |
|
|
|
Dedoleo Newbie
Joined: 23 Dec 2002 Posts: 2 Location: USA
|
Posted: Mon Dec 23, 2002 9:50 pm |
Why will this game be deprecated before February 1 of next year?
I have just started playing Gemstone III. A friend of mine worked very hard on getting zMud to connect, however it is inelegant.
Your connection script seems much more elegant, but I do not see how it works. How does it work? Also, do you have information regarding interpretation of the wizard codes?
"-Shibbidy Joe.
This script was written for Simutronics' GemStone III, and will probably be deprecated before February 1 of next year. Oh well..." |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Mon Dec 23, 2002 10:08 pm |
No, the script will be deprecated. Zugg's plan are to add native zMUD support for Simutronic games in January.
Kjata |
|
|
|
shibbidy joe Wanderer
Joined: 02 Nov 2002 Posts: 76 Location: Tuvalu
|
Posted: Tue Dec 24, 2002 2:00 am |
The game won't be deprecated, the script will. Zugg is creating a version of zMUD that will incorporate simutronics support with it. As to how the script works... That's where it gets tricky. You connect to medusa.simutronics.com on port 7900, then start the script. It prompts for a username and password. Then it sends to the game the command K, and the game returns a thirty two character key. Then the script trims off the end of the key until it's the length of the password (Say the password is 10 chars, it gets rid of the right 22 chars in the key, making the key 10 chars.):
#VAR szKey {%quote( %copy( %line, 1, %len( @{szPassword})))} ""
Then it encodes the key using some crazy formula simutronics derived:
#VAR a 1
#UNTIL (@{a} > %len( @{szPassword})) {
#ADD NewKey (%char( %bitxor( %ascii( %copy( @{szKey}, @{a}, 1)), %ascii( %copy( @{szPassword}, @{a}, 1))+32)-32))
#ADD A 1
}
Then it sends:
A%char(9)[USERNAME]%char(9)[encodedkey]
Note that the %char(9) is a spacing symbol. It's ascii character 9. Also note that the username must be in all caps, and the encoded key must be all lowercase.
The game responds with:
C%char(9)[numchars]%char(9)[numchars]%char(9)0%char(9)0%char(9)W_[USERNAME]_001 [Character's first name] [Character's last name]%char(9)[additional characters]
Note that numchars is how many characters are present, and that for additional characters, the W_etc is repeated, except that the character name is changed (obviously) and the number is incremented in what seems to be binary. (001, 011, etc.) Also note that the nubmers following C could be different for platinum subscriptions or other such things.
The script then gets rid of everything before the W_ section in the front, it gets rid of the W_[USERNAME] section, it gets rid of all numbers, and it gets rid of the last names. Then it replaces the %char(9) with | (the string list separator) thereby turning it into a list. It alters each item in that list so that it's formatted for a picklist, lets the user choose his character, then it sends:
L%char( 9)W_[USERNAME]_[chosen character]%char( 9)PLAY
The game responds by returning the key.
The script coppies that key to the clipboard, opens up a new session to chimera.simutronics.com port 4900 (or whatever session ID you enter) and alerts you that it has coppied the key to the clipboard.
As to the GS commands, Pete has a good compilation of them at www.zinious.com/wizard.
-Shibbidy Joe
If you have further specific questions, post them. Also note that when I wrote this message I realized that the script does not get rid of all last names, just the first one. This will be remedied. Suggestions and comments are always welcome. |
|
|
|
shibbidy joe Wanderer
Joined: 02 Nov 2002 Posts: 76 Location: Tuvalu
|
Posted: Tue Dec 24, 2002 3:54 am |
Ok. I completely redesigned the script. The problem is that the trigger in there matches the K sent at the beginning. I tried changing the trigger from %x to $32. It matched the first three characters. I tried changing it from %x to ???????????????????????????????? (32 question marks). It matched the K again. Anyone know what I'm doing wrong? Here's the script:
szUsername = ""
szPassword = ""
a = ""
szKey = ""
NewKey = ""
szUsername = ""
charLine = ""
howMany = ""
currentItem = ""
pickedChar = ""
sessionID = ""
#PROMPT szUsername {Enter your username}
#PROMPT szPassword {Enter your password}
#trig {????????????????????????????????} {
#VAR szKey {%quote( %copy( %line, 1, %len( @{szPassword})))}
#say @{szKey}
#VAR a 1
#UNTIL (@{a} > %len( @{szPassword})) {
#ADD NewKey (%char( %bitxor( %ascii( %copy( @{szKey}, @{a}, 1)), %ascii( %copy( @{szPassword}, @{a}, 1))+32)-32))
#SAY about to add 1 to a. a is @{a}. szKey is @{szKey}. szPassword is @{szPassword}. NewKey is @{NewKey}.
#ADD A 1
}
A%char( 9)%upper( @{szUsername})%char( 9)%lower( @{NewKey})
}
#cond {} {
G%char( 9)GS3
}
#cond {} {
C
}
#cond {(C%char( 9)?%char( 9)?%char( 9)?%char( 9)?%char( 9))(W_%upper( @{szUsername})_)???%s%w( %x)} {
#var charLine {%line}
#var charLine {%replace( @{charLine}, %1)}
#var charLine {%replace( @{charLine}, %2)}
#var charLine {%replace( @{charLine}, %3)}
#var charLine {%replace( @{charLine}, %d)}
#var charLine {%replace( @{charLine}, %char( 9), ~|)}
#var charLine {%replace( @{charLine}, %s)}
}
#cond {*} {
#until (@{howMany} < 1) {
#var currentItem {%item( @{howMany})}
%replace( @{charline}, @{currentItem}, @{currentItem}~:~#var pickedChar ~{~@currentItem~})
#ADD howMany -1
}
#var charLine {%replace( @{charline}, ~|, ~}~{)}
#pick {@charLine}
#var CharID {L%char( 9)W_%upper( @{szUsername})_@{pickedChar}%char( 9)PLAY}
#var howMany {%numitems( @{charLine})}
}
#cond {GAMEPORT=%d KEY=(&32)} {
#disconnect
#prompt sessionID {Enter your Gemstone III session ID}
#session {@{sessionID}}
%clip( %1)
#mess {Your login key has been copied to the clipboard.}
#t- getchar
}
K
Much thanks,
-Shibbidy Joe |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Tue Dec 24, 2002 6:04 am |
What is the actual text from Gemstone that you are trying to match with %x, or question marks? A series of question marks {?????} with nothing at either end is identical to an *, it'll trigger on anything EXCEPT a blank line. To prevent the trigger from firing on K, you need to use a more specific pattern.
However, you may be able to resolve the problem by simply changing your preferences. If you enter the Preferences window and select Script Parser (or expand Script Parser and select General Parsing) you'll see a checkbox for "Trigger on Commands" near the bottom of the lefthand column. Turn that off, and the problem of firing on the K will probably be solved.
LightBulb
Senior Member |
|
|
|
shibbidy joe Wanderer
Joined: 02 Nov 2002 Posts: 76 Location: Tuvalu
|
Posted: Tue Dec 24, 2002 6:17 am |
I'm trying to stick with the default settings so I can send this script to others. The thing I'm trying to match is a random thirty two character key sent from the server in response to the command K. Usually resembles
KG|GPAbqLy]Nl[GenZXbJRylWO{}rcm]
or
gA[]eYy{x}M~QzsV{KZjhvT}YNDTeL
and changes every time someone connects, as far as I can tell.
-Shibbidy Joe
The two examples I gave I just pulled as from the server. They're actual examples. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Tue Dec 24, 2002 8:30 am |
In that case, check the length.
#TR {(*)} {#IF (%len(%1) < 2) {#NOOP} {the rest of your script}}
Use whatever number/comparison you think will preclude misfiring. Be careful though, there's a lot of special characters in those strings and they could easily mess things up.
LightBulb
Senior Member
Edited by LightBulb to correct typos in trigger. I seem to make those routinely. |
|
|
|
shibbidy joe Wanderer
Joined: 02 Nov 2002 Posts: 76 Location: Tuvalu
|
Posted: Tue Dec 24, 2002 8:08 pm |
Fooled with it for while. Problem I'm having now is that the server sends the key before my computer has time to reset the trigger, so it doesn't catch the fact that the key was sent:
#trig matchKey {(*)} {
#if (%1 =32) {
#VAR szKey {%quote( %copy( %line, 1, %len( @{szPassword})))}
#VAR a 1
#UNTIL (@{a} > %len( @{szPassword})) {
#ADD NewKey (%char( %bitxor( %ascii( %copy( @{szKey}, @{a}, 1)), %ascii( %copy( @{szPassword}, @{a}, 1))+32)-32))
#say adding 1 to A. @{szPassword} @{szKey} @{NewKey}
#ADD A 1
}
A%char( 9)%upper( @{szUsername})%char( 9)%lower( @{NewKey})
} {
#state matchKey 0
}
}
-Shibbidy Joe |
|
|
|
shibbidy joe Wanderer
Joined: 02 Nov 2002 Posts: 76 Location: Tuvalu
|
Posted: Wed Dec 25, 2002 1:40 am |
Fooled with it some more. Here's what I've got:
#trig matchKey {(*)} {
#say matched %1
#if (%len( %1) > 1) {
#VAR szKey {%quote( %copy( %line, 1, %len( @{szPassword})))}
#VAR a 1
#UNTIL (@{a} > %len( @{szPassword})) {
#ADD NewKey (%char( %bitxor( %ascii( %copy( @{szKey}, @{a}, 1)), %ascii( %copy( @{szPassword}, @{a}, 1))+32)-32))
#ADD A 1
}
A%char( 9)%upper( @{szUsername})%char( 9)%lower( @{NewKey})
} {
#say state reseting
#state matchKey 0
}
}
This works sometimes. When it doesn't work, I get something along the lines of:
[This line's a command] K
[This line's a say] matched K
[This line's a say] state reseting
[This line was received] dkweva]ndgHuZAZL[WvBFGD|QAr}ev
[This line's a say] matched dkweva]ndgHuZAZL[WvBFGD|QAr}ev;#if (32
Problem with that is, as you'll notice, it has
;#if (32
at the end, meaning it matched that, along with the key. I don't quite see how it could... Any ideas?
-Shibbidy Joe.
This is taking longer than it should. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Wed Dec 25, 2002 5:21 am |
[This line's a say] matched dkweva]ndgHuZAZL[WvBFGD|QAr}ev;#if (32
Things like that are indicative of mismatched {}'s usually. I warned you special characters can easily mess things up. I'd recommend skipping any #SAY commands, there's no need to introduce extra opportunities for things to go wrong.
LightBulb
Senior Member |
|
|
|
shibbidy joe Wanderer
Joined: 02 Nov 2002 Posts: 76 Location: Tuvalu
|
Posted: Wed Dec 25, 2002 6:59 am |
Ah. That would do it, wouldn't it... I've tried using %quote, but it doesn't seem to be quoting everything as it should. Anyway... that's not the problem I'm facing now. I've gotten to a new step in the creation. Here's the code:
#cond {(C%s?%s?%s?%s?%s)W_%upper( @{szUsername})_???%s%w %x} {
#var charLine {%line}
#say matched
#var charLine {%replace( @charLine, %1)}
#say killed 1. 1 is %1. charline is @{charLine}
#var charLine {%replace( @charLine, W_%upper( @{szUsername}))}
#say killed W upper stuff. charline is @{charLine}
#var a 9
#say vared a
#until (@{a} < 0) {
#var charLine {%replace( @{charLine}, @{a})}
#add a -1
}
#say charline is @{charLine}
}
#cond {} {
#until (@{howMany} < 1) {
#var currentItem {%item( @{howMany})}
%replace( @{charline}, @{currentItem}, @{currentItem}~:~#var pickedChar ~{~@currentItem~})
#ADD howMany -1
}
#var charLine {%replace( @{charline}, ~|, ~}~{)}
#pick {@charLine}
#var CharID {L%char( 9)W_%upper( @{szUsername})_@{pickedChar}%char( 9)PLAY}
#var howMany {%numitems( @{charLine})}
}
Here's what the #cond matches:
C num1 num1 num2 num2 W_USERNAME_001 Firstname Lastname W_USERNAME_011 Firstname2 Lastname2
(All one line)
For instance:
C 2 2 0 0 W_SHIBBIDY_001 Joe Schmoe W_SHIBBIDY_011 John Doe
What I need to do is get rid of the
C num1 num1 num2 num2
(Note the trailing spaces.)
as well as all the
W_USERNAME_000
(Note the trailing spaces. There could be many of the W_USERNAME_000 things, all with different trailing numbers. (001, 011, etc.))
and all the
Lastnames
(Note the leading space)
so that I'm effectively left with first names only. Then I need to put those first names into a picklist, allowing only one selection, and take whatever name is selected in that picklist, putting it into the @pickedChar variable so that it can be acted on accordingly. Ideas?
-Shibbidy Joe
Thanks for all the help so far. It's much appriciated.
Edited for clarity. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Wed Dec 25, 2002 7:53 am |
My usual advice is not to capture things you don't want. That way, you don't have to get rid of them.
#COND {W_%upper( @{szUsername})_???%s(%w) (%x)} {#SAY first name is %1 and last name is %2}
Trying to get more than one per line complicates things though.
#COND {W_%upper( @{szUsername})_???%s%w %x} {#VAR temp1 %trigger;#VAR temp2 %null;#LOOP 1,%numwords(@temp1) {#IF (%begins(%word(@temp, %i), "W_") {#ADDITEM temp2 %word(@temp, %i + 1)};#SAY ~@temp2 has the list of first names}
LightBulb
Senior Member
Just saw your off-topic request on the other thread. I don't do emails. I'm also not familiar with Gemstone. I've looked at its homepage once or twice, but never went any further. I am reasonably familiar with the logic and capabilities of zMUD though. Have you tried doing a search for other threads on Gemstone3 or Simutronics? I have a feeling you're trying to reinvent the wheel. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|