[Discussion] Generic X3TC S&M questions III

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

Post Reply
User avatar
RoverTX
Posts: 1436
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Tue, 1. Jan 13, 00:53

What is the value at which numbers overflow in a script? Its signed so like 1 billion something correct, if it doesn't use the new big number introduced in AP?

I ask because I realized I am multiplying ship price times 18 and I am pretty sure for pricier ships thats going to cause an overflow...

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

Post by jack775544 » Tue, 1. Jan 13, 04:38

2 and a bit billion.
Or (2^31)-1
1940s - Various "computers" are "programmed" using direct wiring and switches. Engineers do this in order to avoid the tabs vs spaces debate.

User avatar
Jack08
Posts: 2993
Joined: Sun, 25. Dec 05, 10:42
x3tc

Post by Jack08 » Tue, 1. Jan 13, 04:42

RoverTX wrote:What is the value at which numbers overflow in a script? Its signed so like 1 billion something correct, if it doesn't use the new big number introduced in AP?

I ask because I realized I am multiplying ship price times 18 and I am pretty sure for pricier ships thats going to cause an overflow...
AP has no "long" value support, it uses an overflow counting system, for each ( 2^31 - 1 ) the overflow value is upped by 1
[ external image ]
"One sure mark of a fool is to dismiss anything that falls outside his experience as being impossible."
―Farengar Secret-Fire

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

Post by jack775544 » Wed, 2. Jan 13, 03:27

I have a script where there is an error. I was able to isolate it down to this single section.

Code: Select all

007    $alphabet = array alloc : size = 0
008    $alphabet [ 0 ] = 'a'
009    $alphabet [ 1 ] = 'b'
010    $alphabet [ 2 ] = 'c'
011    $alphabet [ 3 ] = 'd'
012    $alphabet [ 4 ] = 'e'
013    $alphabet [ 5 ] = 'f'
014    $alphabet [ 6 ] = 'g'
015    $alphabet [ 7 ] = 'h'
016    $alphabet [ 8 ] = 'i'
017    $alphabet [ 9 ] = 'j'
018    $alphabet [ 10 ] = 'k'
019    $alphabet [ 11 ] = 'l'
020    $alphabet [ 12 ] = 'm'
021    $alphabet [ 13 ] = 'n'
022    $alphabet [ 14 ] = 'o'
023    $alphabet [ 15 ] = 'p'
024    $alphabet [ 16 ] = 'q'
025    $alphabet [ 17 ] = 'r'
026    $alphabet [ 18 ] = 's'
027    $alphabet [ 19 ] = 't'
028    $alphabet [ 20 ] = 'u'
029    $alphabet [ 21 ] = 'v'
030    $alphabet [ 22 ] = 'w'
031    $alphabet [ 23 ] = 'x'
032    $alphabet [ 24 ] = 'y'
033    $alphabet [ 25 ] = 'z'
034   
035    $size = size of array $alphabet
036    while $size
037   | dec $size
038   | $selection = $alphabet [ $size ]
039   | write to player logbook $selection
040    end 
I put in the while loop to see what the array was, but when I check my logbook after the script is finished, I had nothing in there. So I changed it so size would be assigned 26 and I removed the get size of array command, but this just gave me 26 null statments in my logbook. So does anyone know why this array has nothing in it?

Thanks
1940s - Various "computers" are "programmed" using direct wiring and switches. Engineers do this in order to avoid the tabs vs spaces debate.

User avatar
RoverTX
Posts: 1436
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Wed, 2. Jan 13, 10:24

Your allocating 0. So you either need to append instead of trying to put them into specific locations, or allocate 26 spots. Other wise your putting them in places that can't be retrieved from memory.

In short your putting stuff in a black hole, so you need to declare the space or use the append method which does it for you.

----------------------------END ANSWER --------------------------

Now for my stupid question of the day.

----------------------------START QUESTION----------------------

A few questions on calling scripts from within scripts.

Ok if I understand correctly START creates a new process that is independent of the current running script. So it will stay alive after the current one dies. It also means if it is run on the same object as the current running script it wont actually 'START' until the next wait, interrupt or the script is finished. That is correct right?

