-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProductMover1_4.java
executable file
·112 lines (99 loc) · 4.36 KB
/
ProductMover1_4.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import com.swath.*;
import com.swath.cmd.*;
/**
** Make sure to have a planet scanner on your ship before running this.
* @author Mind Dagger
*/
public class ProductMover1_4 extends UserDefinedScript {
private Parameter planet;
private Parameter name;
private Planet mainPlanet;
private Planet[] planets;
private Planet fuelPlanet;
private Parameter fuel;
private Parameter organics;
private Parameter equipment;
public String getName() {
return "MD's Express Product Mover 1.4";
}
public boolean initScript() throws Exception {
if (!atPrompt(Swath.COMMAND_PROMPT)){
UserAlert.exec("Must be command prompt!",UserAlert.TYPE_ERROR);
return false;
}
planets = Swath.sector.planets();
if(planets == null || planets.length <= 1){
if(planets.length == 1){
UserAlert.exec("Only one planet in sector!",UserAlert.TYPE_ERROR);
}
else{
UserAlert.exec("No planets in sector!",UserAlert.TYPE_ERROR);
}
return false;
}
planet = new Parameter("Planet To Fill");
for(int i=0;i < planets.length; i++)
{
if(planets[i].id() > 0){
planet.addChoice(i, "#"+planets[i].id()+" "+planets[i].name());
}
}
planet.setCurrentChoice(0);
name = new Parameter("Planet To Empty");
for(int i=0;i < planets.length; i++)
{
if(planets[i].id() > 0){
name.addChoice(i, "#"+planets[i].id()+" "+planets[i].name());
}
}
name.setCurrentChoice(0);
fuel = new Parameter("Move Fuel Ore");
fuel.setType(Parameter.BOOLEAN);
fuel.setBoolean(true);
organics = new Parameter("Move Organics");
organics.setType(Parameter.BOOLEAN);
organics.setBoolean(true);
equipment = new Parameter("Move Equipment");
equipment.setType(Parameter.BOOLEAN);
equipment.setBoolean(true);
registerParam(planet);
registerParam(name);
registerParam(fuel);
registerParam(organics);
registerParam(equipment);
return true;
}
public boolean runScript() throws Exception {
if(name.getCurrentChoice() == planet.getCurrentChoice()){
UserAlert.exec("You chose the same planet twice!",UserAlert.TYPE_ERROR);
return false;
}
JettisonCargo.exec();
planets = Swath.sector.planets();
fuelPlanet = planets[name.getCurrentChoice()];
mainPlanet = planets[planet.getCurrentChoice()];
fuelPlanet = Swath.getPlanet(fuelPlanet.id());
int products[] = fuelPlanet.productAmounts();
while(products[Swath.FUEL_ORE] >= Swath.ship.holds() || products[Swath.ORGANICS] >= Swath.ship.holds() || products[Swath.EQUIPMENT] >= Swath.ship.holds()){
if(atPrompt(Swath.COMMAND_PROMPT)){
Land.exec(fuelPlanet);
LiftOff.exec();
fuelPlanet = Swath.getPlanet(fuelPlanet.id());
String result = "";
if(fuelPlanet.productAmounts()[Swath.FUEL_ORE] > Swath.ship.holds() && fuel.getBoolean()){
result += "l "+fuelPlanet.id()+"^Mtnt1^Mql "+mainPlanet.id()+"^Mtnl1^Mq";
}
if(fuelPlanet.productAmounts()[Swath.ORGANICS] > Swath.ship.holds() && organics.getBoolean()){
result += "l "+fuelPlanet.id()+"^Mtnt2^Mql "+mainPlanet.id()+"^Mtnl2^Mq";
}
if(fuelPlanet.productAmounts()[Swath.EQUIPMENT] > Swath.ship.holds() && equipment.getBoolean()){
result += "l "+fuelPlanet.id()+"^Mtnt3^Mql "+mainPlanet.id()+"^Mtnl3^Mq";
}
SendMacro.exec(result,10,true);
}
}
return true;
}
public void endScript(boolean finished){
}
}