macalroy Posted August 25, 2016 Share Posted August 25, 2016 (edited) I don't know how to connect the Script variables or anything related to the Controller class for the JavaFX application, any ideas? Edited August 25, 2016 by Orient Quote Link to comment Share on other sites More sharing options...
Tom Posted August 25, 2016 Share Posted August 25, 2016 Pass the script instance into the class? Quote Link to comment Share on other sites More sharing options...
macalroy Posted August 25, 2016 Author Share Posted August 25, 2016 Pass the script instance into the class? JavaFX applications need a no-args constructor and the controller class doesn't take the argument and act as a controller for some reason Quote Link to comment Share on other sites More sharing options...
Tom Posted August 25, 2016 Share Posted August 25, 2016 JavaFX applications need a no-args constructor and the controller class doesn't take the argument and act as a controller for some reason I see, I've never touched JavaFX so I'm not exactly sure how to do this the best way. Have you seen this? http://stackoverflow.com/questions/30814258/javafx-pass-parameters-while-instantiating-controller-class Alternatively, if you don't really care about the code design you could just have a static getter in your main class, or in some sort of data class. Quote Link to comment Share on other sites More sharing options...
Token Posted August 25, 2016 Share Posted August 25, 2016 (edited) // don't forget the manifest public class Unicorns extends Script { public static Script script; @ Override public void onStart() { script = this; } @ Override public int onLoop() { return 69; } } This wonderful piece of code solves all your OOP problems Edited August 25, 2016 by Token Quote Link to comment Share on other sites More sharing options...
macalroy Posted August 25, 2016 Author Share Posted August 25, 2016 (edited) I see, I've never touched JavaFX so I'm not exactly sure how to do this the best way. Have you seen this? http://stackoverflow.com/questions/30814258/javafx-pass-parameters-while-instantiating-controller-class Alternatively, if you don't really care about the code design you could just have a static getter in your main class, or in some sort of data class. Alright, well I can't pass arguments to the Controller/Test classes properly so I'll have to do that. How can I go about doing that because it won't let me reference Script from a static context // don't forget the manifest public class Unicorns extends Script { public static Script script; @ Override public void onStart() { script = this; } @ Override public int onLoop() { return 69; } } This wonderful piece of code solves all your OOP problems I think I'm retarded Edited August 25, 2016 by Orient 1 Quote Link to comment Share on other sites More sharing options...
Tom Posted August 25, 2016 Share Posted August 25, 2016 // don't forget the manifest public class Unicorns extends Script { public static Script script; @ Override public void onStart() { script = this; } @ Override public int onLoop() { return 69; } } This wonderful piece of code solves all your OOP problems Feel like starting a debate so Ill go ahead and say that I wouldn't call it wonderful, bad code design and lack of encapsulation. Your turn. Quote Link to comment Share on other sites More sharing options...
macalroy Posted August 25, 2016 Author Share Posted August 25, 2016 Feel like starting a debate so Ill go ahead and say that I wouldn't call it wonderful, bad code design and lack of encapsulation. Your turn. Well, there's really no alternative in this case unless you can somehow pass a constructor to an application class to retrieve the Script methods. Quote Link to comment Share on other sites More sharing options...
Tom Posted August 25, 2016 Share Posted August 25, 2016 Well, there's really no alternative in this case unless you can somehow pass a constructor to an application class to retrieve the Script methods. As a further note, I don't think you should be accessing Script methods in your JavaFX, instead of creating a Script instance, create a Unicorns instance (as demonstrated in @@Token's demonstration) and use that to pass the needed data into main. Just a thought, don't have to do it but I think its better practice 1 Quote Link to comment Share on other sites More sharing options...
Token Posted August 25, 2016 Share Posted August 25, 2016 Feel like starting a debate so Ill go ahead and say that I wouldn't call it wonderful, bad code design and lack of encapsulation. Your turn. It decreases the stack frame size on all methods that require access to your Script instance by 64 bits Your turn. Quote Link to comment Share on other sites More sharing options...
macalroy Posted August 25, 2016 Author Share Posted August 25, 2016 (edited) As a further note, I don't think you should be accessing Script methods in your JavaFX, instead of creating a Script instance, create a Unicorns instance (as demonstrated in @@Token's demonstration) and use that to pass the needed data into main. Just a thought, don't have to do it but I think its better practice Well, I'm just grabbing things like name among other things, I just needed to gain access to those Nope, still retarded. Just going to pull the data from a separate class like a good little boy. Don't know what I'm talking about. Edited August 25, 2016 by Orient Quote Link to comment Share on other sites More sharing options...
Tom Posted August 25, 2016 Share Posted August 25, 2016 (edited) It decreases the stack frame size on all methods that require access to your Script instance by 64 bits Your turn. Who cares this is runescape your turn I used all my cards in my first reply, i concede defeat Edited August 25, 2016 by Tom Quote Link to comment Share on other sites More sharing options...
Token Posted August 25, 2016 Share Posted August 25, 2016 Who cares this is runescape your turn your turn Quote Link to comment Share on other sites More sharing options...
Tom Posted August 25, 2016 Share Posted August 25, 2016 your turn Edited my post 3 times while you were creating this reply, your turn Quote Link to comment Share on other sites More sharing options...
Token Posted August 25, 2016 Share Posted August 25, 2016 Edited my post 3 times while you were creating this reply, your turn I was desperately browsing stackoverflow for an answer to "this is runescape" so as not to look overwhelmed by your argument while you were editting your reply your turn Quote Link to comment Share on other sites More sharing options...