Player Interaction/Hotkeys

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Player Interaction/Hotkeys

Post by UniTrader » Thu, 2. Apr 15, 21:44

I started today another little project and it looks good so far, but i need direct Player Interaction, meaning the Player must have the possibility to trigger an MD event at will while being on a Platform. I cannt use any NPC interaction / dialogue Start because the looking direction of the Player is part of the functionality. Currently i am abusing the <event_ui_triggered screen="'MapMenu'" control="''" comment="Map"/> but this has the downside that the Map appears every time i trigger the Action. i also considered getting the Player Jump interaction, but i didnt find a way to get it with an Event.

Do you have further ideas about possible events i could abuse? Theorhetical Stuff you think which may work but never actually used is also fine.
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Vim Razz
Posts: 1842
Joined: Tue, 2. Nov 10, 02:20
x4

Post by Vim Razz » Thu, 2. Apr 15, 22:25

Some kind of configurable Hotkey API is something I've been dreaming of since starting to dig through the new LUA file information available since 3.50.

Some of the stuff in there is suggestive that a way to do it ~might~ be possible, but I haven't been able to get anything working yet.

User avatar
Litauen
Posts: 193
Joined: Fri, 22. Nov 13, 21:09
xr

Post by Litauen » Thu, 2. Apr 15, 22:36

Gun fights!?

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Thu, 2. Apr 15, 22:48

nope. Commanding Capships like a Commander -> imagine staying on your Bridge and saying "Attack this Destroyer over there" while pointing/looking in its direction instead of finding it through the Map ;) (and your 1★ Captain misunderstands and starts boosting in the Zone behind it :D)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Vim Razz
Posts: 1842
Joined: Tue, 2. Nov 10, 02:20
x4

Post by Vim Razz » Thu, 2. Apr 15, 22:57

That's pretty similar to what I've been wanting it for -- a squad broadcast commands hotkey to make an "attack my target" option viable, and a "speed dialer" hotkey mod to bring up comms with pre-assigned ship/group commanders + "attack my target" command options.


Have you had any luck getting a target (or even direction) indicated in first person mode? I hadn't even thought of that.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Thu, 2. Apr 15, 23:05

it was far too simple:

Code: Select all

<!-- Get Objects in the Line-of-Sight of the Player -->
            <find_object name="$Objects" space="player.zone" multiple="true" known="true" >
              <match_is_in_view_of object="player.entity" vertical="30deg" horizontal="30deg"/>
            </find_object>
            <find_zone name="$Zones" space="player.sector" multiple="true" known="true" tempzone="false" priorityzone="true">
              <match_is_in_view_of object="player.entity" vertical="30deg" horizontal="30deg"/>
            </find_zone>
            <!-- Create Point where the Player looks to -->
            <create_position name="$Position" space="player.sector" object="player.entity" z="30km"/>
            
            <!-- Sort found Objects into categories -->
            <create_list name="$Enemies" />
            <create_list name="$Moveables" />
            <create_list name="$Unmoveables" />
            <do_all exact="$Objects.count" counter="$i">
              <do_if value="$Objects.{$i}.hasrelation.enemy.{faction.player}" >
                <append_to_list list="$Enemies" exact="$Objects.{$i}" />
              </do_if>
              <do_if value="$Objects.{$i}.isclass.ship" >
                <append_to_list list="$Moveables" exact="$Objects.{$i}" />
              </do_if>
              <do_if value="$Objects.{$i}.isclass.station or $Objects.{$i}.isclass.asteroid" >
                <append_to_list list="$Unmoveables" exact="$Objects.{$i}" />
              </do_if>
              <!-- in case of a Gate add its Destination Zone to the Zone List instead of sorting it somewhere else -->
              <do_if value="$Objects.{$i}.isclass.gate">
                <append_to_list list="$Zones" exact="$Objects.{$i}.destination" />
              </do_if>
            </do_all>
to avoid unnecesary (and probably expensive) search operations with looking direction i only search once per call for all possible Objects and sort them into Categories after that.
The Position is untested so far if the Result is what i actually want - currently working on the Menu Stuff instead.

PS could you explain me how in lua the Calls for Opening Menus are received? i am not that familiar with it yet. Best by quoting the concrete example of how the Sector/Zone Map is called (by the , or . hotkey) - maybe that leads to a solution because its easy to add custion Hotkeys to the default Control Profiles, but in AI/MD there is no way to receive their Event.. maybe we can get it in lua?
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Vim Razz
Posts: 1842
Joined: Tue, 2. Nov 10, 02:20
x4

Post by Vim Razz » Fri, 3. Apr 15, 00:16

