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.
 Entire forum ➜ MUSHclient ➜ General ➜ Make postings easier to read with [code] tags

Make postings easier to read with [code] tags

This subject is now closed.     Refresh page


Posted by Nick Gammon   Australia  (23,120 posts)  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
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.


9,179 views.

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