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

Release notes for MUSHclient version 3.57


Version 3.57

Released on 09 Dec 2004

1. Fixed a bug where if a one-shot timer called a script, and the script had an error which showed the error dialog, and the error dialog was not dismissed within one second, MUSHclient would crash.


2. Lua now uses "delayed load" for its DLLs. What this means is it is possible to start MUSHclient without lua.dll or lualib.dll being present, however when you attempt to use Lua scripting (and either one is not present) you will get an error message. This allows MUSHclient to be used without the Lua DLLs (for example, where space is tight, or where, for security reasons, you want to make sure that Lua cannot be used).


3. Fixed the installer so that, if you uninstall MUSHclient, the files lua.dll, lualib.dll, exampscript.lua, and constants.lua are also removed.


4. Changed the error message slightly that appear on a Lua error. Now instead of the word "program" you see what sort of program it is.

eg. [string "Command line"]:1: `=' expected near `a'

This example shows the error came from the command line.

or: [string "Trigger: mytrigger"]:1: `=' expected near `a'

This example shows the error came from the Trigger named mytrigger.


5. Put various useful Lua scripts into the exampscript.lua file. Scripts that you can use from there are:

* tprint (table printer)

* wait (for pausing inside a script)

* waitfor (for pausing inside a script for a trigger line)

* waitforregexp (same as waitfor, but for regular expressions)

* var table (for accessing MUSHclient variables through a Lua table)

* serialize (for serializing nested tables and variables to a string)


6. Changed behaviour with notepad windows, that if you created a new one, and then tried to save it, it now offers to save under the window title (eg. a window called "foo" will offer to save as "foo.txt").

Previously it tried to save as "Text1.txt", "Text2.txt" and so on.


7. Added new selector (64) to world.GetInfo. This returns the current directory path (that is, whatever directory would be used to open or save a file without a pathname). eg. C:\MUSHclient.3.56\

8. Added a few utilities for use in Lua (only). These are restricted to Lua because they may need to use the null byte (hex 00) which can not be readily stored as a string in other languages, as it is regarded as a string terminator.

utils.compress (s [, method] )

Compresses string s and returns the compressed form. Note that it may contain nulls (bytes with a zero value).

The optional argument 'method' indicates the level of compression you want.

0 = no compression
1 = best speed
....
9 = best compression

The default, if omitted, is 6.

utils.decompress (s)

Decompresses string s and returns the decompressed form. Raises an error if decompression cannot be done (eg. bad compressed data).

These two functions should be complementary, so that this should always be true:

x = "some string" -- for any (string) data whatsoever

y = utils.decompress (utils.compress (x)) --> y should be same as x

utils.hash (s)

Returns a 40-character hex string which is the hash of the string 's'. The string 's' may contain the null byte (ie. hex 00). Otherwise, this is the same behaviour as the world.Hash function.

eg.

print (utils.hash ("Nick Gammon")) --> fe09b07227a4e006213ac005831d55b20508a568
print (Hash ("Nick Gammon")) --> fe09b07227a4e006213ac005831d55b20508a568

utils.base64encode (s, [, linebreaks] )

Encodes the string 's' in base64 encoding (suitable for emails etc.). If 'linebreaks' is true, there will be a carriage return/linefeed every 76 characters. The string 's' may contain the null byte (ie. hex 00). Otherwise, this is the same behaviour as the world.Base64Encode function.

eg.

print (utils.base64encode ("Nick Gammon")) --> TmljayBHYW1tb24=

The output string will be 4/3 times as large as the input string, plus some possible padding to make up the result to a multiple of 4 (the padding character is "="). Also, if you request linebreaks there will be a further 2 byte for every 76 bytes output (that is, every 57 bytes of input).

utils.base64decode (s)

Decodes the string 's' from base64 encoding to plain text. The decoded string may contain the null byte (ie. hex 00). Otherwise, this is the same behaviour as the world.Base64Decode function. Bytes that are invalid are skipped (eg. spaces, newlines, other junk).

eg.

print (utils.base64decode ("TmljayBHYW1tb24=")) --> Nick Gammon

If the source string is not a multiple of 4 bytes then the last few bytes of the decoded string will be lost (because decoding is done in batches of 4 input bytes to 3 output bytes).


