Skip to content

Commit

Permalink
Added Automatic_Backup.xml plugin to the distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Sep 8, 2010
1 parent ba65467 commit 2702f19
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions install/mushclient.nsi
Expand Up @@ -347,6 +347,7 @@ SetOverwrite ifnewer
File "..\luacom\luacom5.lua"
File "..\lua\sandbox.lua"
File "..\lua\show_loaded.lua"
File "..\lua\Automatic_Backup.xml"

; LuaSocket

Expand Down Expand Up @@ -561,6 +562,7 @@ Section Uninstall
Delete "$INSTDIR\lua\luacom5.lua"
Delete "$INSTDIR\lua\sandbox.lua"
Delete "$INSTDIR\lua\show_loaded.lua"
Delete "$INSTDIR\lua\Automatic_Backup.xml"

Delete "$INSTDIR\lua\socket.lua"
Delete "$INSTDIR\lua\ltn12.lua"
Expand Down
60 changes: 60 additions & 0 deletions lua/Automatic_Backup.xml
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
name="Automatic_Backup"
author="Nick Gammon"
id="bb6a05ed7534b5db1ed40511"
language="Lua"
purpose="Backs up the world file to a new name each day"
date_written="2010-09-08 09:38:17"
requires="4.40"
version="1.0"
>
<description trim="y">
<![CDATA[
Install to backup your world file to a file of the same name with the day/month/year added to it.
]]>
</description>

</plugin>

<script>
<![CDATA[
function do_backup ()
-- find name of world file
local world_file_name = GetInfo (54)
-- if found (ie. not just newly created) back it up
if world_file_name and world_file_name ~= "" then
-- strip out .MCL (or .mcl), add the date, and put .MCL back
world_file_with_date = string.gsub (world_file_name, "%.[Mm][Cc][Ll]$", "") ..
os.date ("-backup-%d-%b-%Y.MCL")
-- save if possible
if (Save (world_file_with_date, true) == false) then
ColourNote ("orange","", "World file backed up as " .. world_file_with_date)
else
ColourNote ("red", "", "Could not back up world file.")
end -- if
end -- if world file name known
end -- do_backup
-- back when first connecting
function OnPluginConnect ()
do_backup ()
end -- OnPluginConnect
-- back up when disconnecting (eg. after improving it)
function OnPluginDisconnect ()
do_backup ()
end -- OnPluginDisconnect
]]>
</script>

</muclient>

0 comments on commit 2702f19

Please sign in to comment.