How to delay a script from initialising....

Home Board Index » X3AP » Scripts and Modding » How to delay a script from initialising....

RobertSchafer

RobertSchafer avatar
Level badge Skillguey (7)
Posted 10 years ago.

hi,

im currently working on a point 2 point jump system (actually its one created by paulP). Ive modified it to suite the needs of the bsg mod, however i havent been able to figure out how to introduce a delay into the script. Basically this is supposed to mimic an ftl system spooling up. Therefore i would like to introduce a 1 minute time delay (or something around this time) after the hotkey has been pressed and the jump location has been chosen. This is the code bellow, where and what do i have to add in to create such an effect? im at a loss :P


if not [PLAYERSHIP]-> get true volume of ware {Jumpdrive} in cargo bay
= speak text: page=17 id=3983 priority=0
= speak text: page=13 id=24 priority=0
return null
end
if not [PLAYERSHIP]-> get true volume of ware {Navigation Command Software MK1} in cargo bay
= speak text: page=17 id=5673 priority=0
= speak text: page=13 id=24 priority=0
return null
end
if not [PLAYERSHIP]-> get true volume of ware {FTL Coils} in cargo bay
= speak text: page=17 id=50690 priority=0
= speak text: page=13 id=24 priority=0
return null
end

$jump.location = [PLAYERSHIP]-> get user input: type=[Var/Sector Position], title='Select Jump Location'
skip if $jump.location
return null

$current.sector = [PLAYERSHIP]-> get sector
$x = $jump.location[0]
$y = $jump.location[1]
$z = $jump.location[2]
$target.sector = $jump.location[3]

$tyfuel = [PLAYERSHIP]-> get true volume of ware {Tylium fuel} in cargo bay
$fuel = [PLAYERSHIP]-> needed jump drive energy for jump to sector $target.sector
* BW: ==============================
$fuel = $fuel
* $fuel = $fuel * 2
* BW: ==============================
if not $tyfuel >= $fuel
= speak text: page=13 id=1100056 priority=0
return null
end

$followers = [PLAYERSHIP]-> get formation follower ships
if $followers
if [PLAYERSHIP]-> get user input: type=[Var/Boolean], title='Should followers jump too?'
for each $follower in array $followers using counter $total
$follower-> interrupt with script 'plugin.paulp.gatelessjump.follow' and priority 25: arg1=$jump.location arg2=null arg3=null arg4=null
end
end
end

= [PLAYERSHIP]-> use jump drive: target=$target.sector
[PLAYERSHIP]-> set position: x=$x y=$y z=$z
$fuel = -$fuel / 2
= [PLAYERSHIP]-> add $fuel units of {Tylium fuel}
return null


PS: @roguey, i sent you a similar message on the egosoft forum, but thought it would be interesting for other people do understand how to create an effect like this.

---- X3ap Battlestar Galactica mod ----
Latest update: 06/01/2014.
Team recruitment: Texture artist
Mod updater/downloader via our website:
www.x-battlestar.com
Raptor

Raptor avatar
Level badge Instruguey (13)
Posted 10 years ago.

Hey again,

Well the normal vanilla Jumpdrive also take few seconds charging before jumping to destination. If the script that do the jump function (if a script do that) could be located, maybe it could help?

Also note that there is another script, "Improved Kha'ak 2", that uses a P2P jumpdrive. Though I haven't tried it yet but I thought it might help someway, if you wish to check it out.

I wish if I could help more but I'm not a 'scripter', not yet... still learning. Smile

It does not matter what we were in the past but what we are now, what we do and what we are going to be, our destiny.
RobertSchafer

RobertSchafer avatar
Level badge Skillguey (7)
Posted 10 years ago.

thanks for the reply Smile

ive already checked both of your suggestions out, i cant seem to locate that part of the code anywhere. It must just be a simple line but i just cant locate it!
hopefully someone else or maybe roguey will save our asses :P

Miles

---- X3ap Battlestar Galactica mod ----
Latest update: 06/01/2014.
Team recruitment: Texture artist
Mod updater/downloader via our website:
www.x-battlestar.com
Roguey

