choucter 1 Posted July 8, 2021 I'm hoping there's a solution for my issue. I have a woodcutter script with a GUI selection for the tree type, and I want the GUI to display the best tree based on woodcutting skill level. I wrote the code to get the best tree and it works fine. I can set the GUI display using comboBox.setSelectedItem("Oak"); and that works fine. But when I use the variable 'bestTree' instead of "Oak", the GUI always shows null. I'm guessing that the GUI executes before onStart which is where I compute the best tree. I tried adding a long sleep in the GUI but that simply stopped everything for a minute and the GUI was still null when the script resumed. I'm out of ideas. Does anyone have any suggestions that I can try?
TheCloakdOne 389 Posted July 8, 2021 You might need to post some more code for us to help you out, your not assigning bestTree to anything in that snippet, you will need to do something like bestTree = (string) comboBox.getSelectedItem() to set the variable before using it
choucter 1 Author Posted July 8, 2021 @TheCloakedOne, thanks for the response. You helped me get past my null problem i.e. I has bad code for the 'bestTree' setter as you suggested. My GUI no longer shows as blank, but it now shows "Tree" as the default (it's the first item in my array) instead of taking "Maple" from my bestTree variable. I'll play with the code some more now and see if I can fix it myself. If not, I may come back with my code and seek more help... thanks again.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.