ShipConfigurationMenu

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

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

cupoma
Posts: 12
Joined: Fri, 15. Nov 24, 09:13

ShipConfigurationMenu

Post by cupoma »

Can anyone tell me how the dialog launch function works for building a ship at my shipyard?
I've been looking at the files tutorial_platform.xml scenario_tutorials.xml and I found the commands, but I can't figure out what the arguments should be.
MD script:

Code: Select all

 
 <cue name="open_menu_build_ship" instantiate="true">
	 <conditions>
		<event_ui_triggered screen="'ShipConfigurationMenu'" control="''"/>
		<event_cue_signalled/>
	</conditions>
	<actions>
		<open_menu menu="ShipConfigurationMenu" param="player" param2="global.$OMBS.$targetStation"/>
	 </actions>
 </cue>
control= - what can be used here?
param= param2= - what can be used here?

Code: Select all

debug: Error in MD cue md.Interact_Menu_API.Capture_Lua_Callback<inst:1c8f57> Signalled cue md.blablabla.open_menu_build_ship has no corresponding listeners
P.S. As a result, I would like to have access to the modworkbench by clicking on the shipyard.
cupoma
Posts: 12
Joined: Fri, 15. Nov 24, 09:13

Re: ShipConfigurationMenu

Post by cupoma »

I handled this code myself, the topic can be closed
User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13485
Joined: Sun, 15. Feb 04, 20:12
x4

Re: ShipConfigurationMenu

Post by euclid »

I'm glad you've solved that but maybe you'd like to share your solution here that others with the same/similar problems can benefit? ;-)

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
cupoma
Posts: 12
Joined: Fri, 15. Nov 24, 09:13

Re: ShipConfigurationMenu

Post by cupoma »

euclid wrote: Tue, 26. Nov 24, 22:13 I'm glad you've solved that but maybe you'd like to share your solution here that others with the same/similar problems can benefit? ;-)

Cheers Euclid
I'm shy, my code is likely to cause laughter, it's very crooked. Besides, since there were no clues, I went the other way. I'm not sure if this code will work on other computers.

I have a question for you. I saw your mod about the merchant, you don't use the "create_trade_order" commands in it, I tried to insert the "warp" command between the two "create_trade_order" commands, then any at all, then I tried to loop the first "create_trade_order" so that "warp" would be executed after it, but nothing works. Is this done on purpose? Is that why you don't use "create_trade_order" in your fashion?
User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13485
Joined: Sun, 15. Feb 04, 20:12
x4

Re: ShipConfigurationMenu

Post by euclid »

cupoma wrote: Mon, 16. Dec 24, 18:01 ...............
I have a question for you. I saw your mod about the merchant, you don't use the "create_trade_order" commands in it, I tried to insert the "warp" command between the two "create_trade_order" commands, then any at all, then I tried to loop the first "create_trade_order" so that "warp" would be executed after it, but nothing works. Is this done on purpose? Is that why you don't use "create_trade_order" in your fashion?
I assume "merchant" refers to the AutoTrader mod. Any order will overwrite the AutoTrader script, i.e. it will stop running. As to why the warp is not working is difficult to say without any log (error) messages. My guess is that the create_trade_order triggers other script for the ship to fly and buy/sell the wares which will ignore the warp. Check the sticky here in this forum on how to create debug (error) logs.

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
cupoma
Posts: 12
Joined: Fri, 15. Nov 24, 09:13

Re: ShipConfigurationMenu

Post by cupoma »

euclid wrote: Mon, 16. Dec 24, 19:16
cupoma wrote: Mon, 16. Dec 24, 18:01 ...............
I have a question for you. I saw your mod about the merchant, you don't use the "create_trade_order" commands in it, I tried to insert the "warp" command between the two "create_trade_order" commands, then any at all, then I tried to loop the first "create_trade_order" so that "warp" would be executed after it, but nothing works. Is this done on purpose? Is that why you don't use "create_trade_order" in your fashion?
I assume "merchant" refers to the AutoTrader mod. Any order will overwrite the AutoTrader script, i.e. it will stop running. As to why the warp is not working is difficult to say without any log (error) messages. My guess is that the create_trade_order triggers other script for the ship to fly and buy/sell the wares which will ignore the warp. Check the sticky here in this forum on how to create debug (error) logs.

