Home › Forums › Wayward › EzEdit_by_JamesIII… › Reply To: EzEdit_by_JamesIII…
November 25, 2014 at 12:13 am
#5230
JamesIII
Moderator
Here’s the version I currently use.
(function()
{
var saveBlob, saveLink, fileInput;
function saveToFile()
{
if (!saveLink)
{
saveLink = document.createElement("a");
document.body.appendChild(saveLink);
}
// Save game without nullfilter as it makes the game unstable if it keeps running
saveGame(true);
// Avoid saving whole localStorage as it's a privacy risk if playing locally
var data = JSON.stringify(
{
version: localStorage.getItem('version'),
options: localStorage.getItem('options'),
seeds: localStorage.getItem('seeds'),
player: localStorage.getItem('player'),
crafted: localStorage.getItem('crafted'),
envitems: localStorage.getItem('envitems'),
monsters: localStorage.getItem('monsters'),
tileData: localStorage.getItem('tileData'),
tileitems: localStorage.getItem('tileitems'),
milestoneCount: localStorage.getItem('milestoneCount'),
}
);
if (window.URL)
{
if (saveBlob) window.URL.revokeObjectURL(saveBlob);
saveLink.href = saveBlob = window.URL.createObjectURL(new Blob([data], {type:'text/json'}));
} else {
// Give poor Opera 12 at least some way to save
saveLink.target = "_blank";
saveLink.href = 'data:application/octet-stream;charset=utf-8,' + escape(data);
}
var d = new Date();
saveLink.download =
[
"Wayward_save_",
d.getFullYear(),
"_",
(101 + d.getMonth() + "").slice(-2),
(100 + d.getDate() + "").slice(-2),
"_",
(100 + d.getHours() + "").slice(-2),
(100 + d.getMinutes() + "").slice(-2),
(100 + d.getSeconds() + "").slice(-2),
".json"
].join("");
saveLink.click();
}
function loadFromFile()
{
if (!fileInput)
{
fileInput = document.createElement("input");
fileInput.type = "file";
fileInput.accept = ".json";
document.body.appendChild(fileInput);
fileInput.addEventListener("change", function(e)
{
var reader = new FileReader();
reader.onload = function(evt)
{
var result = JSON.parse(evt.target.result);
for (var re in result) localStorage[re] = result[re];
window.onbeforeunload = null;
location.reload();
};
reader.readAsText(e.target.files[0], "ascii");
},
false
);
}
fileInput.click();
}
// Check if already loaded
if (document.getElementById("saveToFile")) return;
// Add buttons to main menu
var saveButton = $('<button type="button" id="saveToFile">Save to file</button>');
saveButton.click(saveToFile);
var loadButton = $('<button type="button" id="loadFromFile">Load from file</button>');
loadButton.click(loadFromFile);
$("#saveAndExit").after(loadButton).after(saveButton).after("<br /><br />");
// Increase main menu height accordingly
var gm = $('#gameMenu');
gm.dialog("option", "height", gm.dialog("option", "height") + 80);
})();
$("#optionswindow").on("click", '#showMap', function(e) {
$("#map").show();
e.preventDefault();
});
$("#optionswindow").on("click", '#closeMap', function(e) {
$("#map").hide();
e.preventDefault();
});
$("#optionswindow").append('<button type="button" id="showMap">Show Map</button>');
$("#optionswindow").append('<button type="button" id="closeMap">Close Map</button>');
$("#optionswindow").on("click", '#instantMiracle', function () {
player.health = player.strength;
player.stamina = player.dexterity;
player.hunger = player.starvation;
player.thirst = player.dehydration;
}); //Sets respective stat to its max.
$("#optionswindow").append('<button type="button" id="instantMiracle">Heal</button>');
$("#optionswindow").on("click", '#statreset', function () {
player.health = 50;
player.strength = 50;
player.stamina = 50;
player.dexterity = 50;
player.hunger = 50;
player.starvation = 50;
player.thirst = 50;
player.dehydration = 50;
}); //Sets all stats to 50.
$("#optionswindow").append('<button type="button" id="statreset">Reset Stats</button>');
$("#optionswindow").append('<button type="button" id="smhouse">House</button>');
$("#optionswindow").on("click", '#smhouse', function(e) {changeTile({type: "stonewall"}, player.x-2, player.y+2);changeTile({type: "stonewall"}, player.x-2, player.y+1);changeTile({type: "woodendoor"}, player.x-2, player.y);changeTile({type: "stonewall"}, player.x-2, player.y-1);changeTile({type: "stonewall"}, player.x-2, player.y-2);
changeTile({type: "stonewall"}, player.x-1, player.y+2);changeTile({type: "woodenfloor"}, player.x-1, player.y+1);changeTile({type: "woodenfloor"}, player.x-1, player.y);changeTile({type: "woodenfloor"}, player.x-1, player.y-1);changeTile({type: "stonewall"}, player.x-1,player.y-2);
changeTile({type: "woodendoor"}, player.x, player.y+2);changeTile({type: "woodenfloor"}, player.x, player.y+1);changeTile({type: "woodenfloor"}, player.x, player.y);changeTile({type: "woodenfloor"}, player.x, player.y-1);changeTile({type: "woodendoor"}, player.x,player.y-2);
changeTile({type: "stonewall"}, player.x+1, player.y+2);changeTile({type: "woodenfloor"}, player.x+1, player.y+1);changeTile({type: "woodenfloor"}, player.x+1, player.y);changeTile({type: "woodenfloor"}, player.x+1, player.y-1);changeTile({type: "stonewall"}, player.x+1,player.y-2);
changeTile({type: "stonewall"}, player.x+2, player.y+2);changeTile({type: "stonewall"}, player.x+2, player.y+1);changeTile({type: "woodendoor"}, player.x+2, player.y);changeTile({type: "stonewall"}, player.x+2, player.y-1);changeTile({type: "stonewall"}, player.x+2, player.y-2);});
$("#optionswindow").append('<button type="button" id="getfiremats">Fire Materials</button>');
$("#optionswindow").on("click", '#getfiremats', function(e) {itemGet({type: "kindling", quality:
"Random"}, 'silent');itemGet({type: "tinder", quality:
"Random"}, 'silent');itemGet({type: "coal", quality:
"Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getsandstone">Sandstone</button>');
$("#optionswindow").on("click", '#getsandstone', function(e) {itemGet({type: "sandstone", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getrock">Stone</button>');
$("#optionswindow").on("click", '#getrock', function(e) {itemGet({type: "largerock", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getwood">Log</button>');
$("#optionswindow").on("click", '#getwood', function(e) {itemGet({type: "log", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getbranch">Branch</button>');
$("#optionswindow").on("click", '#getbranch', function(e) {itemGet({type: "branch", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getstring">String</button>');
$("#optionswindow").on("click", '#getstring', function(e) {itemGet({type: "string", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getleather">Leather</button>');
$("#optionswindow").on("click", '#getleather', function(e) {itemGet({type: "tannedleather", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getbone">Bone</button>');
$("#optionswindow").on("click", '#getbone', function(e) {itemGet({type: "bone", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getwroughtiron">Wrought Iron</button>');
$("#optionswindow").on("click", '#getwroughtiron', function(e) {itemGet({type: "wroughtiron", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="gettalcum">Talc</button>');
$("#optionswindow").on("click", '#gettalcum', function(e) {itemGet({type: "talcumpowder", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getlimestone">Lime</button>');
$("#optionswindow").on("click", '#getlimestone', function(e) {itemGet({type: "limestonepowder", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getcarbonpowder">Carb</button>');
$("#optionswindow").on("click", '#getcarbonpowder', function(e) {itemGet({type: "carbonpowder", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getflintlockpistol">Pistol</button>');
$("#optionswindow").on("click", '#getflintlockpistol', function(e) {itemGet({type: "flintlockpistol", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getblackpowder">Gunpowder</button>');
$("#optionswindow").on("click", '#getblackpowder', function(e) {itemGet({type: "blackpowder", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getironbullet">Bullet</button>');
$("#optionswindow").on("click", '#getironbullet', function(e) {itemGet({type: "ironbullet", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getmagicalessence">Magical Essence</button>');
$("#optionswindow").on("click", '#getmagicalessence', function(e) {itemGet({type: "magicalessence", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getmedicinalwater">Rum</button>');
$("#optionswindow").on("click", '#getmedicinalwater', function(e) {itemGet({type: "medicinalwaterglassbottle", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getsuture">Suture</button>');
$("#optionswindow").on("click", '#getsuture', function(e) {itemGet({type: "suture", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getstonewall">Stone Wall</button>');
$("#optionswindow").on("click", '#getstonewall', function(e) {itemGet({type: "stonewall", quality: "Random"}, 'silent');});
$("#optionswindow").append('<button type="button" id="getsolarstill">Solar Still</button>');
$("#optionswindow").on("click", '#getsolarstill', function(e) {itemGet({type: "solarstill", quality: "Random"}, 'silent');});