Very cool.
UniTrader wrote:PS could you explain me how in lua the Calls for Opening Menus are received? i am not that familiar with it yet
I don't really understand this myself yet, and trying to dig through all the new UI information available has been a slow process. :shock:

J3ANP3T3R
Posts: 126
Joined: Sat, 14. Mar 15, 15:16

Re: Player Interaction/Hotkeys

Post by J3ANP3T3R » Sat, 4. Apr 15, 16:38

UniTrader wrote:I started today another little project and it looks good so far, but i need direct Player Interaction, meaning the Player must have the possibility to trigger an MD event at will while being on a Platform. I cannt use any NPC interaction / dialogue Start because the looking direction of the Player is part of the functionality. Currently i am abusing the <event_ui_triggered screen="'MapMenu'" control="''" comment="Map"/> but this has the downside that the Map appears every time i trigger the Action. i also considered getting the Player Jump interaction, but i didnt find a way to get it with an Event.

Do you have further ideas about possible events i could abuse? Theorhetical Stuff you think which may work but never actually used is also fine.
what i did with Betty AI 2015 mod is intercept the "Player Properties" menu so that it doesn't show the fleet but instead show player choices that my mod made. the mod choices then have to include an option to open the "Player Properties" ... in your settings you must set a shortcut key for "Player Properties". i have mine set to the number 1 so every time i press 1 Betty's choices popup then i have to select "Fleet" for "Player Properties" ...

but the sad thing is that the OPTIONS menu only have a limited number of menus with shortcut keys. wish they can allow an event to listen for a specific key press.

J3ANP3T3R
Posts: 126
Joined: Sat, 14. Mar 15, 15:16

Post by J3ANP3T3R » Sat, 4. Apr 15, 17:25

Vim Razz wrote:That's pretty similar to what I've been wanting it for -- a squad broadcast commands hotkey to make an "attack my target" option viable, and a "speed dialer" hotkey mod to bring up comms with pre-assigned ship/group commanders + "attack my target" command options.


Have you had any luck getting a target (or even direction) indicated in first person mode? I hadn't even thought of that.
yeah that could actually work. and is more accurate than the player view which can have multiple enemies.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sat, 4. Apr 15, 17:26

J3ANP3T3R wrote:
Vim Razz wrote:That's pretty similar to what I've been wanting it for -- a squad broadcast commands hotkey to make an "attack my target" option viable, and a "speed dialer" hotkey mod to bring up comms with pre-assigned ship/group commanders + "attack my target" command options.


Have you had any luck getting a target (or even direction) indicated in first person mode? I hadn't even thought of that.
yeah that could actually work. and is more accurate than the player view which can have multiple enemies.
no player Target in first Person Gameplay :roll:
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

User avatar
YorrickVander
Posts: 2705
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Sat, 4. Apr 15, 17:38

Not 100% sure it would work, but it might be possible to hijack the T keypress by using \ui\core\Lua\Ability Menu Handling.lua. I don't have time to test ideas on this but it at least has potential. As the drone launching can now also be done via sidebar it doesn't break any game controls.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

J3ANP3T3R
Posts: 126
Joined: Sat, 14. Mar 15, 15:16

Post by J3ANP3T3R » Sat, 4. Apr 15, 17:43

UniTrader wrote:
J3ANP3T3R wrote:
Vim Razz wrote:That's pretty similar to what I've been wanting it for -- a squad broadcast commands hotkey to make an "attack my target" option viable, and a "speed dialer" hotkey mod to bring up comms with pre-assigned ship/group commanders + "attack my target" command options.


Have you had any luck getting a target (or even direction) indicated in first person mode? I hadn't even thought of that.
yeah that could actually work. and is more accurate than the player view which can have multiple enemies.
no player Target in first Person Gameplay :roll:
OH ! haha ... sorry i did not read the whole thread :D your aim is for 3rd person ? im guessing this is for when you are inside a capital ship control room right ? with lituen capital ship bridge mod and you can order your ships to attack what you see on the screen ? what about that match in view thing you mentioned ? did it work ? if not then how about switching it to your ship's view instead of the player's view. probably increase the angle a bit as well as the distance. so it would depend on the distance versus angle ... also use distance to determine which target is chosen if multiple targets are on the same view. like the nearest target is the main target or the nearest bigger ship is the main target to attack.

J3ANP3T3R
Posts: 126
Joined: Sat, 14. Mar 15, 15:16

Post by J3ANP3T3R » Sat, 4. Apr 15, 17:46

i see that you already written a sample code ... it looks pretty awesome ... and you already made some filters.. did it work ?

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sat, 4. Apr 15, 18:04

