The client is offline due to RuneScape update. You may see instance errors but this is due to the update and not actual instance errors. This should be resolved soon. Join our Discord for more information.

GUI Text Overlay



  • Hey,

    This is a very basic method to give the user from your script some feedback.

    In this snippet we are going to show the user wich task is getting executed, how long the script is running, how many ores we've already mined and the amount of ores we can get per hour.

    I am not going to show how to mine ores, but only how to show the text overlay.

    alt text

    import org.rspeer.runetek.api.commons.StopWatch;
    import org.rspeer.runetek.api.commons.Time;
    import org.rspeer.runetek.event.types.RenderEvent;
    import org.rspeer.script.Script;
    import org.rspeer.script.ScriptMeta;
    import org.rspeer.runetek.event.listeners.RenderListener;
    import java.awt.*;
    import java.util.concurrent.TimeUnit;
    
    
    @ScriptMeta(name = "[LUX] GUI Text Overlay", desc = "Shows stats on GUI", developer = "Luxiflex", version = 1.0)
    
    //Make sure that your script implements RenderListener!!!!!
    public class TextOverlay extends Script implements RenderListener {
    
        String task = "";
        long oresMined = 0;
        StopWatch stopWatch;
    
        @Override
        public void onStart(){
            stopWatch = StopWatch.start();
        }
    
        @Override
        public int loop() {
            //execute your script here...
            //This script will mine an ore every 3 seconds and banks for 15 seconds every time we have mined 28 ores.
            oresMined ++;
            if(oresMined % 28 == 0 && oresMined > 0){
                task = "Banking...";
                Time.sleep(15000);
            }else{
                task = "Mining ores...";
                Time.sleep(3000);
            }
            return 0;
        }
    
        @Override
        public void notify(RenderEvent e) {
            //runtime in seconds.
            long seconds = stopWatch.getElapsed().getSeconds();
            long ores = oresMined;
            long oresPerHour = 0;
            //calculate ores per hour
            if(seconds>0){
                oresPerHour =  ores * 3600 / seconds;
            }
            //Initialize our graphics
            Graphics g = e.getSource();
            Graphics2D g2 = (Graphics2D) g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            int y = 35;
            int x = 10;
            g2.setColor(Color.green);
            g2.drawString("[LUX] GUI Text Overlay", x, y);
            g2.drawString("Task: " + task, x, y += 20);
            g2.drawString("Runtime: " + stopWatch.toElapsedString(), x, y += 20);
            g2.drawString("Ores mined: " + oresMined, x, y += 20);
            g2.drawString("Ores per hour: " + oresPerHour, x, y += 20);
        }
    }
    

    Please let me know if you found this usefull, if there is enough animo for this, I will create a more detailed tutorial with better looking graphics instead of text only, import images and an XP tracker.


  • Script Writer

    FYI you can use the StopWatch class to keep track of runtime and get hourly rates. You won't have to worry about formatting or any sort of calculations, it's pretty straightforward.



  • @Constellation Thanks!! updated the script.



  • This post is deleted!

 

57
Online

15.4k
Users

1.3k
Topics

18.6k
Posts