Ok, I am VERY new to the world of Java scripting, I have been reading up and such in the last couple weeks when I have the time and it's a struggle, but I am getting there lol. That said, bear with me as I'm sure these are super noob question.
Also, quick shoutout, since I am super new I have been dissecting other peoples scripts and using them to learn, the one I am currently trying to make started with Malcom's GF Buyer for reference and it has been extremely useful in learning how/why things act and respond the way they do in the codes, so thanks a million for the open source script. With that said, clearly I have no claim to the content in this script, and am only displaying it to illustrate my questions.
First super noob question, what is the code for withdraw "X" amount of coins from bank? and can someone please explain how to write "Inventory empty except coins" lol, you'll notice I dont have it set to take money out cuz I havent found that line yet lol...
Second noob question, I am piecing together a buyer bot from the dissected bits of the GF Buyer script. I would like it to only announce the "Buying Offer" if it has not done so in X amount of Milliseconds, but still cycle through the trade listener/accept processes in the interim, so that it doesn't spam annoy the hell out of everyone. The following code may NOT work at all, I managed to make the GF buyer script hop worlds if it completed a trade (using a second account to activate trades n stuff), made it bank everything and accept any trade etc. and THINK I have this coded slightly right using those references... If it is just a complete fail, please just tell me so, and I will try again rather than asking you nice people to help me learn and rebuild the entire code if it's already FUBAR lol.
Ok, the reason I can't wrap my head around how to do this is as follows - The short code below would (i think) Check to see has it been 30 seconds since announced, if so, announce, then log a NEW announcetime
if (System.currentTimeMillis() > (announceofferTime + 30000)) {
typeStringInstant("Buying Santa Hats");
announceofferTime = System.currentTimeMillis() ;
So, I am not sure how to trigger it for the very first time, as in, how can it check ">" against a value that has yet to be written to begin the cycle? I thought, perhaps, the first line could trigger off the startTime in the script, but then how to make it switch to checking the announceofferTime henceforth. If this is harder than I am assuming it is, I don't expect anyone to waste a lot of valuable time so some noob can piddle around with scripting, but if there are simple methods that I am missing and someone could give me a push the right direction I would appreciate it tremendously.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ScriptManifest(author = "ThatGuy", info = "Announces Buy, Trades, Hops, Rinse&Repeat", name = "GE Buddy", version = 1.0, logo = "")
public class GeBuddy extends Script {
@Override
public void onStart() {
log("Let's Buy Stuff & Things");
}
long startTime;
long announceofferTime;
long tradeTime;
public int onLoop() throws InterruptedException {
startTime = System.currentTimeMillis();
if (!getInventory().isEmpty()) {
if (getBank().open()) {
if (getBank().depositAll()) {
if (getBank().close()) {}
} else {
if (System.currentTimeMillis() > (startTime + 300000)) {
if (getWorlds().hopToP2PWorld()) {
} else
if (!getTrade().isCurrentlyTrading()) {
if (getTrade().getRequestListener() != null) {
if (getTrade().getLastRequestingPlayer() != null) {
if (getTrade().getLastRequestingPlayer().interact("Trade with")) {
tradeTime = System.currentTimeMillis();
} else {
}
new ConditionalSleep(10000) {
@Override
public boolean condition() throws InterruptedException {
return (!getInventory().isEmpty());
}
}.sleep();
}