mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
I was just curious if there was some way of doing this. So if I typed:

I want to talk backwards.

it will come out:

.sdrawkcab klat ot tnaw I

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
alias reverse {
  • var %i = 1, %len = $len($1-), %text
    while %i <= %len {
    %text = $mid($1-,%i,1) $+ %text
    inc %i
    }
    $iif($isid,return,say) %text
}


//echo -a $reverse(I want to talk backwards.)

Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
How does that work? Do I need the //echo bit as well?

I just tried the alias bit and tried to do:

/reverse Test

And nothing happened, not even a error message.

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
I changed the alias so you can now use /reverse text and it will be sent to the channel.

Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
Thanks, if you don't mind me asking, how did it work the first time?

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
In the first time there was only return instead of $iif($isid,return,say), so the alias could only be used as an identifier ("function") that returns the result to the calling command.

For example, it could be used in an On input script:

On *:input:#:{
  • if /* !iswm $1 && !$ctrlenter {
    say $reverse($1-)
    halt
    }
}


But now it's more flexible. After $reverse() finishes processing the text, an $iif() is deciding what to do with the result - either /return it to the calling command, or /say it directly to the channel. The $iif() condition makes use of $isid, which holds $true when 'reverse' is called as an $identifier, and $false if it was called as a /command.

Joined: Jul 2004
Posts: 4
S
Self-satisified door
Offline
Self-satisified door
S
Joined: Jul 2004
Posts: 4
Can you repost the first way you had it? I'm looking for the same thing, only I want it to automatically reverse it when I say something if I have the option turned on in a menu. I have the option turned on thing down pat, just not sure how I'd have it to recall with $reverse.


Nur der Morgen vermag allein zu sein.
Die Wagenburg lenkt fluchen ein.
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
menu channel {
  • .Reverse text
    ..$style($groupState(#revtext,2,0)) On: .enable #revtext
    ..$style($groupState(#revtext,0,2)) Off: .disable #revtext
}

alias groupState if $group($1) == on { return $2 } | return $3

alias reverse {
  • var %i = 1, %len = $len($1-), %text
    while %i <= %len {
    %text = $mid($1-,%i,1) $+ %text
    inc %i
    }
    $iif($isid,return,say) %text
}

#revtext off
On *:input:#:{
  • if /* !iswm $1 && !$ctrlenter {
    say Reversed: $reverse($1-)
    halt
    }
}
#revtext end

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Edit: Doh, Online beat me to it :P

Last edited by FiberOPtics; 08/08/04 04:50 AM.

Gone.

Link Copied to Clipboard