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

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

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

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Make postings easier to read with [code] tags

This subject is now closed.   [New subject]  Start a new subject   [Refresh] Refresh page


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

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.


1,444 views.

This subject is now closed.   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]