Jump to content

Getting information about myPlayer from the gui class


Recommended Posts

Posted (edited)
class GUI{
    MethodProvider m;
    public GUI(MethodProvider m){
        this.m = m;
    }

    //example method
    private Position getPos(){
        return m.myPlayer().getPosition();
    }
}

class YourScript extends Script{
    GUI gui = new GUI(this);

    public void onStart(){
        gui.setVisible(true);
    }
}

Something like that should work smile.png

Edited by Vilius
Posted

i dont quite understand what you mean by passing around a reference to the script class. how would i reference it? and are you talking about my main class?

in your new class:

 

MethodProvider script;
 
public yourclass(MethodProvider _script) //constructor
{
   this.script = _script;
}
 
public void somemethod()
{
   script.myPlayer().something;
}
 
in your main class
yourclass c = new yourclass(this);

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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