locqust
Registered:1421078831 Posts: 70
Posted 1421436874
Reply with quote
#1
Hi all, Fairly new to the game, yet really enjoyed every mission my crew and I have done so far! Started messing around with mission scripting and have had a few ideas for events. Most of these sparked from the code snippets I've seen on the wiki. Something I want to do is similar to the away team code where the Artemis has to fly close to a ship in order to transport survivors off and has to remain close for a transporter lock. I want it to take, say, 40 seconds to transport the survivors off but if the Artemis has to move away from the ship I want to be able to pause the timer and restart from where it left off once back in range. Can anybody think of a way to do this? Thanks in advance!
Charlie
Registered:1374978813 Posts: 347
Posted 1421437294
· Edited
Reply with quote
#2
Not sure if this is the best way to do it but you could use 40 1 second variables or 20 2 second ones to cut it down a bit. I havent scripted in a while so not sure if this is the best way to do it without thinking a bit, seems like there might be a better answer but this would work.
ryleyra
Registered:1399599588 Posts: 3,214
Posted 1421439570
· Edited
Reply with quote
#3
Yeah, as far as I know there is no way to stop and restart a timer, so there is no way to start a timer with the amount of time that was left on a previous timer. In fact, you can't really stop a timer, all you can do is tell it not to take effect when it goes off. The previous suggestion is probably the best. Use a series of timers as "gates", and as you pass each, mark that you've passed it. Your granularity won't be the best, depending on how long you make the gate timers, but at least you can set a count and keep firing the timer to increment the count, instead of having to code a whole bunch of events.
Fish Evans
Registered:1381528881 Posts: 383
Posted 1421454582
· Edited
Reply with quote
#4
so some Psdo code here:Event 1 Start Conditions Variable Evac = 0 PlayerShip is less then 600 from EvacShip Actions Set Variable Evac = 1 Set Timer TEvac to 1 sec Send Message "Starting Evacuation"Event 2 Timer Conditions Variable Evac > 0 Variable Evac < 41 PlayerShip is less then 600 from EvacShip Timer TEvac Has finished Actions set Variable Evac = Evac + 1 set Variable EvacAbort = 0 Set Timer TEvac to 1 secEvent 3 Completion Condition Variable Evac = 41 Action Send Message "Evacuation completed!" Set Variable Evac = 42Event 4 Not Complete Conditions Variable Evac > 0 Variable Evac < 41 PlayerShip is More then 600 from EvacShip Timer TEvac Has finished Variable EvacAborted = 0 Actions Send Message "Transporter lock lost, out of range" set Variable EvacAborted = 1
Fish Evans
Registered:1381528881 Posts: 383
Posted 1421454638
· Edited
Reply with quote
#5
eepp Dobble Post! Sorry!
locqust
Registered:1421078831 Posts: 70
Posted 1421519189
Reply with quote
#6
Thanks guys I'll give that a go and see how it works.
I think I may have it activate/reactivate via console key press as well as distance to the ship in distress, just so the crew feel like they are in control of it and it isn't an automatic thing.
eurobusker
Registered:1423403454 Posts: 108
Posted 1432748711
Reply with quote
#7
has anyone tried this? I like the idea of..Actions set Variable Evac = Evac + 1 is this allowed? or must it be Actions set Variable "Evac" = Variable "Evac" + 1
Xavier Wise
Registered:1375817447 Posts: 1,362
Posted 1432756989
Reply with quote
#8
Your first example works fine. We use it quite a lot now in the TSN Sandbox. One example is tracking supplies on auxillary ships.
__________________ Fleet Captain Xavier Wise - TSN SabreLink to TSN RP Community Website Want to follow development of the TSN Sandbox? Head here:https://ko-fi.com/xavierwise
ryleyra
Registered:1399599588 Posts: 3,214
Posted 1432761204
Reply with quote
#9
Yeah, variable substitution works fine for any property that takes a numeric value. So something like: set variable XCoord = XCoord + 1 set property X = XCoord for object named "Artemis" would work just fine. You can also add to properties, but that was implemented prior to variable substitution. Unfortunately, variables that are names can't be substituted. So you can't assign an object name to a variable and then use that variable to access a property on that object, unfortunately.
Fish Evans
Registered:1381528881 Posts: 383
Posted 1432769520
Reply with quote
#10
You can use / * - + although irritatingly it dosent seem you can use more advanced functions, so tryting to make something orbit around a point, or simulating gravity becomes a nightmare.
Arrew
Registered:1393602597 Posts: 2,750
Posted 1432779482
· Edited
Reply with quote
#11
Yeah I use that kind of coding a lot. It's cool that you can use values and complex mathematical codes to calculate things. It's how some, or most if I'm honest, of the new enemies work in my GM Sandbox. Not just for tracking stats. With a little jiggery pokery it's what causes the Kamikaze kraliens to explode when they're in range!(P.S. Not name dropping as I didn't do it first and it is relevant too.) ;P
Arrew
Registered:1393602597 Posts: 2,750
Posted 1432781177
Reply with quote
#12
Oh, using as gate timers is really clever idea!
Being both mean and lazy I normally just make the timer start again.
I did use something like it twice for a gravitational effect, originally for a mission script called Tin Man I think.