[Home] [Downloads] [Search] [Help/forum]

Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Convert word

Convert word

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

Posted by Khuran   (5 posts)  [Biography] bio
Date Thu 16 Sep 2021 02:59 AM (UTC)

Amended on Thu 16 Sep 2021 04:33 AM (UTC) by Nick Gammon

this is a continuation of this post


your suggestion to use this

conversions = {
[GetPluginVariable ("", "char1")] = GetPluginVariable ("", "char1").."-[1]",
[GetPluginVariable ("", "char2")] = GetPluginVariable ("", "char2").."-[2]"


the output comes out as this with char1=Yinn

Yinn-[1] barely hits a centipede.  ---- line 1
A centipede misses Yinn-[1] with its bite.  ---- line 2

If I wanted the substitution to occur only on instances like line 2 (basically with a <space> in front of the variable, how do I go about it?

I tried this and it did not work.

[ " " .. GetPluginVariable("", "char1")] = " " .. GetPluginVariable("", "char1").. "-[1]"

Thank you

[EDIT] Fixed formatting
[Go to top] top

Posted by Nick Gammon   Australia  (23,001 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 16 Sep 2021 04:35 AM (UTC)
From the page you reference:

 return (string.gsub (s, "%a+", conversions))

The match is on one or more letters and therefore a space will not be part of the match.

Perhaps change it to:

 return (string.gsub (s, " %a+", conversions))

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


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

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]