This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Twijn's profile picture

Program not returning weirdly

Started by Twijn, 05 December 2015 - 03:03 AM
Twijn #1
Posted 05 December 2015 - 04:03 AM
For some reason, with my Settings program, whenever you change a setting in there, the program will not close without using ctrl + t. I'm assuming it's some big mess up that I caused, but I cannot seem to find anything.

The code: https://github.com/Twijn/DevOS/blob/master/DevOS/SystemFiles/Settings

For any of those thinking that I could do this in so many better ways I know, it's just an issue when you want to support third party programs to put things into the settings. (to me, at least)
KingofGamesYami #2
Posted 05 December 2015 - 04:17 AM
https://github.com/Twijn/DevOS/blob/master/DevOS/SystemFiles/Settings#L239

This line is an infinite loop, I can't see anywhere that updates the stopend variable.
Twijn #3
Posted 05 December 2015 - 05:02 PM
https://github.com/T...s/Settings#L239

This line is an infinite loop, I can't see anywhere that updates the stopend variable.
At the start of the redraw function, if the table "tab" (also passed to the function) and the "stopend" variable (passed to the redraw function) is false then it will set stopend to true, making the loop continue forever. I did this like this because ONLY when the parallel.waitForAny calls redraw should it never end, because if it always did this then it would end in the button API never returning, because when redraw is called in a button api function then it will get stuck on that and never finish it… I think

Then, when the exit button is pushed the variable "running" is set to false (the running variable makes the button api continue to loop) and it also updates the Button API by sending a fake queue event, causing the loop to end and the function to return, thus ending the parallel.

EDIT: Found something new.

It will only not return if you set Animations to false. If you also try and turn it back to true, it does not work as well. Additionally, the loop DOES finish. (tested by making it print something after the parallel). This makes be believe it's something wrong around this line/program: https://github.com/T...iles/Menus#L123

EDIT #2: I have fixed everything, it works fine now. The issue was that I had drawMenu in the file above inside of the animation check, instead of after it. I also realized I had the rclick function inside of the normal function, meaning you couldn't rightclick anything in the function after clicking a button.
Edited on 05 December 2015 - 04:15 PM