Method to directly issue an MD cue?

The place to discuss scripting and game modifications for X4: Foundations.

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

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Method to directly issue an MD cue?

Post by Alkeena » Fri, 19. Jan 24, 13:23

Hey, I'm trying to find a reasonable means of testing and iterating on some of my MD scripts. I can test as a package pretty well by just issuing a /refreshmd command to the terminal, but trying to unittest any new component requires basically standing up some sort of test harness to run everything. Is it possible instead to just directly init a cue via the terminal?

Ideally what I'd like to do is:
  • Edit my md script
  • /refreshmd to load it
  • issue some command to directly run a cue so I can see if it does what I want
  • iterate
Is this possible?

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13308
Joined: Sun, 15. Feb 04, 20:12
x4

Re: Method to directly issue an MD cue?

Post by euclid » Fri, 19. Jan 24, 13:50

Cues activate on event only if the event conditions are met. If you want to test the actions and not the conditions then you could use event_cue_signalled and then trigger it via signal_cue (or signal_cue_instantly). Or do I miss your point here?

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: Method to directly issue an MD cue?

Post by Alkeena » Fri, 19. Jan 24, 14:22

euclid wrote:
Fri, 19. Jan 24, 13:50
Cues activate on event only if the event conditions are met. If you want to test the actions and not the conditions then you could use event_cue_signalled and then trigger it via signal_cue (or signal_cue_instantly). Or do I miss your point here?

Cheers Euclid
Thanks. What I'm curious about is if there is a way to signal a cue interactively from the chatbox/console while in game?

Here's the rough outline of what I've got:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mdscript name="MDTest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
  <cues>
    <cue name="MDTest" namespace="this">
      <conditions>
		<check_all>
			<check_any>
				<event_cue_signalled cue="md.Setup.Start"/>
				<event_game_loaded/>
				<event_cue_signalled cue="SOMETESTCUE"/>
			</check_any>
			OTHERCONDITIONS
		</check_all>
      </conditions>
      <actions>
	  	ACTIONS
      </actions>
    </cue>
  </cues>
</mdscript>
I'd like to be able to interactively emit SOMETESTCUE while in game from the chatbox, if possible. Alternatively it seems like I'll need to construct some sort of additional test harness with like a dialogue menu or something? More generally: how are folks iterating on and testing their MD scripts without a ridiculous amount of reloading the entire game?

Thanks again!

Edit:

To be super explicit, I'm wondering if there's any command to effectively signal_cue_instantly manually from the console. To my knowledge these are the only console commands that exist though: viewtopic.php?t=366657

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13308
Joined: Sun, 15. Feb 04, 20:12
x4

Re: Method to directly issue an MD cue?

Post by euclid » Fri, 19. Jan 24, 15:06

I never used the chat window (yet) but it should be possible to run a lua script via the ExecuteDebugCommand (that executes the chat window input). I'm pretty sure that you can run any xml commands from a lua script. However, I gave up on that some years ago after spending many months to code an XML-LUA interface in vain. :-(

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

DeadAirRT
Posts: 1036
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Method to directly issue an MD cue?

Post by DeadAirRT » Fri, 19. Jan 24, 15:47

you can use something similar to this. I'm not aware of a method to signal a cue via chat window.

Code: Select all

<cue name="LaunchTheTests" instantiate="true">
	<conditions>
		<event_long_range_scan_sent object="player.entity"/>
	</conditions>
	<actions>
		<!--<signal_cue_instantly cue="CommissionTesting" />-->
		<!--<signal_cue_instantly cue="Infoaboutfaction" />-->
		<!--<signal_cue_instantly cue="FindBrokenStations" />-->
		<!--<signal_cue_instantly cue="GetFactionsByTag" />-->
		<!--<signal_cue_instantly cue="ActiveInactiveGateStuff" />-->
		<!--<signal_cue_instantly cue="BringTheGateOnline" />-->
		<!--<signal_cue_instantly cue="HowDoesSortTradeWork" />-->
		<!--<signal_cue_instantly cue="GetShipsByJob" /> -->
		<!--<signal_cue_instantly cue="ConversionLibrary" />-->
		<!--<signal_cue_instantly cue="AllSectorInfo"/>-->
		<!--<signal_cue_instantly cue="GetPath" />-->
		<!--<signal_cue_instantly cue="GetBlueprint" />-->
		<!--<signal_cue_instantly cue="GetWareVolume" />-->
		<!--<signal_cue_instantly cue="GetStationWareList" />-->
		<!--<signal_cue_instantly cue="DoesShipHaveOwnAccount" />-->
		<!--<signal_cue_instantly cue="ShipReport" />-->
		<!--<signal_cue_instantly cue="TestOrientation" />-->
		<!--<signal_cue_instantly cue="SpawnShips"/>-->
		<!--<signal_cue_instantly cue="FullRelation"/>-->
		<!--<signal_cue_instantly cue="SizeComparison"/>-->
		<!--<signal_cue_instantly cue="XenonTraders"/>-->
		<!--<signal_cue_instantly cue="XenonTraders"/>-->
	</actions>
