Jump to content

Recommended Posts

I've already (more-or-less) figured out how to detect when the player presses a key, so I can turn abilities on and off at will, but when players are typing to talk or enter code, the key presses are still registered.  Is there a way to detect when players are entering text, vs when a key is simply being pressed?  I've heard that some mods do this.

Update:  I think I found an example, but there's a lot here I've never seen before..  Specifically, why is the second half of their code so different from what I have?

AddModRPCHandler("The Wild Child  -Ver. 1.3.4.7","ToogleSwimming",ToogleSwimming)

GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.key_to_swim, function()
    if GLOBAL.ThePlayer then
        SendModRPCToServer(MOD_RPC["The Wild Child  -Ver. 1.3.4.7"]["ToogleSwimming"])
    end
end)
AddModRPCHandler(modname, "widgette_bundle", widgette_bundle)
GLOBAL.TheInput:AddKeyDownHandler(GetModConfigData("key_bundle", true), function()
    if not GLOBAL.ThePlayer or GLOBAL.ThePlayer.prefab ~= "widgette" or GLOBAL.TheFrontEnd:GetActiveScreen() ~= GLOBAL.ThePlayer.HUD then
        return
    end
    
	if GLOBAL.TheNet:GetIsServer() then
		widgette_bundle(GLOBAL.ThePlayer)
	else
		SendModRPCToServer(MOD_RPC[modname]["widgette_bundle"])
	end
end)

 

Edited by FurryEskimo
On 9/22/2021 at 7:56 PM, FurryEskimo said:

try to use this if statement
if _G.ThePlayer and not _G.ThePlayer.HUD:IsChatInputScreenOpen() and not _G.ThePlayer.HUD:IsConsoleScreenOpen() and not _G.ThePlayer.HUD.writeablescreen then

 

Edited by Helwdrokin
  • Like 1

@Helwdrokin
Thanks a lot!

I actually did manage to figure it out.  ^-^
The first part of their check made sure no one was trying, and the second part appears to be outdated, and is related to caves, so I just used what I had.  The ‘modname’ is apparently just some unique indicator to help with the code, so I simplified mine.  I think a lot of people use ‘modname’, which may lead to errors if using the mods at the same time (idk for sure though).

Edited by FurryEskimo

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
×
  • Create New...