Cheers Euclid
it does not issue errors, just the "create_trade_order" command starts executing, and immediately the next "warp" is executed in parallel with it. I've tried a lot of options, nothing helps.

these variant don't work:
Spoiler
Show

Code: Select all

<do_if value="$buyware.exists">
<create_trade_order name="$buyware" object="this.object" tradeoffer="$buytarget" amount="$cargoware" immediate="true" />
</do_if>

<warp object="this.ship" zone="$selltarget.buyer.zone"/>

<create_trade_order name="$sellware" object="this.object" tradeoffer="$selltarget" amount="$cargoware" immediate="true" />
Spoiler
Show

Code: Select all

<do_if value="$buyware.available">
<create_trade_order name="$buyware" object="this.object" tradeoffer="$selltarget" amount="$cargoware" immediate="true" />
</do_if>

<warp object="this.ship" zone="$selltarget.buyer.zone"/>

<create_trade_order name="$sellware" object="this.object" tradeoffer="$selltarget" amount="$cargoware" immediate="true" />
Spoiler
Show

Code: Select all

<do_if value="$buytarget.exists">
<create_trade_order name="$buyware" object="this.object" tradeoffer="$buytarget" amount="$cargoware" immediate="true" />
</do_if>

<warp object="this.ship" zone="$selltarget.buyer.zone"/>

<create_trade_order name="$sellware" object="this.object" tradeoffer="$selltarget" amount="$cargoware" immediate="true" />
Spoiler
Show

Code: Select all

<do_if value="$buytarget.available">
<create_trade_order name="$buyware" object="this.object" tradeoffer="$selltarget" amount="$cargoware" immediate="true" />
</do_if>

<warp object="this.ship" zone="$selltarget.buyer.zone"/>

<create_trade_order name="$sellware" object="this.object" tradeoffer="$selltarget" amount="$cargoware" immediate="true" />
User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13485
Joined: Sun, 15. Feb 04, 20:12
x4

Re: ShipConfigurationMenu

Post by euclid »

Which part is not working? Does the ship execute the trade order? Does it warp? Are you sure all of your variables ($buyware, $buytarget etc.) are set correctly? How did you define those?

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
cupoma
Posts: 12
Joined: Fri, 15. Nov 24, 09:13

Re: ShipConfigurationMenu

Post by cupoma »

euclid wrote: Tue, 17. Dec 24, 17:30 Which part is not working? Does the ship execute the trade order? Does it warp? Are you sure all of your variables ($buyware, $buytarget etc.) are set correctly? How did you define those?

Cheers Euclid
Everything works, it does not issue errors, executes the order, executes the warp command without waiting for the end of the order.
Need to figure out how to execute the warp command after executing the order. I can't do it.
User avatar
ChemODun
Posts: 429
Joined: Mon, 12. Feb 07, 21:58
x4

Re: ShipConfigurationMenu

Post by ChemODun »

cupoma wrote: Wed, 18. Dec 24, 10:19
euclid wrote: Tue, 17. Dec 24, 17:30 Which part is not working? Does the ship execute the trade order? Does it warp? Are you sure all of your variables ($buyware, $buytarget etc.) are set correctly? How did you define those?

Cheers Euclid
Everything works, it does not issue errors, executes the order, executes the warp command without waiting for the end of the order.
Need to figure out how to execute the warp command after executing the order. I can't do it.
What I figured out, when wrote a "Rescue Rangers" aiscript - after creation the order in "default" script, it will be aborted and restarted.
So, for the script it will look as fresh start.
To resolve it I'm use the temporary variables associated with the pilot of a current ship.
I.e. I save some status in

Code: Select all

