Screens created inside of a closing screen's callback are broken
chililisoup opened this issue ยท 0 comments
With nested GUIs, it can sometimes be nice to go back a screen when pressing ESC instead of closing the menu outright.
However, creating a new screen upon your current screen being closed brings up a few problems:
- You have to close the screen in the script before opening a new one, or the first screen's callback will get called many times, sometimes bringing up a "Your thoughts are too deep" error
- The new screen will get displayed, but is unable to be interacted with from the script after initialization
Here is a script showcasing the issue:
__command() -> (
first_screen = create_screen(player(),'generic_3x3','Working Screen',_(screen, player, action, data) -> (
if (action == 'close',
close_screen(screen); //# Prevents open_new_screen from being fired many many times
open_new_screen();
);
));
);
open_new_screen() -> (
new_screen = create_screen(player(),'generic_3x3','Broken Screen',_(screen, player, action, data) -> (
print(action); //# Will print 'slot_update' for every filled slot already in your inventory, then breaks
return('cancel') //# Nothing gets cancelled
));
inventory_set(new_screen, 0, 1, 'stone'); //# Does not set stone
);
Maybe the screens are getting confused with each other in some places?