[SCR] Replication v1.0.0 (21-03-14)

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

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

Pierre'70
Posts: 124
Joined: Sat, 30. Apr 05, 12:19
x4

Post by Pierre'70 » Thu, 11. Sep 14, 18:21

SUCCESS! Er, oh dear. I took your advice and manually typed in the required lines (on a fresh version of the file I hadn't edited with Notepad ++). This saved properly with no error messages. The only problem is that when I loaded a save I found that I couldn't now Replicate ANY missiles at all - only satellites and drones!

Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod » Thu, 11. Sep 14, 20:18

Progress :)

To debug, insert some logging into Get.Missiles as follows. It'll output to 'Documents\Egosoft\X3AP\log01234.txt'.
a. If no logging appears check that Get.Missiles is being called
b. If no missiles are found, check the logic of Get.Missiles
c. If missiles are found, check that the calling logic is assigning $Unsorted = $Missiles.

Code: Select all

Get.Missiles: 
    $Missiles = array alloc: size = 0 
    $idx = get number of subtypes of maintype 10

write to log file 1234 append=0 printf: fmt='Found %s missiles', $idx, null, null, null, null

    while $idx 
        dec $idx 
        $Missile = get ware from maintype 10 and subtype $idx 

write to log file 1234 append=1 printf: fmt='Missile=%s', $Missile, null, null, null, null

        append $Missile to array $Missiles 
    end 

write to log file 1234 append=1 printf: fmt='Missiles=%s', $Missiles, null, null, null, null

endsub 

Pierre'70
Posts: 124
Joined: Sat, 30. Apr 05, 12:19
x4

Post by Pierre'70 » Thu, 11. Sep 14, 22:43

I've created a log, it says

Found null missiles
Missiles=ARRAY ( )


Not sure what to do next!

Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod » Fri, 12. Sep 14, 00:06

I pasted that same Get.Missiles code and it finds them for me, how bizarre.

The found 'null' missiles might be a clue though, as null tends to mean its either uninitialized or is returned as a fallback when doing dodgy operations (5 + null = null). I'd be suspicious of that $idx assignment.

In case you're wondering where the magic number of 10 comes from, maintypes are like ware categories and 10 is the category for missiles:
http://forum.egosoft.com/viewtopic.php?t=292613

Btw I noticed when pasting from the forum's code block that it adds a trailing space to every line, and this seems to be what caused the compile error in X-Studio. Trimming off the space makes it work.

Code: Select all

Found 49 missiles
Missile=Pirate Dummy Missile
...
Missile=Mosquito Missile
Missiles=ARRAY ( Pirate Dummy Missile, Teladi Dummy Missile, Split Dummy Missile, Paranid Dummy Missile, Boron Dummy Missile, Argon Dummy Missile, Gibson Barrage Missile, Heinlein Heavy Torpedo, ... )
As a last resort you could hardcode them:

Code: Select all

Get.Missiles: 
    $Missiles = array alloc: size = 0
    append {Mosquito Missile} to array $Missiles
    ...
endsub
You can use X-Studio's Game Objects tab on the right to filter down to a list of missiles then double-click them to insert the appropriate token for that missile into the code window at the cursor.

Pierre'70
Posts: 124
Joined: Sat, 30. Apr 05, 12:19
x4

Post by Pierre'70 » Fri, 12. Sep 14, 11:49

I've got it working. Copy-pasting, then removing the space from the end of each line, did the trick. Not sure how I managed to mess up manually typing the code in.

Thanks for your patience and help Shimrod. Not sure why there isn't more traffic on this topic, Replication is a great script.

g_BonE
Posts: 153
Joined: Thu, 28. Aug 03, 11:37
x4

Post by g_BonE » Mon, 15. Sep 14, 19:17

Hi, thanks and question time: Could this mod be used with Litcubes Universe seeing that it needs some obscure EMP which i doubt is compatible with LU?
(x|x) .oO[ Fenster fährt mich Nüsse !!! ]

Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod » Sat, 20. Sep 14, 20:27

I haven't tried LU yet. If it bundles the extended EMP (EMP-X) ware entries then it should work right away. Alternatively if X plugin manager can be used with LU, then it I believe this installs EMP-X.

Replication adds the following message to the player logbook at game load if it can't find the ware slot it needs.

Code: Select all

Replication: Cannot find Replicator ware. Note that this script depends on EMP

g_BonE
Posts: 153
Joined: Thu, 28. Aug 03, 11:37
x4

Post by g_BonE » Sun, 21. Sep 14, 08:53

Unfortunately i think its a NOPE to both suggestions. Well too bad - i'll go with just OK Traders then ;)
(x|x) .oO[ Fenster fährt mich Nüsse !!! ]

User avatar
jack775544
Posts: 1277
Joined: Tue, 13. Dec 11, 08:27
x4

Post by jack775544 » Sun, 21. Sep 14, 12:18

LU doesn't have EMP installed by default and it is incompatible with the plugin manager making installing it a big pain in the ass. And even then there is no guarantees since Litcube has made so many changes.
1940s - Various "computers" are "programmed" using direct wiring and switches. Engineers do this in order to avoid the tabs vs spaces debate.

Post Reply

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