Minimum millisecond wait??

The place to discuss scripting and game modifications for X²: The Threat.

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

AalaarDB
Posts: 2282
Joined: Thu, 29. Jan 04, 08:19
x3tc

Minimum millisecond wait??

Post by AalaarDB »

So I made a while loop that looped for 5000-7000 times. Put a "= wait 1 ms" inside the loop. I thought, no problem it'll just take 5-7 seconds.
Ran it 4 times; I couldn't figure out what was wrong.
About 5-7 Minutes later (and that's an approximation) one of the scripts finally ended, and I got my message.
Oops. Now I know there is a maximum wait cycle, for an example try

Code: Select all

= wait 7200000 ms
send message
goto start
I'm not sure if that exact number will produce the results I'm thinking about, but try some numbers and it'll be apparent.
But now it appears there's a minimum wait number too?

Code: Select all

001   *$testsc = [THIS] -> get sector
002   $sector = [PLAYERSHIP] -> get sector
003   *skip if $sector == $testsc
004   *return null
005   $allships =  array alloc: size=0
006   $play = [FALSE]
007   skip if $whichfleet != null
008    return null
009   start:
010   $x =  find ship: sector=$sector class or type=Cruiser M6 race=Player flags=[Find.Multiple] refobj=null maxdist=null maxnum=25 refpos=null
011   $num = 0
012   $number =  size of array $x
013   skip if not $number > 0
014    $play = [TRUE]
015   while $num < $number
016    $carrier = $x[$num]
017    $Fleetnum = $carrier -> get true volume of ware Data Storage Device in cargo bay
018    if ( $whichfleet == 0 ) AND ( $Fleetnum != 0 )
019     goto label skip
020    end
021    if $whichfleet == $Fleetnum
022   skip:
023     $carID = $carrier -> get SectorObject ID
024     $test =  get object from SectorObject $carID
025     $scanrange = $carID + 5000
026     while $scanrange > 1
---------Put a wait 1 ms here ----------
027      dec $scanrange = 
028      if  exists SectorObject $scanrange
029       $shipware =  get ware type of SectorObject $scanrange
030   *if $shipware -> is of class Ship
031        $env = $scanrange -> get environment
032        skip if $env != $carrier
033         append $scanrange to array $allships
034   *end
035       end
036      end
037     end
038     $num = $num + 1
039    end
040    $rand = random value from 0 to 2 - 1
041    skip if $rand != 0
042     $sample = 896
043    skip if $rand != 1
044     $sample = 1166
045    skip if $play != [TRUE]
046     play sample $sample
047    $size =  size of array $allships
048    $msg = sprintf: fmt='%s %s', $size, $test, null, null, null
049    send incoming message $msg to player: display it=[TRUE]
050    return null
AalaarDB
Posts: 2282
Joined: Thu, 29. Jan 04, 08:19
x3tc

Post by AalaarDB »

PS I'm doing something wrong, I think it's with the environment part as I'm not too familiar with that. Anyone have ideas why size is always 0? I've got a test centaur with 2 docked discoverers, fleetnum 1, it returns Your Argon Centaur so I know that much works. I've also gotten over 3000 $size when I set "skip if $env |= null" (that means 3000+ sector object IDs that did not exist, in the range of $carID + 5000)

I think I just figured it out after posting, $carrier is an array not a ship. Scratch that, it's $X that's an array and carrier *is* a ship.

Return to “X²: The Threat - Scripts and Modding”