Next when should I call a script on ship with START, or when should I call the script globally and pass the ship as a parameter? This bit has got me a little confused. As long as the command is quick or has plentiful wait statements, it doesn't really matter does it?

I am a little confused because some one said to not do the following if you want the containing scrip to move on.

Code: Select all

@  =$ship-> call script "plugin.xxx":
But instead to do this assuming [THIS] is global.

Code: Select all

@  =[THIS]-> call script "plugin.xxx":ship=$ship
Which makes sense because the call gets put on the stack for global which of course doesn't execute till the current one is finished, waits, or is interpreted. But wouldn't the following have the same effect as above, or am I missing something?

Code: Select all

@   START $ship-> call script "plugin.xxx":
Also wouldn't the second code clip cut out once the containing code was finished? While the third one would go on until its finished?

IE You would use the second one if you need everything to end no matter what once the top one is finished, and you would use the third when you want it to survive past the top level script? Or is there some additional difference in application that I am missing?

:oops: Sorry if this is a dumb convoluted question... :oops:

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

Post by jack775544 » Wed, 2. Jan 13, 12:31

How did I miss that :headbang:

For your question, the first piece of code would be run on the object $ship and would halt the calling script until it's done.
The second would just run it as a global script assuming that [THIS] is null. It would run the called script and when it returns it would resume the calling script.
The third piece of code would run the script on task 0. Remember that the call script section is an interrupt point so the called script would run before the rest of the calling script is run.

If anyone more knowledgable than I has something to add, or point out any inaccuracies please say so.
1940s - Various "computers" are "programmed" using direct wiring and switches. Engineers do this in order to avoid the tabs vs spaces debate.

User avatar
RoverTX
Posts: 1436
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Wed, 2. Jan 13, 18:56

Ah ok that clears it some what. So it will always enter the call script because the call itself is an inturrept intersting! I did a little test. Where [THIS] Is null

L1

Code: Select all

write to player logbook 'L1 START'
= [THIS]-> call script 'AAAL2' :
write to player logbook 'L1 MID'
= [THIS]-> call script 'AAAL3' :
write to player logbook 'L1 END'
return null
L2

Code: Select all

write to player logbook 'L2 START'
= wait 10000 ms
write to player logbook 'L2 END'
return null
L3

Code: Select all

write to player logbook 'L3 REACHED'
return null
From oldest to newest in my log book was.

L1 START
L2 START
L2 END
L1 MID
L3
L1 END

Then I tried the following changes to L1

L1

Code: Select all

write to player logbook 'L1 START'
START [THIS]-> call script 'AAAL2' :
write to player logbook 'L1 MID'
START [THIS]-> call script 'AAAL3' :
write to player logbook 'L1 END'
return null
The following happened

L1 START
L2 START
L1 MID
L3
L1 END
L2 END

Then the following

L1

Code: Select all

write to player logbook 'L1 START'
START [PLAYERSHIP]-> call script 'AAAL2' :
write to player logbook 'L1 MID'
START [PLAYERSHIP]-> call script 'AAAL3' :
write to player logbook 'L1 END'
return null
L1 START
L2 START
L1 MID
L3
L1 END

(It exited before L2 END could be reached)

Code: Select all

write to player logbook 'L1 START'
= [PLAYERSHIP]-> call script 'AAAL2' :
write to player logbook 'L1 MID'
= [PLAYERSHIP]-> call script 'AAAL3' :
write to player logbook 'L1 END'
return null
L1 START
L2 START
L2 END
L1 MID
L3
L1 END

(Same as the first)

I think I kind of have it now.

So if I want a script to return to the top level at the next inturrpt I have to use START.

If I want a script to survive the top level dying off I need to call it globally.

That right?

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

Post by jack775544 » Wed, 2. Jan 13, 22:24

Yes. If [THIS] is either null or it is another variable eg. $ship, using start will run the called script in parallel with the calling one. If [THIS] is an object the script will be run on task 0 (also in parallel). Using a RetVal, the called script shall execute, before returning control to the calling script.

