I have begin translating the event-based property list script into an event-driven javascript script.
I have translated the first third of the code (3000 lines), with a reduction down to 16% of the original size.
I was going to provide a first-look at the code, but box.net isn't wanting to load for me right now, so I'll post the most interesting part of the code here, adding the spacebar.
Code: Select all
this.addSpaceBarToSystem = function () {
function systemIsAllowed() {
var notAllowed = [46];
if (notAllowed.indexOf(system.ID) > -1) {
return false;
}
return true;
}
function spacebarNumber(systemID) {
var spacebars = [ // 20 systems per row
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4,
4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7,
7, 7, 40, 40, 40, 40, 40, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10,
10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13,
13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16,
16, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 20,
20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22,
23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25,
25, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28,
28, 28, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31,
31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34,
34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36, 36, 37, 37,
37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39
];
return spacebars[systemID];
}
function addSpacebar(type) {
var coords = [
[-41190, 33291, 240408],
[-5106, 5174, 388275],
[12644, 13830, 353962],
[25774, -10946, 314064],
[-48509, -9524, 266555]
],
coordIndex = [1, 2, 3, 4, 0, 1, 2, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1,
2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 3],
position = coords[coordIndex[type - 1]];
missionVariables.random_hits_seedy_spacebar_name = '[random_hits_barname' + type + ']';
system.addShipsAtPrecisely('random_hits_spacebar' + type, 1, 'pwm', position);
missionVariables.random_hits_spacebar_position = position;
system.addShipsWithinRadius('random_hits_griff_autominer', '[random_hits_rocks_number]', 'pwm', position, 15000);
system.addShipsWithinRadius('asteroid', '[random_hits_rocks_number2]', 'pwm', position, 25000);
system.addShipsWithinRadius('random_hits_minesweeper', 1, 'pwm', position, 4000);
}
if (system.countShipsWithRole('random_hits_spacebar1') === 0) {
if (system.government === 0 && systemIsAllowed()) {
addSpacebar(spacebarNumber(system.ID));
if (missionVariables.random_hits_seedy_spacebar_name === null && !system.isInterstellarSpace) {
addSpacebar(17);
}
}
}
};