[X3TC] Call script in iteration

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

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

Post Reply
PSCO1
Posts: 1087
Joined: Thu, 4. Jun 09, 17:08
x4

[X3TC] Call script in iteration

Post by PSCO1 » Thu, 11. Mar 21, 07:21

There is my problems once again:

I work on a "Repair Drones" script, but I dont know how to code this:

- 4 items of "Repair Drone ware" in my ship
- 4 "Repair Drones" are created nearby my ship
- The script for "laser repair work" is finished but:

I want to launch all my drones at the same time on the same target,
but actualy, I wait to the 1rst drone finish the repair job then the 2nd drone can begin to work ??? no logic :sceptic:

There is my "poor" code:

Code: Select all

***
***
***

* CREATE DRONES AND MOVE TO TARGET POS

$drones.arr = array alloc: size=0
while $drones.ware.cnt
  dec $drones.ware.cnt =
  $drn = create ship: type={Argon Camera Drone 4771} owner= {Player} addto=$sector x=0 y=0 z=0
  $drn ->set position: x=$x y=$y z=$z
  $drn ->set name to 'Repair Drone'
  = $ship ->install -1 units of $drone.ware
  = $drn ->install 2 units of {1 MJ Shield}
  = $drn ->install 1 units of {Repair Laser}
  
  = $drn ->select best lasers for target $target in turret null: scan for friends null
  $drn ->ignore collisions: [TRUE]
  
  append $drn to array $drones.arr

  = $drn ->call script 'plugin.PSCO1.repairDroneRepair' : victim=$target

  = wait randomly from 1000 to 2000 ms
end
'plugin.PSCO1.repairDroneRepair' contains a loop who check the "HULL %" of the target

With this code, I need to wait the target to be repaired by the 1rst drone to see the others drones work... bad
(I tried also with sub menus but no success...)
Create Wing with a leader ?
Need to remove my loop in my called script ?



Another quick question about

Code: Select all

$target = [THIS] ->get user input: type={Var/Ship}, title=$text
Once the target selected, how to close all selection windows without stop the rest of the script ?

User avatar
Joubarbe
Posts: 4796
Joined: Tue, 31. Oct 06, 12:11
xr

Re: [X3TC] Call script in iteration

Post by Joubarbe » Thu, 11. Mar 21, 08:46

You should read the MSCI Handbook, especially chapter 7.

Code: Select all

= $drn ->select best lasers for target $target in turret null: scan for friends null

is useless. The function doesn't do anything itself, but returns the best laser for selected target. Turret should be 0 if you want the main turret.

Code: Select all

 = $drn ->call script 'plugin.PSCO1.repairDroneRepair' : victim=$target
should be:

Code: Select all

START $drn ->call script 'plugin.PSCO1.repairDroneRepair' : victim=$target
That way, you are starting a new task on $drn instead of staying into your current script (which I suppose is global) and wait for 'plugin.PSCO1.repairDroneRepair' to finish.

PSCO1
Posts: 1087
Joined: Thu, 4. Jun 09, 17:08
x4

Re: [X3TC] Call script in iteration

Post by PSCO1 » Thu, 11. Mar 21, 16:16

Thanks for the tips Joubarbe !

Not so difficult as I expected :)
I will try to finish this script, adjust values, logics...
it's a good knowledge for my others works !

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”