----------

9. Added new script routine NotepadColour. This lets you set the text and background colour of an open notepad window.

eg.

AppendToNotepad ("test", "but does it get goat's blood out?") -- create window
NotepadColour ("test", "whitesmoke", "saddlebrown") -- change its colour

The colours are specified by colour name - you can use the MUSHclient colour picker to see all possible colour names, or type: world.Debug ("colours"). You can also specify colours in HTML format, like this:

NotepadColour ("test", "#FAEBD7", "#FFB6C1")


10. Added new script routine NotepadFont. This lets you change the font, font size, style, and character set of the font for an open notepad window.

eg.

NotepadFont ("test", "Comic Sans MS", 11, 0, 0)

The arguments are:

notepad name
font name
font size
style bits
character set

If the font name is empty, then the font is unchanged.

If the font size is zero, then the font size is unchanged. The font size is in points.

The style should be a combination of the numbers below (zero is just plain text). For instance, bold and italic would be 3.

Style bits:

1 = bold
2 = italic
4 = underline
8 = strikeout


11. Added script support for the Mersenne Twister pseudo-random number generator.

What is Mersenne Twister?

Mersenne Twister (MT) is a pseudorandom number generator developped by Makoto Matsumoto and Takuji Nishimura (alphabetical order) during 1996-1997. MT has the following merits:

* It is designed with consideration of the flaws of various existing generators.

* Far longer period and far higher order of equidistribution than any other implemented generators. (It is proved that the period is 2^19937-1, and 623-dimensional equidistribution property is assured.)

* Fast generation.

* Efficient use of memory.

The script routines supporting Mersenne Twister (MT) are:

MtSrand (seed)

This seeds the MT generator with the given number, which is a 32-bit number.

MtRand ()

This returns a pseudo-random number in the range 0 to 1 (however excluding 1) as a "double" (floating-point number). Thus you can generate a number in any range by multiplying the result by the range you want.

eg.

print (math.floor (MtRand () * 5)) - returns 0 to 4

An example of doing coin flips:

--------
heads = 0
tails = 0

for j = 1, 1000000 do
i = math.floor (MtRand () * 2)
if i == 0 then
heads = heads + 1
else
tails = tails + 1
end
end

print ("heads = ", heads) --> 498893
print ("tails = ", tails) --> 501107
--------

The example above executes on my PC in about one second, so you can see that random number generation is quite fast (that's a million numbers in a second, which includes the addition, multiplication, if test and so on).

Note that the MT generator is "global" to all of MUSHclient. If you are trying to reproduce a sequence, then you cannot rely on a sequence staying stable from one script call to another (since another script, or another world or plugin) might also use random numbers.

This script here, for example, would generate a million random numbers, and put them into a table for later use:

nums = {}

MtSrand (1234567) -- start with a known seed

for j = 1, 1000000 do
table.insert (nums, MtRand ())
end

Again, this took about a second to execute on my PC.

Over a run of 10,000,000 coins flips it seemed pretty accurate, giving 5,000,625 heads and 4,999,375 tails (in other words, around 50.00625% heads).

-----

12. Added new selector (232) to world.GetInfo. This reports the result from querying the high-performance timer in Windows. Effectively it gives a number which is the number of seconds in the timer. I'm not sure when the timer starts. It is a floating-point number, so you could use it for timing fast loops.

eg.

print (GetInfo (232)) --> 210813.6136863
for i = 1, 1000000 do
a = a + 1
end
print (GetInfo (232)) --> 210813.74770735

In this case you can see that the loop took 0.1340 seconds to execute.

You could use this to seed the random number generator, as the number will change every second.

eg.

MtSrand (GetInfo (232) * 100) --> seed with time in 100ths of a second


13. Fixed problem where, sometimes when MUSHclient started up, and you were using a Guest account, you would see a small dialog box with no text and an OK button. Now you will see the message:

Unable to register as an OLE server.
This may happen if you are using a Guest account.
You can safely ignore this message.


14. Changed the way XML is written (eg. saving world files, copying XML to the clipboard), such that in multi-line strings, quotes are no longer represented as ". This makes the output more readable, and does not compromise the way it is read back in.

View all MUSHclient release notes

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 FutureQuest]