All pastes #252645 Raw Edit

Someone

public text v1 · immutable
#252645 ·published 2006-11-19 20:19 UTC
rendered paste body
import impsoft.ibot.methods.Script;

import java.awt.event.KeyEvent;

public class Compass extends Script {
    public static double version = 2.1;

    public static String[] commands = new String[] { "start Exp" };

    public static String author = "Ruler";

    public String description = " ";

    public boolean doStart(String cmd, String[] args) {
        return true;
    }

    public void script() throws InterruptedException {
        while (true) {
            sleep(3000);
            // refresh
            getColorArray2d(0);
            int startCompassDeg = getCompass();
            int millsecs = random(0, 2000);
            SendKey(KeyEvent.VK_LEFT, millsecs);
            sleep(2300);
            getColorArray2d(0);
            int endCompassDeg = getCompass();
            int change;
            if (startCompassDeg > endCompassDeg) {
                change = endCompassDeg + 360 - startCompassDeg;
            } else {
                change = endCompassDeg - startCompassDeg;
            }
            log("change=" + change + " millsecs=" + millsecs + "    "
                    + (double) (((double) change) / millsecs) + "   "
                    + startCompassDeg + " " + endCompassDeg);
        }
    }

    // like you to do this:
    public void setDegrees(int degrees) throws InterruptedException {
        int startCompassDeg = getCompass();
        int change = degrees - startCompassDeg;
        if (change > 180) {
            change -= 360;
        }
        int millsecs = change * 10;
        // VK_LEFT inceases compass degress
        SendKey(KeyEvent.VK_LEFT, millsecs);
    }
}