[HELP] How to best uninstall a ware from a trader's list?

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

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

oliverjanda
Posts: 309
Joined: Sun, 14. Feb 10, 17:47
xr

[HELP] How to best uninstall a ware from a trader's list?

Post by oliverjanda »

Hi,
I added a new ware to the list of a trader:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<mdscript name="HUDOnlyCockpit" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">

	<cues>
		<cue name="AddCockpit" instantiate="false">
			<conditions>
				<check_any>  
					<event_cue_completed cue="md.Setup.Start"/>
					<event_game_loaded/>  
				</check_any>     
			</conditions>
			<actions>  
				<include_actions ref="PatchAddCockpit" />					
			</actions>  
		</cue> 

		<library name="PatchAddCockpit">
			<actions>

				<set_value name="$MechanicNewItemList" exact="
                [
                    [ware.spe_cockpit_test,  1, 1, 100]
                ]
			"/> 

				<do_all exact="$MechanicNewItemList.count" counter="$Counter">	 
					<do_if value="md.$CockpitUpgradetraderLists.{1}.indexof.{$MechanicNewItemList.{$Counter}}" negate="true" >
						<append_to_list name="md.$CockpitUpgradetraderLists.{1}" exact="$MechanicNewItemList.{$Counter}" />
					</do_if> 
				</do_all>

			</actions>
    </library>

	</cues>
</mdscript>
So how do I make this savegame compatible?
How do I remove the item from the list on uninstallation?
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

not reallly sure if it actually works, but here is my approach:

Code: Select all

<cues>
  <cue name="RemoveCockpit">
    <conditions>
      <!-- Uninstall Condition, not sure what to use - best use some event and no check_value so no polling is done -->
    </conditions>
    <actions>
      <do_all exact="$MechanicNewItemList.count" counter="$Counter">
        <remove_value name="md.$CockpitUpgradetraderLists.{1}.{md.$CockpitUpgradetraderLists.{1}.indexof.{$MechanicNewItemList.{$Counter}}}" />
      </do_all>
    </actions>
  </cue>
</cues>

note that this has to be executed before the Mod is uninstalled because the Script is no longer existent when the Mod is removed.
Alternatively it may be wiser to add a Validation of all Trader Lists on Game Loading to remove non-existent Items from them in a seperate Extension...
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 ;)
oliverjanda
Posts: 309
Joined: Sun, 14. Feb 10, 17:47
xr

Post by oliverjanda »

Thanks, I tried exactly the same md script but can't start it atm.
I'm trying to start it via a sidebar entry but i can't get it to show up.
No error message either. never did lua before...

Return to “X Rebirth - Scripts and Modding”