tarac Posted November 7, 2021 Share Posted November 7, 2021 I just had this simple Idea for my first mod, to autopause when opening a chest. I saw on the QoL notes that you could add "setAutopause(true)" at the constructor of a screen to pause the game Spoiler On 9/27/2021 at 2:12 PM, zarklord_klei said: If you want your screen to autopause the game, you must do the following: Add the following code to the constructor of your screen: SetAutopaused(true) Add/Create the following to the OnDestroy function of your screen: SetAutopaused(false) But when you open a chest it uses a widget, not a screen turns out, so simply SetAutopause(true) on the widget Open() function, throws me "153: attempt to call global 'SetAutopaused' (a nil value)", using GLOBAL.SetAutopause(true) does pause the game without crashing but I cant unpause with the normal pause button, so I made an AddKeyDownHandler with a GLOBAL.SetAutopause(false) and it "works", Im now able to unpause. basically my modmain is just: Spoiler function ContainerWidget:Open(container, doer) --normal code GLOBAL.SetAutopaused(true) GLOBAL.TheInput:AddKeyDownHandler(keybind, function() GLOBAL.SetAutopaused(false) Im asking if someone knows more about how the pause features work, is there a way to pause in the same way the normal "pause key" does? or just general ideas on how to implement this better, I spent almost all my free time doing Find in Files to try to understand it instead of actually playing the game xD Link to comment https://forums.kleientertainment.com/forums/topic/135118-help-adding-autopause-to-widgets/ Share on other sites More sharing options...
penguin0616 Posted November 7, 2021 Share Posted November 7, 2021 You have the opening part done fine, but you need to remember to unpause when the container closes. Link to comment https://forums.kleientertainment.com/forums/topic/135118-help-adding-autopause-to-widgets/#findComment-1511457 Share on other sites More sharing options...
tarac Posted November 8, 2021 Author Share Posted November 8, 2021 Thats the thing you can´t actually close the chest when autopaused, I was thinking about adding a "close" button to the widget... Now I noticed opening a Crockpot crashes with Spoiler [string "scripts/widgets/text.lua"]:86: calling 'SetFont' on bad self (string expected, got nil) , Im thinking it`s because Im pausing the game before the animation for opening the widget ends (otherwise I dont undestand why because It should be doing the same thing as the vanilla open() ), I`ll play around to try pause after the anim finishes Link to comment https://forums.kleientertainment.com/forums/topic/135118-help-adding-autopause-to-widgets/#findComment-1511636 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now