Register forum user name Search FAQ

Gammon Forum

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 ➜ General ➜ but boggled about how to do this

but boggled about how to do this

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by David B   USA  (80 posts)  Bio
Date Thu 17 Jul 2003 07:13 AM (UTC)
Message
I'd like to take make an alias for the IC channel

ic *

Thats easy, I'd like to take the wildcard and replace any vowels with a particular letter.

if i Ic something, it'd replace all the vowels with a letter i choose.

I.E. you ic 'You know I think your right'

becomes:
you ic 'UUU knuw U thunk uuur rught'

Or something to that affect.

I'm not too sure where to start, I know I'll probably have to use the split command, and case to replace the letters, Thats not the hard part, its re-forming the sentence and what not.

If this isn't even possible lemme know.

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #1 on Thu 17 Jul 2003 11:55 AM (UTC)
Message
I can't write the actual code now, but what I will tell you it should be easy. This is only pseudocode

Dim vowels = "aeiou"
Dim intcounter

For intcounter = 1 to len(strword)
if instr(vowels, mid(strword, intcounter, 1)) > 0 then
strstring = strstring & "<the letter you want"
else
strstring = strstring & mid(strword, intcounter, 1)
end if
next

It basically looks at the letters one by one. If a letter is a vowel, it copies another letter in the string. If not, it copies the actual letter.
I don't remember how mid and instr work offhand, you should look them up.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Thu 17 Jul 2003 09:08 PM (UTC)
Message
If you want to replace all vowels with the same letter you could use the replace script function, eg.

str = world.Replace ("str", "a", "u", vbTrue)
str = world.Replace ("str", "e", "u", vbTrue)
str = world.Replace ("str", "i", "u", vbTrue)
str = world.Replace ("str", "o", "u", vbTrue)

This is a bit inefficient, as you are doing it 4 times (you won't need to replace U by itself) however it might not be much slower than doing it in a loop.

My example doesn't preserve capitalisation, you might need another 4 lines for the upper-case letters.

- 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,238 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.