Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Thu May 30, 2002 2:31 am   

Finishing off this alias
 
Ok, i cant figure out how to go about doing this, but its pretty basic.

#ALIAS test {%1 %replace( "%-2", a, %item( "A|B|C", %random( 1, 3)))}

This will take every occurance of "a" after the %1 to be 'A','B', or 'C'.
The problem is that it considers the whole string at once and replaces all the occurances with the same thing.IE:
test say la la la

will produce:
say lA lA lA
or
say lB lB lB
or
say lC lC lC

I want to make it so it will replace them individually AND randomly, like this:
test say la la la
say lB lA lC
or
say lA lB lA

Anyways, it tried using %replaceitem like this:
#ALIAS test {%1 %replaceitem(%item( "A|B|C", %random( 1, 3)), a, "%-2")}

and even tried putting %string("%-2") in there, and that doesnt work.

Any other ideas?

Oh yeah, and to make it harder(or easier?) I have to keep it pretty simple, preferably in this function format. I can really use a bunch of string variables and such, that would require an entire rewrite of existing script.
Reply with quote
NiteTrip
Novice


Joined: 21 May 2002
Posts: 40
Location: Canada

PostPosted: Thu May 30, 2002 2:45 am   
 
is it letters you will be storing here or words, or what?

look into the %pos function.

a|b|c the letters are all in odd numbered locations, so try writing it to read a random odd number and then print the string in that %pos?

just a suggestion i am in a rush right now else i could help more by giving an example scirpt.
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Thu May 30, 2002 3:04 am   
 
quote:

is it letters you will be storing here or words, or what?

look into the %pos function.

a|b|c the letters are all in odd numbered locations, so try writing it to read a random odd number and then print the string in that %pos?

just a suggestion i am in a rush right now else i could help more by giving an example scirpt.


Hmm, not clear what your getting at.

The premise of the alias is to take each letter and replace it with something else, simular to some of the translators seen here in the forum, except rather than recieve it from the mud, I provide the input, and some of the characters need to be random.

So im not capturing anything, except "%-2", which could be any number of letters in any number of positions... so as I said before, I dont see how %pos would help....
Reply with quote
NiteTrip
Novice


Joined: 21 May 2002
Posts: 40
Location: Canada

PostPosted: Thu May 30, 2002 3:36 am   
 
Ok, i'm sorry but I really don't know what you are talking about, or the use of this script, but alas I am here to try to help, what little help I can give is yours :-)

this alias works:

#alias {test} {#var tempstring %null
#while (%len( @tempstring) < 5) {#additem tempstring %char( 64 + %random( 1, 3))}
say @tempstring}

But really it doesn't require any input, maybe if you can give me what your actually trying to do it would help more...
Reply with quote
NiteTrip
Novice


Joined: 21 May 2002
Posts: 40
Location: Canada

PostPosted: Thu May 30, 2002 3:37 am   
 
Sorry, try this again:

#alias {test} {#var tempstring %null;#while (%len( @tempstring) < 5) {#additem tempstring %char( 64 + %random( 1, 3))};say @tempstring}
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Thu May 30, 2002 3:51 am   
 
Trying to think how to jam the concept into function format

An alias concept would be something like
#VAR bleah ""


#LOOP [%len("%-2")] {
#VAR bleah %concat(@bleah,%replace( %copy("%-2",%i,1), a, %item( "A|B|C", %random( 1, 3))))
}

@bleah

How to go through every element while/loop/etc and return your string would still need
to be addressed.

TonDiening
Beta Upgrading to 6.26
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu May 30, 2002 3:55 am   
 
If you really want us to understand what you re seeking to do provide a list of sample inputs and outputs in a format like...

the quick brown fox jumped over a sleeping dog
thD quick brown fox jumpGd ovTr a slOXping dog

Then more examples...cause anything anyone writes when they don't know what it is supposed to do will be useless.
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Thu May 30, 2002 3:50 pm   
 
Its pretty straight forward, and I thought I explained it pretty well, but here, ill give it another shot, using my actualy script:

Its an L337 Speak Generator!!!!

the current script look like this:
#ALIAS {leetspk} {%1 %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( "%-2", z, %item( "z|Z", %random( 1, 2))), y, %item( "y|Y|¥", %random( 1, 3))), x, %item( "x|X|×|¤|(><)|(}{)", %random( 1, 6))), w, %item( "w|W|(^/)", %random( 1, 2))), v, %item( "v|V|(/)", %random( 1, 3))), u, %item( "u|U", %random( 1, 2))), t, %item( "t|T|+|7", %random( 1, 4))), s, %item( "s|S|z|$|§|5", %random( 1, 6))), r, %item( "r|R|®", %random( 1, 3))), q, %item( "q|Q|¶", %random( 1, 3))), p, %item( "p|P", %random( 1, 2))), o, %item( "o|O|0|ø|*|º|Ø", %random( 1, 7))), n, %item( "n|N|(||)", %random( 1, 3))), m, %item( "m|M|(['V])|(|/|)", %random( 1, 4))), l, %item( "l|L|!|(|_)", %random( 1, 4))), k, %item( "k|K|(]<)", %random( 1, 3))), j, %item( "j|J", %random( 1, 2))), i, %item( "i|I|¡", %random( 1, 3))), h, %item( "h|H|(]=[)|(|-|)", %random( 1, 4))), g, %item( "g|G", %random( 1, 2))), f, %item( "f|F", %random( 1, 2))), e, %item( "e|E|3", %random( 1, 3))), d, %item( "d|D|Ð", %random( 1, 3))), c, %item( "c|C|ç|Ç|¢|©", %random( 1, 6))), b, %item( "b|B|þ|ß", %random( 1, 4))), a, %item( "a|A|ª|@@", %random( 1, 4)))}


