Jump to content

Getting information about myPlayer from the gui class


roguehippo

Recommended Posts

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
Link to comment
Share on other sites

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);
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...