Last active
July 22, 2019 06:58
-
-
Save QuadStorm/9b48ba72561073281bbde9b582b3e9a4 to your computer and use it in GitHub Desktop.
Save the current server's bricks in one keypress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// QuickSaver - Save the builds you come across in one keypress | |
// Won't work first time around for an unknown reason | |
// Host Name (by Visolater) | |
function visolatorGetHostName() | |
{ | |
%s = $ServerInfo::Name; | |
%a = strPos(%s, "'s"); | |
%b = strPos(%s, "s'"); | |
if(%a >= %b) | |
%c = %a; | |
else | |
%c = %b; | |
if(%c == -1) | |
return ""; | |
%n = getSubStr(%s, 0, %c); | |
return %n; | |
} | |
// Possessive Apostrophe | |
function addPossessiveApostrophe(%input) | |
{ | |
return %input @ (getSubStr(%input, strLen(%input) - 1, 1) $= "s" ? "'" : "'s"); | |
} | |
// Server Name | |
function getServerName() | |
{ | |
%hostName = visolatorGetHostName(); | |
%serverInfoName = $ServerInfo::Name; | |
return restWords(getSubStr(%serverInfoName, strLen(%hostName), strLen(%serverInfoName) - strLen(%hostName))); | |
} | |
// Time and Date | |
function quickSaveDateTimeFormat(%dateTime) | |
{ | |
%pDT = strReplace(strReplace(%dateTime, "/", " "), ":", "-"); | |
return "20" @ getWord(%pDT, 2) @ "-" @ getWord(%pDT, 0) @ "-" @ getWord(%pDT, 1) SPC getWord(%pDT, 3); | |
} | |
// Saving | |
function quickSaveBricks(%x) | |
{ | |
if (!%x) | |
return; | |
%saveName = addPossessiveApostrophe(getValidSaveName(visolatorGetHostName())) SPC getValidSaveName(getServerName()) SPC quickSaveDateTimeFormat(getDateTime()); | |
%saveFullName = "saves/" @ %saveName @ ".bls"; | |
echo("Saving bricks as" SPC %saveFullName); | |
clientCmdCenterPrint("\c2Saving bricks as" SPC %saveFullName, 3); | |
canvas.pushDialog(saveBricksGui); | |
saveBricks_Filename.setValue(%saveName); | |
saveBricks_Description.setValue($ServerInfo::Name SPC getDateTime()); | |
saveBricks_Ownership.setValue(1); | |
saveBricks_ExtendedInfo.setValue(1); | |
saveBricks_Save(); | |
} | |
// Keybind | |
if(!$quickSaveBind) | |
{ | |
$remapDivision[$remapCount] = "Quicksave Bricks"; | |
$remapName[$remapCount] = "Quicksave"; | |
$remapCmd[$remapCount] = "quickSaveBricks"; | |
$remapCount++; | |
$quickSaveBind = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For some reason you must save twice for it to save properly.