Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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
➜ Tips and tricks
➜ Collected tips for Crimson Editor
Collected tips for Crimson Editor
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Nick Gammon
Australia (23,072 posts) Bio
Forum Administrator |
Date
| Wed 04 Jun 2008 09:47 PM (UTC) Amended on Wed 18 Jun 2008 01:05 AM (UTC) by Nick Gammon
|
Message
| I have been very happy with using Crimson Editor for editing MUSHclient script files, and in general.
It is:
- Free
- Fast
- Does syntax colouring of Lua (and various other languages, like C, HTML)
- Lets you do FTP editing (load and save from a FTP server), which is handy for grabbing files on another server
- Can be configured to show MUSHclient help for the word under the cursor (see below)
- Can be configured to show Lua help for the word under the cursor (see below)
- Can be configured to test Lua stand-alone by putting the path to lua.exe in its tools configuration, so you can edit/test/fix Lua programs very quickly
- Can be configured to syntax-colour the MUSHclient functions, so you can immediately see if they are spelt correctly (see below).
Below are links to the various tips I have developed for Crimson Editor over the years:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,072 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 05 Jun 2008 12:26 AM (UTC) Amended on Thu 05 Jun 2008 03:29 AM (UTC) by Nick Gammon
|
Message
| To simplify syntax colouring MUSHclient keywords, here are the files I used for Crimson Editor:
http://www.gammon.com.au/files/mushclient/lua.key (15 Kb)
http://www.gammon.com.au/files/mushclient/lua.spc (1 Kb)
The first one has all the Lua keywords and functions, as well as the MUSHclient function names.
You can download these files and replace the ones of the same name in the Crimson Editor "spec" subdirectory.
I generated the function names with this script:
pairsbykeys = require "pairsbykeys"
for _, t in ipairs {"math",
"io",
"debug",
"coroutine",
"os",
"string",
"table",
"package",
"world",
"utils",
"bit",
"bc",
} do
for k, v in pairsbykeys (_G [t]) do
if string.sub (k, 1, 1) ~= "_" then
print (t .. "." .. k)
end -- not starts with underscore
end -- each function
print ""
end -- each major package
-- now global variables
for k, v in pairsbykeys (_G) do
if type (v) == "function" or type (v) == "string" then
print (k)
end -- function or string
end -- each function
Then I copied all the "world.xxx" functions to have a second copy without "world." in front, as MUSHclient does not require the world prefix, for simplicity. (Basically this is done by putting a metatable on the _G table).
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,072 posts) Bio
Forum Administrator |
Date
| Reply #2 on Thu 05 Jun 2008 03:28 AM (UTC) |
Message
| A slightly improved version finds for itself all the table names:
require "pairsbykeys"
for a, b in pairsByKeys (_G) do
if type (b) == "table" and a ~= "_G" then
for k, v in pairsByKeys (_G [a]) do
if string.sub (k, 1, 1) ~= "_" and type (v) == "function" then
print (a .. "." .. k)
end -- not starts with underscore
end -- each function
end -- each table
print ""
end -- each major package
-- now global variables
for k, v in pairsByKeys (_G) do
if type (v) == "function" or type (v) == "string" then
print (k)
end -- function or string
end -- each function
After running this a few extra function names cropped up (eg. progress.new) so I have uploaded a more up-to-date lua.key file. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Onoitsu2
USA (248 posts) Bio
|
Date
| Reply #3 on Thu 05 Jun 2008 03:37 AM (UTC) Amended on Thu 05 Jun 2008 03:39 AM (UTC) by Onoitsu2
|
Message
| using the 'progress.new' function just shows a progress dialog that does not allow you to dismiss it, so use of it is pointless as of yet.
-Onoitsu2 | Top |
|
Posted by
| Nick Gammon
Australia (23,072 posts) Bio
Forum Administrator |
Date
| Reply #4 on Thu 05 Jun 2008 05:09 AM (UTC) |
Message
| Well, it was designed for use in the spell checker, and it *can* be dismissed, however in version 4.26 or earlier it has a bug which I just noticed, so I wouldn't use it just yet. Here is an example of how it might be used:
dlg = progress.new ("Self-destruct sequence started ...")
number_of_things = 100000
dlg:range (0, number_of_things )
dlg:setstep (1)
for i = 1, number_of_things do
dlg:step ()
dlg:status ("Doing item " .. i)
if dlg:checkcancel () then
print "Self-destruct sequence cancelled..."
break
end -- if
end -- loop
dlg:close ()
This illustrates the general idea of the progress dialog.
- You create it with progress.new - that gives you a userdatum which is used for subsequent operations.
With the userdatum (dlg in this example) you can:
- dlg:range - set a range for the progress bar (assuming you know that you need to do x things)
- dlg:setstep - set a step amount - when you step it goes up by this much.
- dlg:status - set the status (which is shown in the progress bar) - this is a piece of text
- dlg:step - step up to the next item
- dlg:checkcancel () - check if they clicked "cancel"
- dlg:close - close and dismiss the dialog
Notice the colon after "dlg", not a period. This is because it is a userdatum.
Thanks to your message I noticed that there is a bug, after you close it, when Lua goes to garbage-collect it (which might be 5 minutes later) it raises an error. Better wait for version 4.27 before you try it.
|
- 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.
23,338 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top