var townnames = Array("Henesys", "Ellinia", "Kerning City", "Perion", "Lith Harbour");
//townnames[0] = Henesys, so townids[0] MUST BE Henesys's mapid,
//else you will be warped to another map.
var townids = Array(10000000, 101000000, 103000000, 102000000, 104000000);
//end of configuration, do not touch unless you know what you're doing!
var selectedMapId = -1;
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
function getTownId(townNameStr)
{
for(int iter = 0; iter < townnames.length; iter++;) {
if(townNameStr.equalsIgnoreCase(townnames[iter])) return townids[iter];
}
return -1;
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && status == 0) {
cm.sendOk("Alrighty, cya around!");
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendGetText("Please type in a town name:");
} else if (status == 1) {
var mapId = getTownId(cm.getText());
if(mapId != -1) {
selectedMapId = mapId;
cm.sendYesNo("Go to " + cm.getText() + "?");
} else {
cm.sendOk("Invalid town name.");
cm.dispose();
return;
}
} else if (status == 2) {
if(selectedMapId != -1) {
cm.warp(selectedMapId, 0);
cm.dispose();
return;
} else {
cm.sendOk("This isn't supposed to happen..");
cm.dispose();
return;
}
}
}
}