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 ➜ Multi command alias (god wars 2)

Multi command alias (god wars 2)

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


Posted by Jesse P Bunker   (2 posts)  Bio
Date Tue 13 Sep 2022 09:48 PM (UTC)
Message
I am trying to make an alias that places an r before every letter, for example:

typing 'ra' returns
ra
typing 'rabc' returns
ra
rb
rc

I know very little about scripting, but could inputting this function into a script potentially help me? I am in way over my head. =)

Quote:

function string.insert(str1, str2, pos)
return str1:sub(1,pos)..str2..str1:sub(pos+1)
end
Top

Posted by AdInfinitum   (74 posts)  Bio
Date Reply #1 on Thu 15 Sep 2022 05:02 PM (UTC)
Message
Jesse P Bunker said:

I am trying to make an alias that places an r before every letter, for example:

typing 'ra' returns
ra
typing 'rabc' returns
ra
rb
rc

I know very little about scripting, but could inputting this function into a script potentially help me? I am in way over my head. =)

Quote:

function string.insert(str1, str2, pos)
return str1:sub(1,pos)..str2..str1:sub(pos+1)
end



Not sure what scripting language you are used to, but this is how I would go about it in Lua:


local str = "%1"

for letter in str:gmatch("%w") do
   Send("r" .. letter)
end


This is, of course, provided your alias is 'r*'. Be mindful, though, as this will fire on any command that starts with 'r'. You may consider using a different, unique alias, such as: sendr*.
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.


4,054 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.