it worked great - i Navigated a Taranis from one End of the Universe to the other only using this (and sometimes consulted the Map when i coulnt locate some Objects)
It also gave me the impression something like this was planned at some point because there are Orientation Points for all Sectors in each Cluster (for example the Giantsolarplant in DV points to Barren Heart with its bottom tip - without it you wouldnt have any chance locating it) - sadly this doesnt apply to TO, there you have to guess mostly if you want to travel from one Sector to the other


Until i can have a Hotkey for myself this Mod is suspended though, but in the long run yes, i will improve the Selection.. currently it is still god enough i think because its very rare to have more than 7 Capships in nearly a line (which would cause some ot them to be omited), it just could get confusing if there is more than one Ship with the same Name targeted

related to the T Hotkey: that would work for my Purpose i think - it is usually not available on Platforms (but i can enable it there) and lua can differ between in Space and on Platform for sure - so in Space use its usual behavior and on Platform signal an MD-Script..
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

J3ANP3T3R
Posts: 126
Joined: Sat, 14. Mar 15, 15:16

Post by J3ANP3T3R » Sat, 4. Apr 15, 18:14

UniTrader wrote:it worked great - i Navigated a Taranis from one End of the Universe to the other only using this (and sometimes consulted the Map when i coulnt locate some Objects)
It also gave me the impression something like this was planned at some point because there are Orientation Points for all Sectors in each Cluster (for example the Giantsolarplant in DV points to Barren Heart with its bottom tip - without it you wouldnt have any chance locating it) - sadly this doesnt apply to TO, there you have to guess mostly if you want to travel from one Sector to the other


Until i can have a Hotkey for myself this Mod is suspended though, but in the long run yes, i will improve the Selection.. currently it is still god enough i think because its very rare to have more than 7 Capships in nearly a line (which would cause some ot them to be omited), it just could get confusing if there is more than one Ship with the same Name targeted

related to the T Hotkey: that would work for my Purpose i think - it is usually not available on Platforms (but i can enable it there) and lua can differ between in Space and on Platform for sure - so in Space use its usual behavior and on Platform signal an MD-Script..
i hope you can find the answer to your hotkey problems... being able to command ships while on a capital ship is very useful and i cant wait till you upload the final version. and when you can this could actually help those who were requesting to be able to commandeer a capital ship. like just press this and that and the ship complies.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sun, 5. Apr 15, 04:14

i have just looked into the Hotkey part for my Project, and i think i found how hotkeys are handled:

from ui\addons\ego_detailmonitor\menu_map.lua

Code: Select all

function menu.hotkey(action)
	local rowdata = Helper.currentTableRowData
	if rowdata ~= "back" then
		if action == "INPUT_ACTION_ADDON_DETAILMONITOR_G" then
			if rowdata and rowdata[1] == "child" then
				MovePlayerToZone(rowdata[2])
			end
is the handler of the Hotkey Event it seems.
from ui\addons\ego_detailmonitor\ui.xml

Code: Select all

………
    <bindings context="INPUT_CONTEXT_ADDON_DETAILMONITOR" alwaysactive="false">
      <binding action="INPUT_ACTION_ADDON_DETAILMONITOR_G" />
      <binding action="INPUT_ACTION_ADDON_DETAILMONITOR_C" />
      <binding action="INPUT_ACTION_ADDON_DETAILMONITOR_I" />
      <binding action="INPUT_ACTION_ADDON_DETAILMONITOR_A_SHIFT" />
      <binding action="INPUT_ACTION_ADDON_DETAILMONITOR_COMMA" />
      <binding action="INPUT_ACTION_ADDON_DETAILMONITOR_RIGHT" />
      <binding action="INPUT_ACTION_ADDON_DETAILMONITOR_LEFT" />
    </bindings>
…………
these seems to define the available Hotkeys for Menus. Question is if we may add custom ones in the related Game files (libraries/inputmap.xml and libraries/contexts.xml) and they work then or if more is necesary.. or if these are even hardcoded.. and if its possible to catch Hotkey Events without any Menu open.. maybe some invisible permanent-open Menu which catches all HK events and signals the Events to AIscripts/MD?

note: i may had a look today, but i am still a complete noob with lua - be nice to me :)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

J3ANP3T3R
Posts: 126
Joined: Sat, 14. Mar 15, 15:16

Post by J3ANP3T3R » Sun, 5. Apr 15, 08:29

here is a sample hijack i made with the Mainmenu.xml

<diff>
<replace

sel='/mdscript[@name="MainMenu"]/cues/cue[@name="PropertyMenuStarted"]/actions'>

