find_ship & find_station / how to cleanup?

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

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

Post Reply
Andy_MB
Posts: 72
Joined: Fri, 24. Jul 15, 17:47
x4

find_ship & find_station / how to cleanup?

Post by Andy_MB » Sun, 11. Mar 18, 19:11

When you change a cluster in these commands, the list of previously found objects is not cleared! w/ key space="player.cluster"

Code: Select all

<find_ship groupname="$aShips" space="player.cluster" known="true" masstraffic="false" multiple="true" class="[class.ship_l, class.ship_xl]">
i use:

Code: Select all

<clear_group group="$aShips"/>
or / and
<clear_list list="$aShips"/>
<remove_value name="$aShips"/>
no effect! :(

...
load gamet and looking for ships in the DV - everything is fine. Found ships that are present in the DV
Clear the list of objects
I fly/jump to OL.
Again looking for ships
And the list contains the old list (DV) + new ones from the OL.
The list is replenished for all clusters.
Cleared only when the game is loaded.
What can I do to make the command work only on the 1 cluster in which the player is located?

Thanks!
_____________

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

Post by UniTrader » Sun, 11. Mar 18, 19:33

clear_group should usually do the trick. can you post your whole Code? maybe the issue lies somewhere else.. (for example the Group is cloned by passing it back and forth through the UI or something..)
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 ;)

Andy_MB
Posts: 72
Joined: Fri, 24. Jul 15, 17:47
x4

Post by Andy_MB » Sun, 11. Mar 18, 19:56

Thanks, Uni!
I solve this problem. :)

Code: Select all

<create_group groupname="$gOfferedShips"/>
<clear_group group="$gOfferedShips"/>
<find_ship groupname="$gOfferedShips" space="player.cluster"...
full code was:

Code: Select all

          <do_elseif value="event.param == 'diplomat_ships'">
            <!--найти все покрасневшие кораблики и передать в меню. Исключить неизвестные игроку-->
          
            <find_ship groupname="$gOfferedShips" space="player.cluster" masstraffic="false" multiple="true" class="[class.ship_l, class.ship_xl]" comment="class.ship_xl or class.ship_l"/>
            <create_list name="$gFoundedShips" exact="[]"/>
            <create_list name="$gRelations" exact="[]"/>
            <create_list name="$gShipsPrices" exact="[]"/>
            <do_if value="$gOfferedShips.count == 0">
              <append_to_list name="$gFoundedShips" exact="player.primaryship" />
            </do_if>
            <do_all exact="$gOfferedShips.count" counter="$i">
              <do_if value="$gOfferedShips.{$i}.owner != faction.player" comment="исключаем корабли игрока">
                <do_if value="player.primaryship.relationto.{$gOfferedShips.{$i}} lt -0.01" comment="исключаем нейтральных и друзей = neutral:  -0.01 to  0.01 / friend = 0.01 = +10(ui)">
                  <set_value name="$add_relation_upto_friend" exact="0.01 - player.primaryship.relationto.{$gOfferedShips.{$i}}"/>
                  <append_to_list name="$gFoundedShips" exact="$gOfferedShips.{$i}" />
                  <append_to_list name="$gRelations" exact="player.primaryship.relationto.{$gOfferedShips.{$i}}" />
                  <append_to_list name="$gShipsPrices" exact="100000Cr + (($gOfferedShips.{$i}.value)f * $add_relation_upto_friend / 2)i" comment="стоимость оплаты дипломату = 100т.кр. + пол стоимости корабля * прибавку к репутации. т.е. при репе -30 макс сумма"/>
                </do_if>
              </do_if>
            </do_all>
            <open_conversation_menu menu="DiplomatShipsMenu" param="[0,0,{98981,2035},$gFoundedShips,'diplomat','ok_button_ship',$gRelations,$gShipsPrices]" />
            <add_conversation_view view="closeupdetailmonitor" />
            
          </do_elseif>
Clen cue:

Code: Select all

    <cue name="ClenUp_values" instantiate="true" namespace="this">
      <conditions>
        <check_any>
          <event_cue_signalled cue="this"/>
          <event_conversation_returned_to_section section="diplomat"/>
        </check_any>
      </conditions>
      <actions>
        <show_help custom="'cleanup'"/>
        <remove_value name="$gFoundedFactions"/>
        <remove_value name="$gFactionRelations"/>
        <remove_value name="$gThe_price_of_improving_relations"/>
        <clear_group group="$gOfferedStations"/>
        <remove_value name="$gOfferedStations"/>
        <remove_value name="$gFoundedStations"/>
        <remove_value name="$gStationsRelations"/>
        <remove_value name="$gStationsPrices"/>
        <clear_group group="$gOfferedShips"/>
        <remove_value name="$gOfferedShips"/>
        <remove_value name="$gFoundedShips"/>
        <remove_value name="$gRelations"/>
        <remove_value name="$gShipsPrices"/>
      </actions>
    </cue>
_____________

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

Post by UniTrader » Sun, 11. Mar 18, 20:22

ok, so you solved it. But a few more hints:

Code: Select all

<create_list name="$gFoundedShips" exact="[]"/> 
thats wrong this way, the exact value gives the initial amount of elements (filled with null), not the List content. you can use either of these to create an empty list:

Code: Select all

<create_list name="$gFoundedShips" exact="0"/> 

Code: Select all

<set_value name="$gFoundedShips" exact="[]"/> 
but combining them is nonsense (i think there is an error about that in the logfile, if you are logging)

Also i think there is another flaw: i guess you (ab)use the Playership as fallback in case no suitable Ship was found to not Crash the UI/pass an empty List? what happens if the Player is in a Cluster only containing Player-owned or friendly Capships?

Code: Select all

            <do_if value="$gOfferedShips.count == 0">
              <append_to_list name="$gFoundedShips" exact="player.primaryship" />
            </do_if>
           .....
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 ;)

Andy_MB
Posts: 72
Joined: Fri, 24. Jul 15, 17:47
x4

Post by Andy_MB » Sun, 11. Mar 18, 21:14

1. According to the scheme, I realized that I can do this. But I will use separate writing.

Code: Select all

<xs:element name="create_list">
        <xs:annotation>
          <xs:documentation>
            Create a list of given element count (default is 0), filled with null values. Use [] syntax instead for lists with fixed size/content.
          </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:attributeGroup ref="action" />
          <xs:attributeGroup ref="random">
            <xs:annotation>
              <xs:documentation>
                Number of elements
              </xs:documentation>
            </xs:annotation>
          </xs:attributeGroup>
          <xs:attribute name="name" type="lvaluename" use="required" />
        </xs:complexType>
      </xs:element>
2. Yes, this is because there is no check in the UI for an empty list.
I made a check in UI. Now I can exclude this code.

ps: & now no need cue name="ClenUp_values" :) (-24 lines)
_____________

Post Reply

Return to “X Rebirth - Scripts and Modding”