Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

drawing on a tile?

Featured Replies

what is the best way to highlight a tile. im trying to iterate through a list of positions but when i try to use g.drawPolygon (as suggested by other threads on the forum) it just gives me a red underline and sys drawpolygon is undefined. did they change how tiles are highlighted? thanks!

edit for visibility of the real problem i need help with still :(

---------------------------------------------------

my gui class seems to not be able to use myPlayer().getlocation effectively because i always just get a null pointer when the code executes.

this is the snippet of code

 

JButton SetSpotButton = new JButton("Set Safe Spot");
SetSpotButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(CustomSpotButton.isSelected())
{
SafeSpot = m.myPlayer().getPosition();
}
}
});
if the button is pressed and a checkbox is checked to use the method then it tries to save the tile i am standing on.
 
also my "m" is a global in my gui so i dont know why its not working sad.png
MethodProvider m;
public Gui(MethodProvider m){
       this.m = m;
   } 
 

 

Edited by roguehippo

  • Author

i have no idea

 


graphics.draw(position.getPolygon(bot))

hey frost, thanks for the help, but it still says that "graphics" cannot be resolved do i have to import a source into my script?

i have no idea

 

hey frost, thanks for the help, but it still says that "graphics" cannot be resolved do i have to import a source into my script?

public class GodWarsDungeon extends Script { 
private Position position = new Position(0,0,0); // obviously have the correct co-ordinates
//in your onPaint do this
 
@[member='Override']
public void onPaint(Graphics2D g) {
g.draw(position.getPolygon(bot));



}

Do you have to give it a name or something?

 

 

The reason why graphics did not resolve was because by default your onPaint(Graphics2D g) is set at g so you can change that to whatever you want :P (the g part)

  • Author

facep.gif facep.gif facep.gif facep.gif  i forgot about onPaint... i havent coded in like all summer. my b


public class GodWarsDungeon extends Script { 
private Position position = new Position(0,0,0); // obviously have the correct co-ordinates
//in your onPaint do this
 
@[member='Override']
public void onPaint(Graphics2D g) {
g.draw(position.getPolygon(bot));



}

The reason why graphics did not resolve was because by default your onPaint(Graphics2D g) is set at g so you can change that to whatever you want :P (the g part)

 

this is a function i made to color the tiles of an area. im wondering if this is going to work, the only thing im worried about is it had me automatically set g2 = null. does it have to be something else? i havent tested it yet 

 

public void drawArea()
{
 
 
if(gui.ShowOverlay == true )
        {
Graphics2D g2 = null;
      
g2.setColor(Color.WHITE);
log("drawing tiles");
for(int i = 0;i < FightArea.getPositions().size(); i++ )
   {
    Polygon poly = FightArea.getPositions().get(i).getPolygon(bot);
    g2.draw(poly);
   }
        }
 
}

 

facep.gif facep.gif facep.gif facep.gif  i forgot about onPaint... i havent coded in like all summer. my b

this is a function i made to color the tiles of an area. im wondering if this is going to work, the only thing im worried about is it had me automatically set g2 = null. does it have to be something else? i havent tested it yet 

 

public void drawArea()
{
 
 
if(gui.ShowOverlay == true )
        {
Graphics2D g2 = null;
      
g2.setColor(Color.WHITE);
log("drawing tiles");
for(int i = 0;i < FightArea.getPositions().size(); i++ )
   {
    Polygon poly = FightArea.getPositions().get(i).getPolygon(bot);
    g2.draw(poly);
   }
        }
 
}

 

 

:s

 

I'm using this fellow's "Drawing Tiles" useful snippet: http://osbot.org/forum/topic/80826-useful-methods/?hl=fill and it works perfectly. smile.png

 

My snippet iterating through Positions:

for (Position p : fishingArea.getPositions() ) {
    drawTile(script, g, p, Color.pink, Color.white, "");
}

With drawTile() slightly modified from the link's example, looking like this:

/**
 * 
 * @param script	Most likely: client.getBot().getScriptExecutor().getCurrent()
 * @param g			The Graphics2D object passed into the onPaint() method
 * @param position	The Position for the tile you are wishing to draw on
 * @param tileColor	The color that will be drawn around the border of the tile
 * @param textColor	The color of the text for the "s" parameter
 * @param s			The text you wish to display next to the tile, if any.
 */
public void drawTile(Script script, Graphics g, Position position, Color tileColor, Color textColor, String s) {
	Polygon polygon;
	    if (position != null && (polygon = position.getPolygon(script.getBot(), position.getTileHeight(script.getBot()))) != null) {
	        g.setColor(tileColor);
	        for (int i = 0; i < polygon.npoints; i++) {
	            g.setColor(new Color(0, 0, 0, 20));
	            g.fillPolygon(polygon);
	            g.setColor(tileColor);
	            g.drawPolygon(polygon);
	        }
	        g.setColor(textColor);
	        g.drawString(s, (int) polygon.getBounds().getX(), (int) polygon.getBounds().getY());
	    }
	}

Edited by jython

  • Author

my gui class seems to not be able to use myPlayer().getlocation effectively because i always just get a null pointer when the code executes.

this is the snippet of code

 

JButton SetSpotButton = new JButton("Set Safe Spot");
SetSpotButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(CustomSpotButton.isSelected())
{
SafeSpot = m.myPlayer().getPosition();
}
}
});
if the button is pressed and a checkbox is checked to use the method then it tries to save the tile i am standing on.
 
also my "m" is a global in my gui so i dont know why its not working :(
MethodProvider m;
public Gui(MethodProvider m){
       this.m = m;
   } 

 

Edited by roguehippo

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.