Pegasus Posted June 7, 2018 Share Posted June 7, 2018 (edited) does script cached files , variables? my private script made by myself read and write text file and bot according to the file, without gui. sometimes my private script is seem to cache files/variable and cannot run properly. I need to refresh script selector everytime? or what can I do? Edited June 7, 2018 by Pegasus Quote Link to comment Share on other sites More sharing options...
progamerz Posted June 7, 2018 Share Posted June 7, 2018 21 minutes ago, Pegasus said: does script cached files , variables? my private script made by myself read and write text file and bot according to the file, without gui. sometimes my private script is seem to cache files/variable and cannot run properly. I need to refresh script selector everytime? or what can I do? Depends on who made u the script, ask him, usually if it loads from textfile doesn't need, not sure, but its better always to refresh(personal preference) Quote Link to comment Share on other sites More sharing options...
Pegasus Posted June 7, 2018 Author Share Posted June 7, 2018 (edited) 14 minutes ago, progamerz said: Depends on who made u the script, ask him, usually if it loads from textfile doesn't need, not sure, but its better always to refresh(personal preference) my private script made by myself yes , it load from text file. There are some static variable in my script, is it the reason? Troublesome to refresh every times. it takes a few seconds to finishing refresh. Edited June 7, 2018 by Pegasus Quote Link to comment Share on other sites More sharing options...
progamerz Posted June 7, 2018 Share Posted June 7, 2018 1 minute ago, Pegasus said: my private script made by myself yes , it load from text file. There are some static variable in my script, is it the reason? Usually i don't think that can be the cause, but maybe on the "onExit()" reset the values of the variables, even tho if u always reload settings from .txt this shouldn't be the problem, not sure what u can do other than that, if u refresh in the script selector does the script work? Quote Link to comment Share on other sites More sharing options...
Pegasus Posted June 7, 2018 Author Share Posted June 7, 2018 Just now, progamerz said: Usually i don't think that can be the cause, but maybe on the "onExit()" reset the values of the variables, even tho if u always reload settings from .txt this shouldn't be the problem, not sure what u can do other than that, if u refresh in the script selector does the script work? yes , it works after refresh the script. Quote Link to comment Share on other sites More sharing options...
Chris Posted June 7, 2018 Share Posted June 7, 2018 yes static variables is why friend 1 Quote Link to comment Share on other sites More sharing options...
Alek Posted June 7, 2018 Share Posted June 7, 2018 50 minutes ago, Pegasus said: my private script made by myself yes , it load from text file. There are some static variable in my script, is it the reason? Troublesome to refresh every times. it takes a few seconds to finishing refresh. static variables as @Chris said. It's driven me crazy before too. 1 Quote Link to comment Share on other sites More sharing options...
Pegasus Posted June 7, 2018 Author Share Posted June 7, 2018 Thanks Chris Should I make all variables be non-static or just the one which affect the script? Quote Link to comment Share on other sites More sharing options...
Alek Posted June 7, 2018 Share Posted June 7, 2018 16 minutes ago, Pegasus said: Thanks Chris Should I make all variables be non-static or just the one which affect the script? You could reset variables on script start. I mean is there a reason the variables are static? Quote Link to comment Share on other sites More sharing options...
Pegasus Posted June 7, 2018 Author Share Posted June 7, 2018 2 minutes ago, Alek said: You could reset variables on script start. I mean is there a reason the variables are static? no reason , just ask Quote Link to comment Share on other sites More sharing options...
Explv Posted June 7, 2018 Share Posted June 7, 2018 (edited) 14 hours ago, Pegasus said: Thanks Chris Should I make all variables be non-static or just the one which affect the script? Make them all non-static, except for constants, which you can leave as static, but you should also make them final. There's very rarely a good reason to be using static, and it just causes a lot of pain. Edited June 7, 2018 by Explv Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted June 7, 2018 Share Posted June 7, 2018 I create a Singleton class for my Variables and reset them on script start. Quote Link to comment Share on other sites More sharing options...
Explv Posted June 7, 2018 Share Posted June 7, 2018 8 minutes ago, HeyImJamie said: I create a Singleton class for my Variables and reset them on script start. Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted June 7, 2018 Share Posted June 7, 2018 (edited) 3 hours ago, Explv said: Wat? public class Vars { private Vars() {} private static final Vars VARS = new Vars(); public static Vars get() { return VARS; } public String status; public int boneCount, deathCount; } Can then just call Vars.get().status and the instance is individual, while still having all my Variables are stored in one location. Constants are kept static like you said though. Edited June 7, 2018 by HeyImJamie Quote Link to comment Share on other sites More sharing options...