Skip to content

Commit 2702f19

Browse files
committed
Added Automatic_Backup.xml plugin to the distribution
1 parent ba65467 commit 2702f19

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

install/mushclient.nsi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ SetOverwrite ifnewer
347347
File "..\luacom\luacom5.lua"
348348
File "..\lua\sandbox.lua"
349349
File "..\lua\show_loaded.lua"
350+
File "..\lua\Automatic_Backup.xml"
350351

351352
; LuaSocket
352353

@@ -561,6 +562,7 @@ Section Uninstall
561562
Delete "$INSTDIR\lua\luacom5.lua"
562563
Delete "$INSTDIR\lua\sandbox.lua"
563564
Delete "$INSTDIR\lua\show_loaded.lua"
565+
Delete "$INSTDIR\lua\Automatic_Backup.xml"
564566

565567
Delete "$INSTDIR\lua\socket.lua"
566568
Delete "$INSTDIR\lua\ltn12.lua"

lua/Automatic_Backup.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="iso-8859-1"?>
2+
<!DOCTYPE muclient>
3+
4+
<muclient>
5+
<plugin
6+
name="Automatic_Backup"
7+
author="Nick Gammon"
8+
id="bb6a05ed7534b5db1ed40511"
9+
language="Lua"
10+
purpose="Backs up the world file to a new name each day"
11+
date_written="2010-09-08 09:38:17"
12+
requires="4.40"
13+
version="1.0"
14+
>
15+
<description trim="y">
16+
<![CDATA[
17+
Install to backup your world file to a file of the same name with the day/month/year added to it.
18+
]]>
19+
</description>
20+
21+
</plugin>
22+
23+
<script>
24+
<![CDATA[
25+
26+
function do_backup ()
27+
-- find name of world file
28+
local world_file_name = GetInfo (54)
29+
30+
-- if found (ie. not just newly created) back it up
31+
if world_file_name and world_file_name ~= "" then
32+
-- strip out .MCL (or .mcl), add the date, and put .MCL back
33+
world_file_with_date = string.gsub (world_file_name, "%.[Mm][Cc][Ll]$", "") ..
34+
os.date ("-backup-%d-%b-%Y.MCL")
35+
36+
-- save if possible
37+
if (Save (world_file_with_date, true) == false) then
38+
ColourNote ("orange","", "World file backed up as " .. world_file_with_date)
39+
else
40+
ColourNote ("red", "", "Could not back up world file.")
41+
end -- if
42+
43+
end -- if world file name known
44+
45+
end -- do_backup
46+
47+
-- back when first connecting
48+
function OnPluginConnect ()
49+
do_backup ()
50+
end -- OnPluginConnect
51+
52+
-- back up when disconnecting (eg. after improving it)
53+
function OnPluginDisconnect ()
54+
do_backup ()
55+
end -- OnPluginDisconnect
56+
57+
]]>
58+
</script>
59+
60+
</muclient>

0 commit comments

Comments
 (0)