Jump to content

Help with runtime scripts


Nbacon

Recommended Posts

So I made scheme in java its a flavor of lips (Lost in Stupid Parentheses). The programing language looks terrible for someone that used to java but whatever.  The beauty of it is that you can make new run time programs. So I have a way to update programs over sockets ( they cost alot in ram) and don’t know anything about swing/awt. I would like to click a button on the botscreen that would update the code from a file or just automaticly after code goes into a file.

[example code makes glass orbs]

(define makepart
  (lambda ()
    (cond
      ((bankopen?)(closebank))
      ((Animation?)(wait))
      ((makeall?)(makeall 7))
      ((not (use? 1785) )(interact 1785))
      (else (interact 567)))))
            
(define bankpart
  (lambda ()
    (if(not (bankopen?))
       (bankopen)
       (and (getitem? 1785 1)(getitem 567 "all") )

(define loop
  (lambda ()
    (if (not (invhas? 567 ))
        (makepart)
        (bankpart))))

my java code (not alot of help)

import com.bacon.bot.scheme.Scheme;
import org.osbot.rs07.script.Script;
import com.bacon.bot.network.Client_sock;
import org.osbot.rs07.script.ScriptManifest;

import java.io.StringReader;

@ScriptManifest(author = "Bacon", name = "lisp" + ScemeBot.VERSION, info = "Runtime bots", version = 0, logo = "")

public class ScemeBot extends Script {
    static final String VERSION = " 0.0023";
    Scheme  x ;
    Client_sock xx = new Client_sock(8888);

    @Override
    public void onStart() throws InterruptedException {
        x =new Scheme(this);
        log( x.eval("(define test" +
                "    (lambda () \n" +
                "    (if (bankopen?)\n" +
                "           (bankclose)\n" +
                "           (bankopen)\n" +
                "            )))"));
        log(x.eval("(test)"));
        log("bot works");
        log(x.eval("(start)"));
    }


    @Override
    public int onLoop() throws InterruptedException {

        if(xx.hasUpdate()){

            x.eval(xx.update());
        }

      log(x.eval("(Loop)"));


       return 700;
    }




    @Override
    public void pause() {
        log(x.eval("(pause)"));
    }

    @Override
    public void resume() {
        log(x.eval("(resume)"));
    }

    @Override
    public void onExit() {
        log(x.eval("(exit)"));
    }

}

The automatic code reading would be the best so i dont have to fuck with GUI'S.

Thanks.

 

Edited by Nbacon
Error
  • Like 2
Link to comment
Share on other sites

Amazing Quote.❤️

dreameo  I have used Event Handlers when making my muti-boxer. I thought you could just add a button to the bot screen (but thats not the case?). So the only way to add the button is to draw a rectangle and do some math that says clicked in side x,y and x',y'.  

I came up this that checks for updates evey 5 ish min and everytime you pause.

  @Override
    public void onStart() throws InterruptedException {
		...
        fileShit();
    }
    int counter= 0;
    @Override
    public int onLoop() throws InterruptedException {
        if (counter%450==0){
            fileShit();
        }
        counter++;
		log(x.eval("(loop)"));
        return 700;
    }
    private long size=0;
    private long amount=0;
    private void fileShit(){
        File folder = new File(getDirectoryData() + File.separator + "bacon_runtime");
        File[] files = folder.listFiles();
        long sizeHolder =0;
        long amountHolder =files.length;
        for (File file : files) {
            sizeHolder  +=file.length();
        }
        if (sizeHolder!=size || amount !=amountHolder){
            x.reset();
            size=sizeHolder;
            amount=amountHolder;
			BufferedReader br = null;
            for (File file : files) {
                try {
                    br = new BufferedReader(new FileReader(file));
                    String st;
                    while ((st = br.readLine()) != null) {
                        log(x.eval(st));
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }


    @Override
    public void pause() {
        fileShit();
        log(x.eval("(pause)"));
    }

 

 

 

Link to comment
Share on other sites

@Override
  public void onStart() throws InterruptedException {
  getBot().getMouseListeners().add(new BotMouseListener() {
    @Override
      public void checkMouseEvent(MouseEvent mouseEvent) {
      // on shift + left click
      if(mouseEvent.getModifiersEx() == 1088){

      }
    }
  });
}

 

Didn't find any documentation but this will do (for win 10 at least).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...