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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Suggestions
. . -> [Subject]  History Log

History Log

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Sun 01 Feb 2009 08:31 AM (UTC)
Message
I'm one of these people that doesn't reboot for months, has 32 windows open, and never closes mushclient.

On the rare occasion that I do need to reboot, I'm always peeved that my command history's gone.

What I'd love is if the scripting interface included:

CommandHistoryAdd/CommandHistoryLoad
CommandHistorySave/CommandHistoryExport

So in my OnWorldClose function I could export it to a text file, and re-read it OnWorldOpen.

Thanks Nick.

[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 01 Feb 2009 06:55 PM (UTC)
Message
Months, eh? MUSHclient must be pretty reliable then. :)

For getting the command history:

http://www.gammon.com.au/scripts/doc.php?function=GetCommandList

For putting it back (per command):

http://www.gammon.com.au/scripts/doc.php?function=SetCommand

then:

http://www.gammon.com.au/scripts/doc.php?function=PushCommand



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #2 on Sun 01 Feb 2009 11:28 PM (UTC)

Amended on Sun 01 Feb 2009 11:44 PM (UTC) by WillFa

Message
Thanks Nick.

If anyone else is looking for similar, here's the code.


function OnWorldOpen()
	local tmp = GetInfo(54):sub(1,-4) .. "cmds"
	f = io.open(tmp)
	repeat
		local line = f:read()
		if line then
			SetCommand(line)
			PushCommand()
		end
	until not line
	f:close()
end

function OnWorldClose()
	local tmp = {}
	f = io.open(GetInfo(54):sub(1,-4) .. "cmds", "w")
	for _,cmd in ipairs(GetCommandList(GetCurrentValue("history_lines"))) do
		if not tmp[cmd] then
			f:write(cmd .. string.char(13) .. string.char(10))
		end
		tmp[cmd] = true
	end
	f:close()
end


OnWorldClose removes duplicates from the history. The commands are saved to a .cmds file in the same directory as the world file.
[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.


10,711 views.

It is now over 60 days since the last post. This thread is 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]