kingvitamin 0 Share Posted June 5, 2016 put this in your Main class private ClasName classname; public void onStart() { classname = new ClasName(this); } Then to make a new class public class ClasName { AbstractScript s; public ClasName (AbstractScript ctx) { this.s = ctx; } } Isn't 'this' of the type main (or whatever your main class is called)? Can you pass this into a class constructor expecting a AbstractScript? EDIT: I ask because i'm trying to do this and my IDE complains... Link to comment Share on other sites More sharing options...
slasso 27 Share Posted June 5, 2016 the key Isn't 'this' of the type main (or whatever your main class is called)? Can you pass this into a class constructor expecting a AbstractScript? EDIT: I ask because i'm trying to do this and my IDE complains... The keyword 'this' means an object of the class in which you use this keyword. If you have your class that extends AbstractScript you can pass 'this' to a constructor of some other object that takes an AbstractScript, as in Diddy's example. If you're getting an error make sure that you have the correct spelling and imports. Link to comment Share on other sites More sharing options...
deathsgrasp 0 Share Posted June 5, 2016 I think what you are looking for is both what Dreamlicker posted and implementing a type of Node framework (there are already a few posts on the forums about that). If you want a better understanding of how all that works, from a CS standpoint, you might want to look up Polymorphism and Inheritance. It is also important to understand how Constructor's work when trying to do all of this. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.