<set_value name="this.$somedata" exact="...">
Then checking this variable on script init and remove it after ...
Multiply entropy by absolute zero

Freedom in space
cupoma
Posts: 12
Joined: Fri, 15. Nov 24, 09:13

Re: ShipConfigurationMenu

Post by cupoma »

ChemODun wrote: Wed, 18. Dec 24, 16:12
cupoma wrote: Wed, 18. Dec 24, 10:19
euclid wrote: Tue, 17. Dec 24, 17:30 Which part is not working? Does the ship execute the trade order? Does it warp? Are you sure all of your variables ($buyware, $buytarget etc.) are set correctly? How did you define those?

Cheers Euclid
Everything works, it does not issue errors, executes the order, executes the warp command without waiting for the end of the order.
Need to figure out how to execute the warp command after executing the order. I can't do it.
What I figured out, when wrote a "Rescue Rangers" aiscript - after creation the order in "default" script, it will be aborted and restarted.
So, for the script it will look as fresh start.
To resolve it I'm use the temporary variables associated with the pilot of a current ship.
I.e. I save some status in

Code: Select all

<set_value name="this.$somedata" exact="...">
Then checking this variable on script init and remove it after ...
Can more detail? With an example...
User avatar
ChemODun
Posts: 429
Joined: Mon, 12. Feb 07, 21:58
x4

Re: ShipConfigurationMenu

Post by ChemODun »

Ok.

When I found the needed target, I store the data about and call another order:

Code: Select all

<set_value name="this.$rescueData" exact="table[
  $timeStamp = player.age, 
  $target = $target, 
  $textTargetPerson = $textTargetPerson,
  $crewFreeCount = $crewFreeCount,
]" />
<create_order id="'RescueShip'" object="this.ship" immediate="true">
  <param name="target" value="$target"/>
  <!-- <param name="internalorder" value="true"/> -->
  <param name="debugchance" value="$debugChance"/>
</create_order>
After calling the order my default one will be aborted, till the order lists will be clean
And on start I made this:

Code: Select all

<do_if value="this.$rescueData?">
      <do_if value="@this.$rescueData.$timeStamp ge (player.age - 300)">
        <set_value name="$target" exact="@this.$rescueData.$target" />
        ...
      </do_if>
    <remove_value name="this.$rescueData" />
</do_if>
Multiply entropy by absolute zero

Freedom in space
cupoma
Posts: 12
Joined: Fri, 15. Nov 24, 09:13

Re: ShipConfigurationMenu

Post by cupoma »

ChemODun wrote: Fri, 20. Dec 24, 17:22 Ok.
Spoiler
Show
When I found the needed target, I store the data about and call another order:

Code: Select all

<set_value name="this.$rescueData" exact="table[
  $timeStamp = player.age, 
  $target = $target, 
  $textTargetPerson = $textTargetPerson,
  $crewFreeCount = $crewFreeCount,
]" />
<create_order id="'RescueShip'" object="this.ship" immediate="true">
  <param name="target" value="$target"/>
  <!-- <param name="internalorder" value="true"/> -->
  <param name="debugchance" value="$debugChance"/>
</create_order>
After calling the order my default one will be aborted, till the order lists will be clean
And on start I made this:

Code: Select all

<do_if value="this.$rescueData?">
      <do_if value="@this.$rescueData.$timeStamp ge (player.age - 300)">
        <set_value name="$target" exact="@this.$rescueData.$target" />
        ...
      </do_if>
    <remove_value name="this.$rescueData" />
</do_if>


I'll try later. I'm trying another variant:

Code: Select all

<interrupts>
	<handler>
		<conditions>
			<check_any>
				<event_trade_completed buyer="this.ship"/>
			</check_any>
		</conditions>
			<actions>
				<warp object="this.ship" zone="$sourceStation.sector" />
			</actions>
	</handler>
</interrupts>
It does not give errors, but the interrupt does not execute...

Return to “X4: Foundations - Scripts and Modding”