HELP! Need some guidance with MD<>UI interaction.

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

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

Post Reply
Dev disco
Posts: 33
Joined: Wed, 2. Dec 20, 16:35

HELP! Need some guidance with MD<>UI interaction.

Post by Dev disco » Sun, 14. Mar 21, 21:49

I made the Pirate Variety mod because my first game ended with 50+ stations, hundreds of ships and the feeling that the upkeep of my empire felt like a true job. So I wanted less fuss, more excitement and at the same time lots of credits.
Anyway, the game has a new dynamic to me. I only have two stations now: a warehouse and next to it a ship yard. I use the recycle mod to turn the ships into goods that I transport to the warehouse, which sells them. However, if the ship has any bulk or liquid cargo, I first send it to the warehouse to unload its wares (the shipyard can't store these). Still quite a bit of a fuss.
So I copied the warehouse, bolted an XL cradle onto it and now I can recycle the ship while the cargo is placed in the proper type of container.
However, I am still not satisfied. I actually want the manager to use the warehouse buy/sell options, instead of the usual menu in which you can only adjust the buy prices of the goods needed for production. I think it would be a nice new station, useful to many players (and perhaps X4 as well?).
This is where I run into a wall named UI/Lua. I can hack into XML, no clue what 90% of it does, but it seems to work. The interaction between MD and UI is beyond me, though.
I think that I know which scripts are involved, but I need some coaching to deal with them. Anyone still around who can hold my hand?

User avatar
KrYcHokE
Posts: 259
Joined: Wed, 2. Dec 15, 13:15
x4

Re: HELP! Need some guidance with MD<>UI interaction.

Post by KrYcHokE » Sun, 14. Mar 21, 23:00

you need next patches in aiscripts folder:
trade.station.xml:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<diff>
  <add sel="/aiscript/attention[@min='unknown']/actions/do_if[@value='this.station.owner != faction.player']/set_value[@name='$tradingstations']" pos="after">
    <append_to_list name="$tradingstations" exact="macro.struct_bt_warehouse_new_macro"/>
  </add>
</diff>
trade.station.tradingstation.xml:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<diff>
  <add sel="/aiscript/attention[@min='unknown']/actions/do_elseif[@value='this.station.macro.ismacro.struct_bt_alb_warehouse_macro']" pos="after">
     <do_elseif value="this.station.macro.ismacro.struct_bt_warehouse_new_macro">
        <add_tradeware ware="ware.crystals" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.cutcrystals" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.energycells" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.foodrations" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.ice" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.meat" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.medicalsupplies" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.narcotics" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.nividium" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.ore" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.refinedmetals" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.silicon" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.siliconwafers" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.spacefuel" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.water" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_tradeware ware="ware.wheat" object="this.station" allowbuy="true" allowsell="true" lockavgprice="true"/>
        <add_default_production_wares object="this.station" lowerlimit="40" upperlimit="60"/>
      </do_elseif>
  </add>
</diff>
put your station macro instead of struct_bt_warehouse_new_macro

Dev disco
Posts: 33
Joined: Wed, 2. Dec 20, 16:35

Re: HELP! Need some guidance with MD<>UI interaction.

Post by Dev disco » Mon, 15. Mar 21, 10:33

First of all: THANKS!

However,... this looks promising, but both of those scripts/parts run if the owner isn't the player.

Besides, I have the feeling that you don't have to force teh warehouse behaviour, but suppress the regular one.

As far as I can see the warehouse function for players is a kind of fall-down mechanism: if a station doesn't have a production module, it will act like a warehouse.

Removing this component in my Recycle Station macro is all that it takes to change the manager from XL shipyard to Warehouse behaviour.

Code: Select all

      <connection ref="ConnectionFor_buildmodule_ships_albion_xl_macro">
        <build mode="optional" group="production" sequence="G"  stage="1" tags="primary " />
        <macro ref="buildmodule_recycler_macro" connection="space" />
      </connection>
I also lose the ship yard and the Capital Ship dealer, so this is clearly not a solution, haha. However, it seems that the type of manager is initialised by looking at the production modules.

I also tried not giving any ship blueprints to the buildmodule. That removes the list or required wares (and the manager whining about money), but hides the Capital Ship Manager options from the station comms (you can still access him via Station details > NPC details > Comm, and he then works fine).

ps. I get the feeling that you could assign a manager to a ship, and it will act like a moving warehouse as well.

Dev disco
Posts: 33
Joined: Wed, 2. Dec 20, 16:35

Re: HELP! Need some guidance with MD<>UI interaction.

Post by Dev disco » Mon, 15. Mar 21, 10:46

I also have the feeling that this part of MD/MainMenu is the key:

Code: Select all

        <!-- Price overrides menu -->
        <do_elseif value="event.param == 'gMain_objectPriceOverrides'">
          <open_conversation_menu menu="PriceOverridesMenu" param="event.param2" param2="event.param3" />
          <add_conversation_view view="closeupdetailmonitor" />
        </do_elseif>

        <!-- Price overrides slider menu -->
        <do_elseif value="event.param == 'gMain_objectPriceOverridesSilder'">
          <open_conversation_menu menu="PriceOverridesSliderMenu" param="event.param2" param2="event.param3" />
          <add_conversation_view view="closeupdetailmonitor" />
        </do_elseif>

        <!-- Trade wares menu -->
        <do_elseif value="event.param == 'gMain_objectTradeWares'">
          <open_conversation_menu menu="TradeWaresSetupMenu" param="event.param2" param2="event.param3" />
          <add_conversation_view view="closeupdetailmonitor" />
        </do_elseif>

        <!-- Trade wares slider menu -->
        <do_elseif value="event.param == 'gMain_objectAddTradeWares'">
          <open_conversation_menu menu="AddTradeWaresMenu" param="event.param2" param2="event.param3" />
          <add_conversation_view view="closeupdetailmonitor" />
        </do_elseif>

I have to figure out what makes you go the Price Overides way (production managers) or the Tarde Wares route (warehouses).

Dev disco
Posts: 33
Joined: Wed, 2. Dec 20, 16:35

Re: HELP! Need some guidance with MD<>UI interaction.

Post by Dev disco » Mon, 15. Mar 21, 17:54

I have drilled deeper and I now know where the UI bases its choice on in menu_orders.lua:

Code: Select all

	if (menu.typestring == "manager") and ( GetComponentData(container, "istradestation") then
		setup:addSimpleRow({
			ReadText(1001, 4228)
		}, "tradewares", {4})
	else
		setup:addSimpleRow({
			ReadText(1001, 4226)
		}, "priceoverrides", {4})
	end
		
I can't find anything about this istradestation elsewhere, though. I assume it's a variable set on the station, but I wonder who sets it.

Dev disco
Posts: 33
Joined: Wed, 2. Dec 20, 16:35

Re: HELP! Need some guidance with MD<>UI interaction.

Post by Dev disco » Tue, 16. Mar 21, 16:16

Victory is mine!

It took three days, tons of headache and 6 lines of code... :evil:

Post Reply

Return to “X Rebirth - Scripts and Modding”