Note that there are some explanatory texts on larger screens.

plurals
  1. POOperator for switching between different arrays, more precise inside
    primarykey
    data
    text
    <p>I'm working on a script for a program and I'm trying to add a feature where if the client detects a certain string being sent, and does an action specified in response.</p> <p>Here is my question, I'm trying to get it so that when it says anything with "here" in it, then it will move to a new array of tiles! So, is there a way where I can make the script go to the next array if the message is sent?</p> <p>Here is my code, and i will explain my question better below it:</p> <pre><code>@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&lt;Strategy&gt; strategy = new ArrayList&lt;Strategy&gt;(); 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 &lt; 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 &lt;b&gt;true&lt;/b&gt; 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")){ } } } </code></pre> <p>Okay, so in my script, i have multiple arrays that are the same except for one number, example: toFire1, toFire2, toFire3, toFire4, fire1ToBank, fire2ToBank, fire3ToBank, fire4ToBank. Now, what I wan't the script to do is, in the method "public void messageRecieved" (at the bottom), I wan't it to move to the next tile array list that I have. What kind of operator would I use to make it move on to the next array? Keep in mind, this script run's in a loop so I can't just make it go to lets say, from toFire1, onto toFire2 every time! </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload