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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Make postings easier to read with [code] tags

Make postings easier to read with [code] tags

This subject is now closed.     [Refresh] Refresh page


Posted by Nick Gammon   Australia  (23,006 posts)  [Biography] bio   Forum Administrator
Date Wed 19 Aug 2009 09:25 PM (UTC)

Amended on Thu 20 Aug 2009 12:31 AM (UTC) by Nick Gammon

Message
If you are posting script (or C) code, or triggers, aliases or timers copied from MUSHclient, it is much more readable if you use the [code] ... [/code] tags around it. For example, without the tags:



function mytrigger (name, line, wildcards)
if wildcards [1] == "sword" then
Send "wield axe"
else
if wildcards [2] == "now" then
Send "flee"
else
Send "kick"
end -- if
end -- if
end -- function



The above example is not monospaced, and is not indented, so it is hard to read. (This also applies to MUD output, which is often monospaced).

It looks better like this:


function mytrigger (name, line, wildcards)
  if wildcards [1] == "sword" then
    Send "wield axe"
  else
    if wildcards [2] == "now" then
      Send "flee"
    else
      Send "kick"    
    end -- if
  end -- if
end -- function


To achieve the improved look, simply put [code] at the start of the code snippet, and [/code] at the end. If you are editing an existing post, make sure that "Forum codes" (under the post) is checked.

However there is a small problem - if your post has square brackets or backslashes in it, the forum may misinterpret them as forum tags. For example, if your script had [i] in it, that would make everything after it appear in italics.

You need to ensure that square brackets inside your post are not misinterpreted by "escaping" them.


  • To do this, copy the code to the clipboard
  • Then use MUSHclient's Edit menu -> "Convert Clipboard Forum Codes" (Shift+Ctrl+Alt+Q)
  • Paste the converted code into the forum posting (between the [code] and [/code] tags).


Now your code will look monospaced and much easier to read.

In this example, when looking at the posting whilst editing it in the forum, you would see this:


[code]
function mytrigger (name, line, wildcards)
  if wildcards \[1\] == "sword" then
    Send "wield axe"
  else
    if wildcards \[2\] == "now" then
      Send "flee"
    else
      Send "kick"    
    end -- if
  end -- if
end -- function
[/code]

- 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.


8,788 views.

This subject is now 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.

[Home]


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]