Unknown freeze

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

Locked
User avatar
Joubarbe
Posts: 3596
Joined: Tue, 31. Oct 06, 13:11
xr

Unknown freeze

Post by Joubarbe » Fri, 2. Feb 18, 11:13

I've got that code:

Code: Select all

$sector = [SECTOR]
$support = $sector-> get local variable: name='mayhem_secStatsSupport'

*do if [THIS] -> call script 'Mayhem.IsPerkUnlocked': perk='Extra factory support'
*$support = $support + 4

$allStations.size = [NULL]-> call script 'Mayhem.GetNbPCFactories' : sector=$sector
$people = [THIS]-> get local variable: name='mayhem_people'
Nothing fancy... But if I uncomment the two lines in the middle, the game doesn't run anymore, it freezes.

The same call is made in several places, without problem. This call in this code is NOT made upon game start.

I've tried to create another script with a different name and the same code, as I already had problem with X-Studio or another obscure reason. But that doesn't work either.

Funny thing is when the freeze occurs at game loading, the game still take 25% of my proc and keeps filling the RAM.

User avatar
Joubarbe
Posts: 3596
Joined: Tue, 31. Oct 06, 13:11
xr

Post by Joubarbe » Fri, 2. Feb 18, 15:33

Code: Select all

START [THIS] -> call script 'Mayhem.IsPerkUnlocked': perk='Extra factory support'
The game loads.

Code: Select all

= [THIS] -> call script 'Mayhem.IsPerkUnlocked': perk='Extra factory support'
The game freezes.

---

EDIT: when I type the "do if... call script" line in the in-game editor, the game freezes right after I save the script...!

EDIT2: recreated the script with another name, and now it works... Probably X-Studio, we'll never know...!

|K.O.S.H.
Posts: 3217
Joined: Fri, 19. Dec 03, 11:36
x3tc

Post by |K.O.S.H. » Mon, 5. Feb 18, 10:15

what does the script do?

the game usually freezes on infinite loops or stack overflow.
does it call itself?
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

User avatar
JSDD
Posts: 897
Joined: Fri, 21. Mar 14, 21:51
x3tc

Post by JSDD » Mon, 5. Feb 18, 11:21

Joubarbe wrote:... The game loads. ...
is this in a "init." or "setup." script ? i remember that in case of setup/init scripts the actions must not take a long time, otherwise some errors (skipping that script etc) can occur. see gazz's delayed mars setup (for example) to circumvent possiple errors ... start a global script which waits for about 10-30seconds, then do the "heavy" setup

START X -> call script is NOT a blocking instruction, which means that the script will be invoked BUT the invoking script executes without waiting for the return of the invoked script.

without START prefix, it is a blocking instruction, which means this script waits for the return of the invoked script.

do if xyz -> call script: ... is also a blocking instruction, it waits for the return and uses the return value for the logical operation "do if" (or "skip if").
To err is human. To really foul things up you need a computer.
Irren ist menschlich. Aber wenn man richtig Fehler machen will, braucht man einen Computer.


Mission Director Beispiele

|K.O.S.H.
Posts: 3217
Joined: Fri, 19. Dec 03, 11:36
x3tc

Post by |K.O.S.H. » Mon, 5. Feb 18, 11:42

START starts the script a new/separate thread :)
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20547
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Mon, 5. Feb 18, 12:02

The reason it works when using START is because, scripts that are started on another process dont have a return value.

so your do if is always false

to be extra safe, you could check if $support is actual equal to something, and if not, set it to 0

Code: Select all

skip if $support
  $support = 0
in MSCI, 0, null and [FALSE] are all different values

User avatar
Joubarbe
Posts: 3596
Joined: Tue, 31. Oct 06, 13:11
xr

Post by Joubarbe » Mon, 5. Feb 18, 12:09

Please close this thread. Thanks.

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

Post by X2-Illuminatus » Mon, 5. Feb 18, 12:24

*click*

Locked

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