Roguey avatar
Level badge Trueguey (22)
Posted 10 years ago.

oh, I just responded to you PM on the egosoft site..

as for my response;

hmm.. looking at that code, why dont you do the actual jump in another file? like a function. That way you can call the script synchronously, then put a delay in the other. This should give you the delay you want. You could probably then add sound effects too. ie. charge up sound, wait 3 secs, jump. You can pass variables to a script, much like a function

RobertSchafer

RobertSchafer avatar
Level badge Skillguey (7)
Posted 10 years ago.

Well the issue is this code you see here also links to to a further script that controls followers. In other words if you have ships following you, and you initiate a jump it will ask you whether you would like them to jump with you, if you do it will also check them for the correct wares and whether they have enough tylium (as in energy to jump). The code is very similar to the above.

It just seems like it would become rather a mess if i had to split it..... i also dont have the experience to completely re-do the code :P

Would it be possible to add in a delay or wait command in the code above? or is that not possible without splitting them into two different files? Also if it where possible would i be able to add in a charge up sound?

Also, would i be correct to say that the following lines of code is where the actual jump happens? the rest is just setting up variables and acquiring info on e.g enough fuel, correct wares ect


= [PLAYERSHIP]-> use jump drive: target=$target.sector
[PLAYERSHIP]-> set position: x=$x y=$y z=$z
$fuel = -$fuel / 2
= [PLAYERSHIP]-> add $fuel units of {Tylium fuel}
return null

---- X3ap Battlestar Galactica mod ----
Latest update: 06/01/2014.
Team recruitment: Texture artist
Mod updater/downloader via our website:
www.x-battlestar.com
Roguey

Roguey avatar
Level badge Trueguey (22)
Posted 10 years ago.

Well you could add a wait command into code, just before;

= [PLAYERSHIP]-> use jump drive: target=$target.sector


The reason I suggested to make it into another file, is to make it like an event (ie. give it a task to do), like how plugin.paulp.gatelessjump.follow interrupts the current action.. Adding wait timers to that code is a little hacky way of doing things, but would probably work fine for you. Its just that I try and doing it the best way Smile

RobertSchafer

RobertSchafer avatar
Level badge Skillguey (7)
Posted 10 years ago.

Ahhh ok, no thats great that your trying to show me the correct way haha.

So what your saying is move this code


= [PLAYERSHIP]-> use jump drive: target=$target.sector
[PLAYERSHIP]-> set position: x=$x y=$y z=$z
$fuel = -$fuel / 2
= [PLAYERSHIP]-> add $fuel units of {Tylium fuel}
return null


to a seperate file, add in @ start call script 'nameofnewscript' after the follow commands. Then add in the wait command to the new script?

Or have i misunderstood a load of stuff :P

---- X3ap Battlestar Galactica mod ----
Latest update: 06/01/2014.
Team recruitment: Texture artist
Mod updater/downloader via our website:
www.x-battlestar.com
Roguey

Roguey avatar
Level badge Trueguey (22)
Posted 10 years ago.

Lol, well after doing all the decoding of rebirths XML, I learnt to try and code things better - it can make it easier in the long run.

As for your code, that is what I was suggesting. Basically your creating an event (to jump), and rather tie up your main code, your handing responsibility over to a function. In there you could add sound effects etc.

This may sound a bit long winded, but if you changed [playership] to an variable, then you could use the function to jump a whole fleet, with all the same sound effects etc.

RobertSchafer

RobertSchafer avatar
Level badge Skillguey (7)
Posted 10 years ago.

I see what you mean!! thanks for putting me on the right track!!

I see what you mean with changing the [playership], but for the moment i think ile just keep it like i said above Smile

thanks again for all your help. good luck with rebirth btw :P :P

Miles

---- X3ap Battlestar Galactica mod ----
Latest update: 06/01/2014.
Team recruitment: Texture artist
Mod updater/downloader via our website:
www.x-battlestar.com
Roguey

Roguey avatar
Level badge Trueguey (22)
Posted 10 years ago.

no problemo Smile

1


You need to log-in to post here.