rj
2013-07-13 23:34:26
So in my learning of making injection scripts in java, I have encountered 2 ways to construct a script:
1) Using a main loop to do actions such as:
Or I could use strategies:
anyway, I was wondering, which was in more memory efficient? All the overrides, is that taking up a lot more memory?
1) Using a main loop to do actions such as:
public int loop() {
if(Inventory.isFull()) {
if (atMine()) {
walkBank();
state = ("Walking to bank");
} else if (atBank()) {
state = ("Banking");
openBank();
countGains();
handleBank();
} else {
if (Inventory.isFull()) {
walkBank();
} else {
walkMine();
}
}
} else if(!Inventory.isFull()) {
if (atMine()) {
mineRock();
state = ("Mining");
} else if (atBank()) {
state = ("Walking to mine");
walkMine();
} else {
if (Inventory.isFull()) {
walkBank();
} else {
walkMine();
}
}
}
return 5;
}Or I could use strategies:
public class withdrawPotions implements Strategy {
@Override
public boolean activate() {
return !extremesReady() && Bank.isOpen();
}
@Override
public void execute() {
// stuff here if above conditions are met
}
}
public class closeBank implements Strategy {
@Override
public boolean activate() {
return extremesReady() && Bank.isOpen();
}
@Override
public void execute() {
// stuff here if above conditions are met
}
}
public class makePotions implements Strategy {
@Override
public boolean activate() {
return !Bank.isOpen() && extremesReady();
}
@Override
public void execute() {
// stuff here if above conditions are met
}
}
public class bankPotions implements Strategy {
@Override
public boolean activate() {
return !Bank.isOpen() && OverloadsExist() || !extremesReady();
}
@Override
public void execute() {
// stuff here if above conditions are met
}
}anyway, I was wondering, which was in more memory efficient? All the overrides, is that taking up a lot more memory?