</cue>

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: Method to directly issue an MD cue?

Post by Alkeena » Fri, 19. Jan 24, 15:55

DeadAirRT wrote:
Fri, 19. Jan 24, 15:47
you can use something similar to this. I'm not aware of a method to signal a cue via chat window.

Code: Select all

<cue name="LaunchTheTests" instantiate="true">
	<conditions>
		<event_long_range_scan_sent object="player.entity"/>
	</conditions>
	<actions>
		<!--<signal_cue_instantly cue="CommissionTesting" />-->
		<!--<signal_cue_instantly cue="Infoaboutfaction" />-->
		<!--<signal_cue_instantly cue="FindBrokenStations" />-->
		<!--<signal_cue_instantly cue="GetFactionsByTag" />-->
		<!--<signal_cue_instantly cue="ActiveInactiveGateStuff" />-->
		<!--<signal_cue_instantly cue="BringTheGateOnline" />-->
		<!--<signal_cue_instantly cue="HowDoesSortTradeWork" />-->
		<!--<signal_cue_instantly cue="GetShipsByJob" /> -->
		<!--<signal_cue_instantly cue="ConversionLibrary" />-->
		<!--<signal_cue_instantly cue="AllSectorInfo"/>-->
		<!--<signal_cue_instantly cue="GetPath" />-->
		<!--<signal_cue_instantly cue="GetBlueprint" />-->
		<!--<signal_cue_instantly cue="GetWareVolume" />-->
		<!--<signal_cue_instantly cue="GetStationWareList" />-->
		<!--<signal_cue_instantly cue="DoesShipHaveOwnAccount" />-->
		<!--<signal_cue_instantly cue="ShipReport" />-->
		<!--<signal_cue_instantly cue="TestOrientation" />-->
		<!--<signal_cue_instantly cue="SpawnShips"/>-->
		<!--<signal_cue_instantly cue="FullRelation"/>-->
		<!--<signal_cue_instantly cue="SizeComparison"/>-->
		<!--<signal_cue_instantly cue="XenonTraders"/>-->
		<!--<signal_cue_instantly cue="XenonTraders"/>-->
	</actions>
</cue>
Cool, thanks DeadAir!

sprIder
Posts: 96
Joined: Sat, 3. Jul 10, 23:23
x4

Re: Method to directly issue an MD cue?

Post by sprIder » Mon, 22. Jan 24, 17:51

euclid wrote:
Fri, 19. Jan 24, 15:06
I never used the chat window (yet) but it should be possible to run a lua script via the ExecuteDebugCommand (that executes the chat window input). I'm pretty sure that you can run any xml commands from a lua script. ...
SirNukes already implemented (something like) this in his mod "Mod Support APIs" with the "Chat_Window_API".

And you can learn how to use this in practice from kuertees mods, e.g. UI Trade Analytics.

In the file "\kuertee_ui_trade_analytics\md\kuertee_trade_analytics.xml" you'll find the following cue:

Code: Select all

<cue name="ResetAll" namespace="this">
	<conditions>
		<check_any>
			<event_cue_signalled />
			<check_all>
				<event_ui_triggered screen="'Chat_Window_API'" control="'text_entered'" />
				<check_value value="event.param3.$text == 'reset tanalytics'" />
			</check_all>
		</check_any>
	</conditions>
	<actions>
		<debug_text text="'reset_cue ' + kTAnalytics" />
		<reset_cue cue="UserSettings" />
		<reset_cue cue="kTAnalytics" />
	</actions>
	....
</cue>
It gets triggered if text is entered in the chat window and checks, if the text matches the value 'reset tanalytics'.

Just ignore the "ResetAll2" cue that follows, change everything as you need and want it, and change the actions to something like

Code: Select all

<actions>
	<signal_cue cue="MyTestCue" />
</actions>
Don't forget to set the dependency in the content.xml:

Code: Select all

<dependency name="SirNukes Mod Support APIs" id="ws_2042901274" optional="false"/>
I hope this helps.

Best regards
sprIder

Return to “X4: Foundations - Scripts and Modding”