View Single Post
04/24/23, 06:07 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,000
Hi Simon,

I'm not sure if this will work as some of the move etc. keybinds are protected in a way you cannot change or missuse them for botting.
If the default crouch keybind provides an API function that will toggle the change (I assume this is OnSpecialMoveKeyPressed(SPECIAL_MOVE_INDEX_CROUCH) ? ) then you should be able to put some lua if .. then around it as you did, to make 2 keybinds of it.

This Bindings.xml needs to be included in your addon's manifest (YourAddon.txt file) then so it get's loaded.
https://wiki.esoui.com/Addon_Structure
https://wiki.esoui.com/Addon_manifest_(.txt)_format

https://wiki.esoui.com/Keybindings


Edit:
I just saw that SPECIAL_MOVE_CROUCH already is the vanilla code's name of that keybind!
So you cannot overwrite this, you need to create your own one like

<Action name="MYADDON_SPECIAL_MOVE_CROUCH">
<Action name="MYADDON_SPECIAL_MOVE_STAND">

And use ZO_CreateStringId to define the texts for the keybinds too in your lua files:

ZO_CreateStringId("SI_BINDING_NAME_MYADDON_SPECIAL_MOVE_CROUCH", "Crouch on")
ZO_CreateStringId("SI_BINDING_NAME_MYADDON_SPECIAL_MOVE_STAND", "Crouch off")


Edit2:
Another hint: API functions like GetUnitStealth return a stealth state variable (number).
The API documentation (linked at the WIKI -> API version https://wiki.esoui.com/APIVersion -> current live https://wiki.esoui.com/APIVersion#live_API_version e.g. or PTS https://wiki.esoui.com/APIVersion#PTS_API_version if you are on the Public Test Server API documentation txt file, e.g. for the live version: API TXT Documentation: https://www.esoui.com/forums/attachm...6&d=1675236301)
provides you the type of the returned number format AND a list of that type.

Code:
* GetUnitStealthState(*string* _unitTag_)
** _Returns:_ *integer* _stealthState_
In this case it's stealthState

Search for that in the same file:
Code:
h5. StealthState
* STEALTH_STATE_DETECTED
* STEALTH_STATE_HIDDEN
* STEALTH_STATE_HIDDEN_ALMOST_DETECTED
* STEALTH_STATE_HIDING
* STEALTH_STATE_NONE
* STEALTH_STATE_STEALTH
* STEALTH_STATE_STEALTH_ALMOST_DETECTED
Now you got the global constant names and shuld use those instead of 2 or 1 numbers, as the numbers could change!
STEALTH_STATE_NONE = 0 I think, so you could use the "crouch" keybind if the state is currently none, and if it's not none uncrouch = stand?

Code:
<Bindings>
	<Layer name="SI_KEYBINDINGS_LAYER_GENERAL">
		<Category name="SI_KEYBINDINGS_CATEGORY_COMBAT">
			<Action name="MYADDON_SPECIAL_MOVE_CROUCH">
				<Down>
					if GetUnitStealth(player) == STEALTH_STATE_NONE then
						OnSpecialMoveKeyPressed(SPECIAL_MOVE_INDEX_CROUCH)
					end
				</Down>
			</Action>

			<Action name="MYADDON_SPECIAL_MOVE_STAND">
				<Down>
					if GetUnitStealth(player) > STEALTH_STATE_NONE then
						OnSpecialMoveKeyPressed(SPECIAL_MOVE_INDEX_CROUCH)
					end
				</Down>
			</Action>
		</Category>
	</Layer>
</Bindings>

Last edited by Baertram : 04/24/23 at 06:20 AM.
  Reply With Quote