The problem is, when I use it to say something, it randomly chooses the appropriate characters correctly, but only once, and then uses that through out the string.Like this

leetspk grouptell the quick brown fox jumped over a sleeping dog
will output:
grouptell 7He ¶u¡C]< brØwN FØ>< Ju[ V]PeÐ Ø/er @ z!eeP¡NG ÐØG
or
grouptell 7]=[E qU¡cK bRØW|| FØ}{ JU|/|PEÐ ØvER A 5|_EEP¡|| ÐØg

now notice the 'O' and 'N' in those strings remain exactly the same thoughout the string, all instances of 'O' are turned to 'Ø'. What I'm trying to do is make it so that the the first 'O' will be anything, and the second 'O' could be anything else(including the same).
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu May 30, 2002 6:36 pm   
 
If you want each instance of each letter to be considered individually, you need to do it like Ton did. %replace just replaces every instance of that letter in the string. However, since you do this not only with one particular character, but other as well, you could modify it to something like this:

#LOOP %len("%-2") {#IF (%copy("%-2", %i, 1) = "a") {#VAR message %concat(@message, %item( "a|A|ª|@@", %random( 1, 4))};#IF (%copy("%-2", %i, 1) = "b") {#VAR message %concat(@message, %item( "b|B|þ|ß", %random( 1, 4))};etc}

Kjata
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Fri May 31, 2002 3:11 am   
 
Ya missed the ending ) from the #IF statements, but I figured it out. It was kinda difficult to figure out how to get the spaces in there, but I managed.

The problem now is that I cant get '@@' in the variable for 'a'. It will only send one @ instead of 2, and I need because @ is an in-game ESC character for color codes, and the only way to make it literal is by using '@@'.

I have used:
%item( "a|A|ª|@@", %random( 1, 4))
%item( "a|A|ª|(@@)", %random( 1, 4))
%item( "a|A|ª|~@@", %random( 1, 4))
%item( "a|A|ª|~(@@)", %random( 1, 4))
%item( "a|A|ª|(~@@)", %random( 1, 4))
%item( "a|A|ª|~~(@@)", %random( 1, 4))

blahblahblah, you get the idea, pretty much ever combo i could think of.Also tried to call the variable with %literal and %quote with no success. I might just dump it, but if anyone can figure it out, please post :)

And thanks for all the help guys, this one will go on the finished scripts forum once im done with it :)
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Fri May 31, 2002 2:56 pm   
 
I have no such problem when I test it myself using:
%item( "a|A|ª|@@", %random( 1, 4))

That's strange...

Kjata
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri May 31, 2002 11:08 pm   
 
On the subject of the @@ thing. The %item does it correctly, and the #VAR does it correctly too. The problem appears to be when you try to get information out of it. The odd solution that I tested and seems to work with the least code alteration is...
change the @@ to @@~~
change @message in whatever line you actually send it to %replace(@message,"~~","").

If that isn't clear just tell me, if you want to know why it works then just give a holler.
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Sat Jun 01, 2002 3:02 am   
 
quote:

On the subject of the @@ thing. The %item does it correctly, and the #VAR does it correctly too. The problem appears to be when you try to get information out of it. The odd solution that I tested and seems to work with the least code alteration is...
change the @@ to @@~~
change @message in whatever line you actually send it to %replace(@message,"~~","").

If that isn't clear just tell me, if you want to know why it works then just give a holler.





Yeah, its rather odd, because I was noticing that it would work right if followed by the '[' character also. IE:
If the string it converted was 'am', and on the random chance it chose '@@' for 'a', and '[ V]' or '|v|' for the 'm' it would output correctly. But if it chose '@@' and anything else for 'm'(m|M) it would fail.

My conclusion was that you have to precede the @@ characters with characters that wont go in a variables name? otherwise the script parser believes it to be a variable? Is that right?

Unforunately, now when on of those 'non-standard' characters([,|) follows the @@~~, and using the %replace correctly, it outputs like this:

test grouptell am am am am am

outputs:
grouptell AM @@~"M @@~"m ªM @@~"V

grouptell @@~m @@~M aV am Am

grouptell ªm @@~|v| am Am aV

grouptell @@~M @@~m @@~m Am @@~|v|


Hmmm, upon looking at it closer it appears that it doesn't matter what its preceded by with the %replace. the script calling it is reall simple. Within the same alias making the replacements:

#LOOP [%len( "%-2")] {
#IF (%copy( "%-2", %i, 1) = " ") {#VAR message %concat( @message, " ")}
#IF (%copy( "%-2", %i, 1) = "a") {#VAR message %concat( @message, %item( "a|A|ª|(@@~~)", %random( 1, 4)))}
#IF (%copy( "%-2", %i, 1) = "m") {#VAR message %concat( @message, %item( "m|M|()|(|v|)", %random( 1, 4)))}
}
%1 %replace( @message, "~~", "")
#VAR message {}


????

I tried combos of different numbers of tildes, and taking out the brackets for @@ works the same. If I use @@~ it doesnt process at all that I can see(didnt run though the debugger, im sure something is happening, but there is no output).
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Jun 01, 2002 5:15 am   
 
Egads! You have so many special characters all over the place no wonder it is having problems.

My solution of @@~~ worked only because it was a bug in how zMud parses things. Literally I was using a bug to overcome another bug, but with more special charaacters in the way your going to have to do things right. The only solution that will work is to have every usage encapsulated with %expand. To be perfectly clear, you will have to change every "@message" to "%expand(@message,1)". My testing yeilded no other way, and I can't even be sure that will work.
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Sat Jun 01, 2002 5:04 pm   
 
Whew. As far as I can tell, the %expand 's are doing it right

Thanks A lot for your help Vijilante!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net