私はプログラムのスクリプトに取り組んでおり、クライアントが特定の文字列の送信を検出した場合に、応答で指定されたアクションを実行する機能を追加しようとしています。
これが私の質問です。「ここ」が含まれているものを言うと、新しいタイルの配列に移動するように取得しようとしています。それで、メッセージが送信された場合にスクリプトを次の配列に移動させる方法はありますか?
これが私のコードです、そして私はその下で私の質問をよりよく説明します:
@ScriptDetails(author = "iSully", category = "Firemaking", description = "Burns Your Willow Logs So You Don't Have To!", name = "iFire - Willows", version = 1.1)
public class iFire extends Script implements Painter, LoopTask {
private static int logs;
private static final int tinderbox = 591;
private int loopCounter = 0;
private static final int fire = 2732;
private static final int ID_BANKBOOTH = 2213;
private FontMetrics FONTMETRICS = null;
private final Timer RUNTIME = new Timer();
private String STATE = "";
private int Burnt = 0;
private int XP = 0;
public boolean guiWait = true;
gui g = new gui();
Tile[] toFire1 = new Tile[] { new Tile(2722, 3493, 0),
new Tile(2725, 3489, 0), new Tile(2725, 3485, 0),
new Tile(2734, 3486, 0) };
Tile[] fire1ToBank = new Tile[] { new Tile(2711, 3486, 0),
new Tile(2716, 3484, 0), new Tile(2721, 3486, 0),
new Tile(2725, 3489, 0), new Tile(2722, 3493, 0) };
Tile[] toFire2 = new Tile[] { new Tile(2721, 3493, 0), new Tile(2723, 3488, 0), new Tile(2720, 3484, 0),
new Tile(2715, 3483, 0), new Tile(2710, 3483, 0), new Tile(2708, 3483, 0) };
Tile[] toFire3 = new Tile[] { new Tile(2722, 3493, 0), new Tile(2725, 3489, 0), new Tile(2721, 3486, 0),
new Tile(2716, 3485, 0), new Tile(2711, 3485, 0), new Tile(2706, 3485, 0),
new Tile(2706, 3484, 0) };
Tile[] fire3ToBank = new Tile[] { new Tile(2683, 3484, 0), new Tile(2688, 3484, 0), new Tile(2695, 3484, 0),
new Tile(2701, 3484, 0), new Tile(2706, 3484, 0), new Tile(2711, 3485, 0),
new Tile(2716, 3485, 0), new Tile(2721, 3485, 0), new Tile(2724, 3489, 0),
new Tile(2721, 3493, 0) };
Tile[] fire2ToBank = new Tile[] { new Tile(2680, 3482, 0), new Tile(2686, 3482, 0), new Tile(2691, 3482, 0),
new Tile(2696, 3484, 0), new Tile(2701, 3485, 0), new Tile(2706, 3485, 0),
new Tile(2711, 3485, 0), new Tile(2716, 3485, 0), new Tile(2721, 3485, 0),
new Tile(2723, 3490, 0), new Tile(2721, 3493, 0) };
Tile[] toFire4 = new Tile[] { new Tile(2721, 3493, 0), new Tile(2724, 3489, 0), new Tile(2721, 3485, 0),
new Tile(2716, 3484, 0), new Tile(2711, 3484, 0), new Tile(2708, 3485, 0) };
Tile[] fire4ToBank = new Tile[] { new Tile(2682, 3484, 0), new Tile(2688, 3484, 0), new Tile(2695, 3484, 0),
new Tile(2700, 3484, 0), new Tile(2705, 3483, 0), new Tile(2710, 3483, 0),
new Tile(2716, 3483, 0), new Tile(2721, 3482, 0), new Tile(2722, 3487, 0),
new Tile(2721, 3492, 0), new Tile(2720, 3493, 0) };
private ArrayList<Strategy> strategy = new ArrayList<Strategy>();
protected boolean onExecute() {
strategy.add(new a1());
provide(strategy);
g.setVisible(true);
while (guiWait == true) {
BotGUI.log("Starting up....");
sleep(10000);
}
return (true);
}
public void paint(Graphics g) {
if (FONTMETRICS == null) {
FONTMETRICS = g.getFontMetrics();
RUNTIME.start();
}
drawGradientText(g, "Runtime: " + RUNTIME.getElapsedTime(), 15, 200,
Color.red);
drawGradientText(g, "State: " + STATE, 15, 218, Color.red);
drawGradientText(g, "Logs Burnt: " + Burnt + "", 15, 236, Color.red);
}
public class a1 extends Strategy {
public boolean isValid() {
BotGUI.log("Script Started!");
return true;
}
public void run() {
Camera.setPitch(true);
}
}
protected void onFinish() {
BotGUI.log("Script Stopped! Thanks for using iFire by iSully!");
BotGUI.log("Please leave feedback on the Parabot forum");
}
public int loop() {
bank();
toFire1();
lightFires();
toBank1();
bank();
toFire2();
lightFires();
toBank2();
bank();
toFire3();
lightFires();
toBank3();
bank();
toFire4();
lightFires();
toBank4();
loopCounter++;
return 1000;
}
void toBank1() {
STATE = "Walking To Bank";
Path path = new Path(fire1ToBank);
while (!path.hasReached()) {
while (!Players.getMyPlayer().isMoving()) {
Walking.getPath(fire1ToBank).traverse();
}
}
}
void toBank2() {
STATE = "Walking To Bank";
Path path = new Path(fire2ToBank);
while (!path.hasReached()) {
while (!Players.getMyPlayer().isMoving()) {
Walking.getPath(fire2ToBank).traverse();
}
}
}
void toFire1() {
STATE = "Walking To Burning Path #1";
Path path = new Path(toFire1);
while (!path.hasReached()) {
while (!Players.getMyPlayer().isMoving()) {
Walking.getPath(toFire1).traverse();
if(toFire1.equals(2732)){
toFire2();
}
}
}
}
void toFire2() {
STATE = "Walking To Burning Path #2";
Path path = new Path(toFire2);
while (!path.hasReached()) {
while (!Players.getMyPlayer().isMoving()) {
Walking.getPath(toFire2).traverse();
}if(toFire2.equals(2732)){
toFire3();
}
}
}
void toBank3() {
STATE = "Walking To Bank";
Path path = new Path(fire3ToBank);
while (!path.hasReached()) {
while (!Players.getMyPlayer().isMoving()) {
Walking.getPath(fire3ToBank).traverse();
}
}
}
void toFire3() {
STATE = "Walking To Burining Location #3";
Path path = new Path(toFire3);
while (!path.hasReached()) {
while (!Players.getMyPlayer().isMoving()) {
Walking.getPath(toFire3).traverse();
}if(toFire3.equals(2732)){
toFire4();
}
}
}
void toFire4() {
STATE = "Walking To Burining Location #4";
Path path = new Path(toFire4);
while (!path.hasReached()) {
while (!Players.getMyPlayer().isMoving()) {
Walking.getPath(toFire4).traverse();
}if(toFire4.equals(2732)){
toFire2();
}
}
}
void toBank4() {
STATE = "Walking To Bank";
Path path = new Path(fire4ToBank);
while (!path.hasReached()) {
while (!Players.getMyPlayer().isMoving()) {
Walking.getPath(fire4ToBank).traverse();
}
}
}
void closeBank() {
if (Walking.isRunEnabled() == false) {
Time.sleep(1000); // 1600
Mouse.hop(460, 41);
Time.sleep(500); // 900
Mouse.click(460, 41, true);
Time.sleep(500); // 1000
}
}
void bank() {
GameObject bankBooth = GameObjects.getNearest(ID_BANKBOOTH);
if (!bankBooth.isOnScreen()) {
Camera.turnTo(bankBooth);
}
while (!Bank.isOpen()) {
bankBooth.interact("Use-quickly");
Time.sleep(2000);
}
while (!Inventory.isFull()) {
Bank.withdraw(logs, 27);
Time.sleep(500);
}
}
private boolean isLighting() {
return Players.getMyPlayer().getAnimation() != -1;
}
void lightFires() {
STATE = "Lighting Fires";
while (Inventory.contains(logs)) {
if (isLighting() == false) {
Inventory.getItem(tinderbox).interact("Use");
Inventory.getItem(logs).interact("Use Tinderbox with");
Burnt++;
Time.sleep(3000);
} else {
Time.sleep(4500);
}
}
}
void useRun() {
if (Walking.isRunEnabled() == false) {
Time.sleep(1000);
Mouse.hop(710, 485);
Time.sleep(500);
Mouse.click(710, 485, true);
Time.sleep(1000);
Mouse.hop(625, 270);
Time.sleep(500);
Mouse.click(625, 270, true);
Time.sleep(500);
Mouse.hop(650, 185);
Time.sleep(1000);
Mouse.click(650, 185, true);
Time.sleep(random(750, 1250));
}
}
public void drawGradientText(Graphics g, String text, int x, int y, Color c) {
Graphics2D g2 = (Graphics2D) g;
Color color3 = new Color(51, 51, 51, 205);
Font font1 = new Font("Arial", 0, 12);
g.setFont(font1);
FONTMETRICS = g.getFontMetrics();
Rectangle textBox = new Rectangle(x, y - g.getFont().getSize(),
(int) FONTMETRICS.getStringBounds(text, g).getWidth() + 8,
(int) FONTMETRICS.getStringBounds(text, g).getHeight() + 5);
Paint defaultPaint = g2.getPaint();
g2.setPaint(new RadialGradientPaint(new Point.Double(textBox.x
+ textBox.width / 2.0D, textBox.y + textBox.height / 2.0D),
(float) (textBox.getWidth() / 2.0D),
new float[] { 0.5F, 1.0F }, new Color[] {
new Color(color3.getRed(), color3.getGreen(), color3
.getBlue(), 175),
new Color(0.0F, 0.0F, 0.0F, 0.8F) }));
g.fillRect(textBox.x, textBox.y + 12, textBox.width, textBox.height);
g2.setPaint(defaultPaint);
g.setColor(Color.WHITE);
g.drawRect(textBox.x, textBox.y + 12, textBox.width, textBox.height);
g.setColor(Color.WHITE);
g.drawString(text, x + 4, y + 15);
for (int i = 0; i < text.length(); i++) {
if (Character.isDigit(text.charAt(i))) {
g.setColor(new Color(255, 255, 255));
g.drawString("" + text.charAt(i),
x + FONTMETRICS.stringWidth(text.substring(0, i)) + 4,
y + 15);
}
}
}
public class Timer {
long millis;
/**
* Starts the timer
*/
public void start() {
millis = System.currentTimeMillis();
}
/**
* Resets the timer
*/
public void reset() {
millis = 0;
}
/**
* Determines if timer is running
*
* @return <b>true</b> if timer is running
*/
public boolean isRunning() {
return millis != 0;
}
/**
* Generates string based on HH:MM:SS
*
* @return String
*/
public String getElapsedTime() {
long elapsedTime = System.currentTimeMillis() - millis;
String format = String.format("%%0%dd", 2);
elapsedTime = elapsedTime / 1000;
String seconds = String.format(format, elapsedTime % 60);
String minutes = String.format(format, (elapsedTime % 3600) / 60);
String hours = String.format(format, elapsedTime / 3600);
String time = hours + ":" + minutes + ":" + seconds;
return time;
}
/**
* Calculates Experience per hour based on timer
*
* @param Gained
* experience
* @return Experience per hour
*/
public int getEXPHour(int xpgained) {
return (int) ((xpgained) * 3600000D / (System.currentTimeMillis() - millis));
}
}
public void messageRecieved(String message) {
if (message.toLowerCase().contains("burn")) {
Burnt++;
if(message.toLowerCase().contains("here")){
}
}
}
さて、私のスクリプトでは、1つの番号を除いて同じ複数の配列があります。例:toFire1、toFire2、toFire3、toFire4、fire1ToBank、fire2ToBank、fire3ToBank、fire4ToBank。さて、スクリプトで実行したくないのは、メソッド「public void messageRecieved」(下部)で、次のタイル配列リストに移動したくないということです。次の配列に移動するには、どのような演算子を使用しますか?このスクリプトはループで実行されるため、toFire1からtoFire2に毎回実行することはできません。