Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var MuleData = {
- create: function () {
- var obj, string;
- obj = {
- account: "",
- character: "",
- full: []
- };
- string = JSON.stringify(obj);
- FileTools.writeText("AutoMule." + AutoMule.realm + ".json", string);
- },
- read: function () {
- var obj, string;
- string = FileTools.readText("AutoMule." + AutoMule.realm + ".json");
- obj = JSON.parse(string);
- return obj;
- },
- write: function (obj) {
- var string = JSON.stringify(obj);
- FileTools.writeText("AutoMule." + AutoMule.realm + ".json", string);
- }
- };
- function pickItems() {
- print("pickItems function");
- var item,
- list = [];
- // temp
- while (true) {
- item = getUnit(4, -1, 3); // item, on ground
- if (item) {
- do {
- list.push(copyUnit(item));
- } while (item.getNext());
- }
- while (list.length > 0) {
- print("list " + list.length);
- print (Pickit.pickItem(list.shift()));
- }
- delay(1000);
- }
- }
- include("json2.js");
- include("oog.js");
- include("automule.js");
- include("common/storage.js");
- include("common/pickit.js");
- include("common/town.js");
- include("common/pather.js");
- include("common/misc.js");
- include("common/config.js");
- include("common/prototypes.js");
- load("tools/heartbeat.js");
- function main() {
- var status = "loading";
- function MuleEvent(mode, msg) {
- if (typeof msg === "string") {
- print("Got a status request from: " + msg);
- sendCopyData(null, msg, 0, status);
- }
- }
- if (!FileTools.exists("AutoMule." + AutoMule.realm + ".json")) {
- MuleData.create();
- }
- addEventListener("copydata", MuleEvent);
- while (true) {
- if (me.gameReady && status !== "ready") {
- Storage.Init();
- status = "ready";
- pickItems();
- }
- locationAction(getLocation());
- delay(1000);
- }
- }
- function locationAction(location) {
- var obj, info;
- switch (location) {
- case 18: // splash
- ControlAction.click();
- break;
- case 8: // menu
- case 9: // login
- obj = MuleData.read();
- if (!obj.account || obj.account.indexOf(AutoMule.accountPrefix) < 0 || obj.character.indexOf(AutoMule.charPrefix) < 0) {
- obj.account = AutoMule.accountPrefix + "1";
- obj.character = AutoMule.charPrefix + "I";
- MuleData.write(obj);
- }
- info = {
- realm: AutoMule.realm,
- account: obj.account,
- password: AutoMule.accountPassword
- };
- if (!ControlAction.loginAccount(info)) {
- ControlAction.makeAccount(info);
- FileTools.writeText("Mules/" + info.account + ".txt", "");
- }
- break;
- case 12: // char select
- case 42: // empty char screen
- obj = MuleData.read();
- info = {
- charName: obj.character,
- ladder: AutoMule.ladder,
- hardcore: AutoMule.hardcore,
- expansion: AutoMule.expansion,
- charClass: "amazon"
- };
- if (ControlAction.findCharacter(info)) {
- ControlAction.loginCharacter(info);
- } else {
- ControlAction.makeCharacter(info);
- }
- break;
- case 30: // charname already exists
- // todo
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement