Jump to content

need help with script


Recommended Posts

function CloseInCombat()
	if game.GetPlayer().IsInCombat()
		debug.Notification("I can't do this in combat!")
		utility.WaitMenuMode(0.150000)
		input.TapKey(Input.GetMappedKey("Tween Menu"))
		utility.WaitMenuMode(0.150000)
	endIf
endFunction

i am trying to make it so if the journal or loading menu are opened while in combat then it will be closed before the player has enough time to do anything however the script wont close the menu it will give me the debug notification but wont close so can someone tell me where i went wrong

 

edit1: if i change the input.getmappedkey to a number it works however that will only work if the player has not changed their controls and will not work on controller if the number is like 15

Edited by Blaise1203
Link to comment
Share on other sites

i fixed that issue now however i cant get the code to work with the game pad

the fixed code for keyboard and mouse

function CloseInCombat()
	if game.GetPlayer().IsInCombat()
		debug.Notification("I can't do this in combat!")
		self.iKey()
		utility.WaitMenuMode(0.050000)
	endIf
endFunction

function iKey()
	int numberAny = Input.GetMappedKey("Tween Menu",0xff)
	If numberAny == Input.GetMappedKey("Tween Menu",0xff)
		Input.TapKey(numberAny)
	endIf
endFunction
Edited by Blaise1203
Link to comment
Share on other sites

Use 0x02 for gamepad. You can maybe check if the menu is still open and then detect gamepad if it is:

 

function iKey()
    int numberAny = Input.GetMappedKey("Tween Menu",0xff)
    If numberAny == Input.GetMappedKey("Tween Menu",0xff)
        Input.TapKey(numberAny)
    endIf
    
    Utility.WaitMenumode(0.1)
    If UI.IsMenuOpen("Journal Menu") 
        numberAny = Input.GetMappedKey("Tween Menu",0x02)
        Input.TapKey(numberAny)
    Endif 
    
endFunction
Link to comment
Share on other sites

A few workarounds to consider. Using:

Game.DisablePlayerControls() 
Game.EnablePlayerControls()

Will force close some menus. I don't think it works on the Journal Menu but will work on the Stats Menu or Inventory Menu. For journal, if you want to prevent saving you can use SetInChargen. Disable on combat start then enable again when combat ends. https://www.creationkit.com/index.php?title=SetInChargen_-_Game

Link to comment
Share on other sites

Ok I thought of a possible solution. Since tapKey doesn't seem to work for game pad, have the script make it so you stop using gamepad at the start of the function, then re-enable gamepad at the end of the function

function iKey()
    Bool GamepadCheck = Utility.GetIniBool("bGamepadEnable:MAIN") 
    
    If GamepadCheck == True 
        Utility.SetIniBool("bGamepadEnable:MAIN", False) 
    Endif
    
    Utility.WaitMenuMode(0.1)
    
    int numberAny = Input.GetMappedKey("Tween Menu",0xff)
    Input.TapKey(numberAny)
    
    Utility.WaitMenuMode(0.1)
    
    If GamepadCheck == True 
        Utility.SetIniBool("bGamepadEnable:MAIN", True) 
    Endif
endFunction

I haven't tested but I think it would work.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...