I should of said this before, but have a look on page 31 of the MSCI Handbook, it has a great description of how the command works.
1940s - Various "computers" are "programmed" using direct wiring and switches. Engineers do this in order to avoid the tabs vs spaces debate.

flopsies
Posts: 64
Joined: Tue, 15. May 12, 04:35

Post by flopsies » Mon, 14. Jan 13, 15:11

Do XSP ships cause the "Modified" flag? I use Humble merchant, no Cycrow cheats, and I still don't get achievements on Steam.

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24965
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus » Mon, 14. Jan 13, 15:27

Yes, they do. They are basically (small) mods.

The ***modified*** sign is displayed at the bottom of the pilot statistics (by default press two times 'p' then scroll down to the bottom of the screen).
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

flopsies
Posts: 64
Joined: Tue, 15. May 12, 04:35

Post by flopsies » Mon, 14. Jan 13, 23:03

Is there a way around this then?

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24965
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus » Mon, 14. Jan 13, 23:11

No, there isn't.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

flopsies
Posts: 64
Joined: Tue, 15. May 12, 04:35

Post by flopsies » Mon, 14. Jan 13, 23:29

Sigh... Do scripts or Cadius' ships as a fake patch though?

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24965
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus » Mon, 14. Jan 13, 23:38

It doesn't depend on the installation method, whether a mod marks your game as *modified* or not, but on the files it changes.

All scripts, except for the ones from the official bonus package, and all mods, except for a few vanilla safe mods, mark your game as *modified*.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22236
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Tue, 15. Jan 13, 09:48

Modified != Cheats

Modified is any changes to the game. Adding ships will be a change to the game.

There are a few mods that only change certain cosmetic things which wont detect as modified. But almost all mods will

User avatar
RoverTX
Posts: 1436
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Wed, 16. Jan 13, 21:47

So I have a few ships I want to add into my game, but I don't want to add the Engine Effects and Engine Emmitters so I am trying to remove them from the scene file, but if I do that then I throw off the number of the index and the turrets stop working.

So I either

A. Have to redo all the numbers and then redo the turrents in the Tship file.

OR is this possible

B. Add in an empty entry to the scene file instead of engine effect/emitters.

I would really like to be abel to do B but I really don't know whats safe to put in there as an empty place holder.


Would the following work for an empty place holder?

Code: Select all

P X; B ; C 99999; N ; b  // idx X
X being the current index number.

Edit: Tested it and it seems to work! If anyone still has any insight though I would be great full.

User avatar
RoverTX
Posts: 1436
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Fri, 18. Jan 13, 03:36

Is the hiring of TLs hard coded or can I modify it some where?

In order to fix an unforeseen issue with my Station Capture through TL capture scripts I need to remove all stations from TLs cargo bay when they are hired otherwise players can end up with free stations. Is this possible?

User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle » Fri, 18. Jan 13, 03:51

Supply TL's run the job "special.idle" when they are roaming about.

If they have cargo already, then you cannot hire them.

So I think the solution is to never place stations on TL's running "special.idle".

User avatar
RoverTX
Posts: 1436
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Fri, 18. Jan 13, 04:52

I noticed most of they where running that job from the Job File, but thought nothing of it because it doesn't seem to do anything but tell them to move around the sector or return to their homesector if they aren't already there.

Thats like 70% of the NPC TLs out there. I think I am just going to add a signal too all the ships that will trigger a script.

The signal will work when the ship is owned by a player, and will then add a random factory after capture. Its the same outcome, just a little bit different of an effect because you wont be able to see the stations in the TLs cargo bay before capture.

Hornet108
Posts: 343
Joined: Thu, 15. Nov 12, 13:46
x4

Post by Hornet108 » Thu, 24. Jan 13, 14:52

Hmm, im seeing some odd behaviour when I have a large-ish amount of ships entering a sector at once, some ships are appearing at 0,0,0 and are not rendering. If I go OOS and come back in however, they are fine. Anyone know what might be causing this?

Post Reply

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