<actions>
<signal_cue_instantly cue="md.bettyAI.SectionHandler_BettyAI" param="100"/>

<!-- open_conversation_menu menu="PropertyMenu" param="[0, 0, 'player']" param2="event.param3" / -->
<!-- add_conversation_view view="closeupdetailmonitor" / -->
</actions>

so now instead of the "PropertyMenu" menu popping up when i press the shortcut key for "PropertyMenu" my md script choices appear without any window open. i just add the "PropertyMenu" choice in there.

</replace>

</diff>

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sun, 5. Apr 15, 12:47

nice idea, but i think i am on the way to real custom Hotkeys, not just stealing the EGO ones.. aviods complications when we run out of Menus we could steal :D
think i will get a bit into lua today - just to pass random Hotkey Events to the MD so it can be used as lib instead of being a special solution...
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sun, 5. Apr 15, 14:18

sorry for double-post but i think this is interesting for everone here:

=> Game does not accept custom Hotkeys when adding them to both contexts.xml and inputmap.xml:
[XML ] Failed to parse string 'INPUT_ACTION_UT_PC' in node 'action', attribute 'id' at line 4 of file 'libraries/contexts.(pck|xml)' as enum value.
[General] ======================================
[=ERROR=] Invalid action specified in context data: INPUT_ACTION_UT_PC

=> also the binding i mentoined earlier is not available for Custom UI Elements:
[=ERROR=] LIBXML2: file:///extensions%2FUTUITest%2Fui.xml?ext=pck%20xml line 6, error 1871: Element 'bindings': This element is not expected. Expected is one of ( file, dependency, savedvariable ).
[General] ======================================
[General] ======================================
[=ERROR=] XLib::XMLValidateAgainstSchema(): Document 'file:///extensions%2FUTXUITest%2Fui.xml?ext=pck%20xml' failed validation against schema 'file:///ui%2Fcore%2Faddon.xsd?ext=xsd' - Errorcode: 1871.
[General] ======================================
[General] ======================================
[=ERROR=] AddonManager::LoadAddonInfos(): Failed to load extension addon info file '': 'Error loading from XML file 'extensions/UTXUITest/ui.xml'. Check the log for further information.'


if someone wants to try further here my File contents - i give up at this point for now:
ui.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<addon xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ut_lib_hotkey" xsi:noNamespaceSchemaLocation="http://utnas/~unitrader/XRebirthxsds/addon.xsd">
  <environment type="fullscreen">
    <file name="ui/ut_lib_hotkey.lua"/>
    <dependency name="ego_fullscreenHelper"/>
    <bindings context="INPUT_CONTEXT_BASE" alwaysactive="true">
      <action id="INPUT_ACTION_STOP"/>
      <action id="INPUT_ACTION_TOGGLECURSOR"/>
      <action id="INPUT_ACTION_SCREENSHOT"/>
      <action id="INPUT_ACTION_PAUSE"/>
      <action id="INPUT_ACTION_DEBUG_FEATURE_1"/>
      <action id="INPUT_ACTION_DEBUG_FEATURE_2"/>
      <action id="INPUT_ACTION_TOGGLECOCKPIT"/>
      <action id="INPUT_ACTION_TOGGLE_AUTOPILOT"/>
      <action id="INPUT_ACTION_MUTE"/>
      <action id="INPUT_ACTION_UT_PC"/>
      <state id="INPUT_STATE_MOUSECLICK"/>
    </bindings>
  </environment>
</addon>
libraries/contexts.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<diff>
  <add sel="//context[@id="INPUT_CONTEXT_BASE"]">
    <action id="INPUT_ACTION_UT_PC"/>
  </add>
</diff>
libraries/inputmap.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<diff>
  <add sel="/inputmap">
    <action id="INPUT_ACTION_UT_PC" source="INPUT_SOURCE_KEYBOARD" code="INPUT_KEYCODE_E" />
  </add>
</diff>
also my first lua script which is probably wrong anyway, but also had never any chance to actually be used: ui/ut_lib_hotkey.lua:

Code: Select all

local function init()
	RegisterAddonBindings("ut_lib_hotkey")
end

local menu = {
	name = "HotkeyCatcherFake"
}


function menu.hotkey(action)
	AddUITriggeredEvent("Hotkey", action)
end
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

J3ANP3T3R
Posts: 126
Joined: Sat, 14. Mar 15, 15:16

Post by J3ANP3T3R » Sun, 5. Apr 15, 14:50

are they not going to allow custom keys on next update ?

Post Reply

Return to “X Rebirth - Scripts and Modding”