Vilius Posted May 7, 2018 Posted May 7, 2018 2 hours ago, Apaec said: aren't all scripts state based? Technically yes, if they ude the task/node framework. Some frameworks are Event based with break conditions and other crap.
Alek Posted May 9, 2018 Posted May 9, 2018 boolean shouldExecute() { return getObjects.getAll().get("ABC") != null } void execute() { return getObjects.getAll().get("ABC").interact(); } 1 1
Vilius Posted May 9, 2018 Posted May 9, 2018 24 minutes ago, Alek said: boolean shouldExecute() { return getObjects.getAll().get("ABC") != null } void execute() { return getObjects.getAll().get("ABC").interact(); } Syntax error on line 2, missing ; 2
Alek Posted May 9, 2018 Posted May 9, 2018 Just now, Vilius said: Syntax error on line 2, missing ; it makes the task node system faster, less characters to compute.
Vilius Posted May 9, 2018 Posted May 9, 2018 Just now, Alek said: it makes the task node system faster, less characters to compute. No need to compile when you are missing parameters on line 6 cause eitherway you wouldnt do an action
FrostBug Posted May 9, 2018 Posted May 9, 2018 14 minutes ago, Vilius said: Syntax error on line 2, missing ; Not even commenting on the fact that he's using a List like a Map 1
liverare Posted May 9, 2018 Posted May 9, 2018 public enum Task { OPEN_BANK("Open bankies") { @Override public boolean validate(Bot bot) { return !bot.bank.isOpen(); } @Override public int execute(Bot bot) throws InterruptedException { if (bot.bank.open()) { bot.logger.debug("*YAY*"); } return 250; } } ; private final String name; private Task(String name) { this.name = name; } public abstract boolean validate(Bot bot); public abstract int execute(Bot bot) throws InterruptedException; @Override public String toString() { return name; } }
Alek Posted May 9, 2018 Posted May 9, 2018 1 hour ago, liverare said: public enum Task { OPEN_BANK("Open bankies") { @Override public boolean validate(Bot bot) { return !bot.bank.isOpen(); } @Override public int execute(Bot bot) throws InterruptedException { if (bot.bank.open()) { bot.logger.debug("*YAY*"); } return 250; } } ; private final String name; private Task(String name) { this.name = name; } public abstract boolean validate(Bot bot); public abstract int execute(Bot bot) throws InterruptedException; @Override public String toString() { return name; } } Bank open() checks if your bank is already open, so you're still calling the same code twice. Not like it matters much though