Jump to content

Check if the console is open


Recommended Posts

15 minutes ago, JohnWatson said:

I made a mod that relies on keystrokes, however, that makes it harder to type in the console because it would perform its functions while I'm typing in it. Is there a way to check if the console is open?

Mostly what is done is checking if the user is actively in-game via:

local function cz_hotkey_checker()
    local curScreen = TheFrontEnd:GetActiveScreen()
    if(curScreen and curScreen.name=="HUD")
    then
        return false
    end
    return true
end
TheInput:AddKeyUpHandler(
    KEY_Z,
    function()
        if cz_hotkey_checker()
        then
            return
        end
        -- Do stuff
    end
)

 

  • Like 1
Link to comment
Share on other sites

19 hours ago, CarlZalph said:

Mostly what is done is checking if the user is actively in-game via:


local function cz_hotkey_checker()
    local curScreen = TheFrontEnd:GetActiveScreen()
    if(curScreen and curScreen.name=="HUD")
    then
        return false
    end
    return true
end
TheInput:AddKeyUpHandler(
    KEY_Z,
    function()
        if cz_hotkey_checker()
        then
            return
        end
        -- Do stuff
    end
)

 

Thanks, mate. Works just fine.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...