EzEdit_by_JamesIII…

Home Forums Wayward EzEdit_by_JamesIII…

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #4992
    AndyDemon
    Member

    I took it upon my self to update the script it currently works with 1.9.1

    (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", '#talent', function(e) {player.talent=0;});
    
    $("#optionswindow").append('<button type="button" id="talent">Talentless</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="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');});

    Keep in mind the save to file and load from file does work in a way you can save from your browser and load into the client downloaded game via the script..all other script parts should work as they did before.

    P.S all credits go to the original creator all i did was update it

    • This topic was modified 10 years, 3 months ago by AndyDemon.
    #4996

    Cool! I have updated the mod on the mods page. I also realized this version was missing some of the old functionality that JamesIII had in there (like monster spawning), so I added/updated that stuff as well.

    #5003
    JamesIII
    Moderator

    This is great you guys fixed it. I sorta reverse figured out how to write most of this from what others have posted so its harder for me when the format changed or just knowing little parts of how to write the code. I’d really like to learn how to make different chapters to post text that can be qued by either a button or better yet, walking onto a specific tile location. Perhaps when another button is pushed it would do a inventory check to see if the needed items were present and then based on a true/false check, dispense a not completed message or completed message with reward item. Just a few thoughts, I’m not sure how to accomplish these things.

    #5024
    AndyDemon
    Member

    sorry been working hard to get time to check stuff heh

    anyhow you could do a player.x and player.y to see if a player is in a area and run off of that as for the code and learning if you use google crome while playing browser game press F12 this will bring up the crome elements console from there is a list of tabs “Elements, Netowrk,Sources,Timeline” etc etc select sources on the left will be a few things to look at you will see http://www.unloc.ca in the box select it and go from there in this order http://www.unlok.ca>wayward>js and in the js folder you will se a few javascripts player.js audio etc etc use them to read the game’s code this will allow you to update your work faster ^_~ and maybe help you figure out a few things 🙂 remember to have the game open i the browser and press f12 to bring up the menu also at the bottom left you will see the word console below that a blue > if you click next to it you can run commands in game aka player.health=999 would instantly heal you if you take a step or spawn items via it etc just keep in mind you must walk ingame for the commands to take effect most of the time. but hope this helps enjoy

    #5192
    JamesIII
    Moderator

    Just a few questions if anyone has a moment.. 🙂

    How would I set specific stat total to a different number? player.health=48; changes current health but whats the variable name for total health?

    How would i create a a message in the the message box in a different font that appears in the middle of the screen when a button is pushed?

    Is there a way to do an inventory check for an item and then a true/false message for each possibility?

    How would you spawn a monster at a specific distance from player?

    #5200

    Here you go:

    player.strength Controls the total health of the player.

    ui.message("Test", "normal", false);
    ui.textAbove("Test", 255, 255, 255, false, -25, 0);

    ui.message Parameters:
    (Message, Message Type (“normal”, “bad”, “good”, etc.), Variables for Message String)

    ui.textAbove Parameters:
    (Message, Red, Green, Blue, Target (false or “target”), Offset X, Offset Y)

    if (player.isItemInInventory("ironsword")) {
    //Add code in here, the item was found!
    }

    spawnMonster("giantspider", player.x+3, player.y-3);

    That would do, 3 spaces to the right from you, and three spaces above.

    #5221
    Myrk
    Member

    I went skulking through the console and found the remaining total-stat variables.
    [Redacted]

    Here’s my lazy test button

    [Redacted]

    On a related note: undefined/NaN stat values are very bad. For health it’s a 1-hit-kill, for Stamina you can only spin on the spot, and for hunger and thirst the value drops to -1 when the respective stat updates.

    I also noticed two Get String buttons/functions in the version on the mods page, both of which ended up spawning six string instead of one (for the first button) and five (for the second), so
    I tweaked the first String button to give tree bark:

    [Redacted]

    My apologies if there are errors; I’m new to both Javascript and Wayward.

    • This reply was modified 10 years ago by Myrk. Reason: Copyright license gave mixed messages about modding, the help post on the mods page cleared up the confusion
    • This reply was modified 10 years ago by Myrk. Reason: Will un-redact when the copyright license 'clicks' in my head
    #5227
    Myrk
    Member

    I can’t edit the post again, so I’ll add the redacted parts here:

    player.dexterity is for stamina, starvation for hunger and dehydration for thirst. strength also affects carry weight.

    Here’s version one of the lazy button, as well as the Bark 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">I Want To Live!</button>'); 
    $("#optionswindow").append('<button type="button" id="getBark">Bark</button>'); 
    $("#optionswindow").on("click", '#getBark', function () {
    	itemGet({
    		type: "treebark",
    		quality: "Random"
    	}, 'silent');
    }); 

    I must apologize; I proposed these changes to the mod without James’ or Andy’s permission beforehand. I will ask before I propose any more changes from now on.

    #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');});
    
    #5340
    JamesIII
    Moderator

    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() {changeTile({type: "stonewall"}, player.x-4, player.y-4);changeTile({type: "stonewall"}, player.x+4, player.y-4);
    
    changeTile({type: "stonewall"}, player.x-3, player.y-1);changeTile({type: "stonewall"}, player.x-3, player.y-2);changeTile({type: "stonewall"}, player.x-3, player.y-3);changeTile({type: "woodenfloor"}, player.x-3, player.y-4);changeTile({type: "stonewall"}, player.x-3, player.y-5);
    
    changeTile({type: "stonewall"}, player.x-2, player.y-1);changeTile({type: "woodenfloor"}, player.x-2, player.y-2);changeTile({type: "woodenfloor"}, player.x-2, player.y-3);changeTile({type: "stonewall"}, player.x-2, player.y-4);changeTile({type: "woodenfloor"}, player.x-2, player.y-5);changeTile({type: "stonewall"}, player.x-2, player.y-6);
    
    changeTile({type: "stonewall"}, player.x-1, player.y-1);changeTile({type: "woodenfloor"}, player.x-1, player.y-2);changeTile({type: "woodenfloor"}, player.x-1, player.y-3);changeTile({type: "stonewall"}, player.x-1, player.y-4);changeTile({type: "woodenfloor"}, player.x-1,player.y-5);changeTile({type: "woodenfloor"}, player.x-1,player.y-6);changeTile({type: "stonewall"}, player.x-1,player.y-7);
    
    changeTile({type: "cobblestone"}, player.x, player.y);changeTile({type: "woodendoor"}, player.x, player.y-1);changeTile({type: "woodenfloor"}, player.x, player.y-2);changeTile({type: "woodenfloor"}, player.x, player.y-3);changeTile({type: "woodenfloor"}, player.x, player.y-4);changeTile({type: "woodenfloor"}, player.x,player.y-5);changeTile({type: "woodenfloor"}, player.x,player.y-6);changeTile({type: "woodenfloor"}, player.x,player.y-7);changeTile({type: "stonewall"}, player.x,player.y-8);
    
    changeTile({type: "stonewall"}, player.x+1, player.y-1);changeTile({type: "woodenfloor"}, player.x+1, player.y-2);changeTile({type: "woodenfloor"}, player.x+1, player.y-3);changeTile({type: "stonewall"}, player.x+1, player.y-4);changeTile({type: "woodenfloor"}, player.x+1,player.y-5);changeTile({type: "woodenfloor"}, player.x+1,player.y-6);changeTile({type: "stonewall"}, player.x+1,player.y-7);
    
    changeTile({type: "stonewall"}, player.x+2, player.y-1);changeTile({type: "woodenfloor"}, player.x+2, player.y-2);changeTile({type: "woodenfloor"}, player.x+2, player.y-3);changeTile({type: "stonewall"}, player.x+2, player.y-4);changeTile({type: "woodenfloor"}, player.x+2, player.y-5);changeTile({type: "stonewall"}, player.x+2, player.y-6);
    
    changeTile({type: "stonewall"}, player.x+3, player.y-1);changeTile({type: "stonewall"}, player.x+3, player.y-2);changeTile({type: "stonewall"}, player.x+3, player.y-3);changeTile({type: "woodenfloor"}, player.x+3, player.y-4);changeTile({type: "stonewall"}, player.x+3, player.y-5);changeTile({type: "stonewall"}, player.x+3, player.y-6);changeTile({type: "stonewall"}, player.x+3, player.y-7);changeTile({type: "stonewall"}, player.x+3, player.y-8);
    
    changeTile({type: "snow"}, player.x+3, player.y-9);changeTile({type: "snow"}, player.x+4, player.y-10);changeTile({type: "snow"}, player.x+5, player.y-10);});
    
    $("#optionswindow").append('<button type="button" id="smcube">Cube</button>');
    $("#optionswindow").on("click", '#smcube', function() {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() {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="getammo">Ammo</button>');
    $("#optionswindow").on("click", '#getammo', function(e) {itemGet({type: "blackpowder", quality: "Random"}, 'silent');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');});
    
    $("#optionswindow").on("click", '#chicken', function () {
    	spawnMonster("chicken", player.x, player.y + 2);
    });
    $("#optionswindow").on("click", '#skeleton', function () {
    	spawnMonster("skeleton", player.x, player.y + 2);
    });
    $("#optionswindow").on("click", '#bogling', function () {
    	spawnMonster("bogling", player.x, player.y + 2);
    });
    $("#optionswindow").on("click", '#zombie', function () {
    	spawnMonster("zombie", player.x, player.y + 2);
    });
    $("#optionswindow").on("click", '#pirateghost', function () {
    	spawnMonster("pirateghost", player.x, player.y + 2);
    });
    
    $("#optionswindow").append('<button type="button" id="chicken">Chicken</button>');
    $("#optionswindow").append('<button type="button" id="skeleton">Skeleton</button>');
    $("#optionswindow").append('<button type="button" id="bogling">Bogling</button>');
    $("#optionswindow").append('<button type="button" id="zombie">Zombie</button>');
    $("#optionswindow").append('<button type="button" id="pirateghost">Pirate Ghost</button>');
    
    
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.