Page 1 of 1
Need help--not sure if I'm using the right command, right format, etc.
Posted: Mon Feb 13, 2023 1:06 am
by Mgellis
All right, I've exhausted what little lua-fu I have. I need your help.
I am trying to create an event that tells a certain ship, when it is damaged, to come to a full stop. Basically, I'm handling a fishing dispute by having Blue do a small amount of damage to a ship that is running away (as opposed to sinking them, for which you lose points), which causes the fishing boat to give up and surrender and not run away anymore because the people on board are like, "Crap! They're serious! Cut the engines!"
I cannot figure out which lua command is used to give a ship orders (like "throttle should now be set to stop"). I have a attached a screenshot of the one I was using, but it is not working. I have looked at various lua documentation and I must be a dumb ass because I cannot figure out what I am doing wrong.
What am I doing wrong?
Thank you in advance.

- Capture.JPG (34.84 KiB) Viewed 1001 times
Re: Need help--not sure if I'm using the right command, right format, etc.
Posted: Mon Feb 13, 2023 7:45 am
by blu3s
Mgellis wrote: Mon Feb 13, 2023 1:06 am
All right, I've exhausted what little lua-fu I have. I need your help.
I am trying to create an event that tells a certain ship, when it is damaged, to come to a full stop. Basically, I'm handling a fishing dispute by having Blue do a small amount of damage to a ship that is running away (as opposed to sinking them, for which you lose points), which causes the fishing boat to give up and surrender and not run away anymore because the people on board are like, "Crap! They're serious! Cut the engines!"
I cannot figure out which lua command is used to give a ship orders (like "throttle should now be set to stop"). I have a attached a screenshot of the one I was using, but it is not working. I have looked at various lua documentation and I must be a dumb ass because I cannot figure out what I am doing wrong.
What am I doing wrong?
Thank you in advance.
Capture.JPG
You are right with the method SetUnit but I think the keyword for full stop is 'Stop' and not 'FullStop'
Re: Need help--not sure if I'm using the right command, right format, etc.
Posted: Mon Feb 13, 2023 9:25 am
by DavidRN
Hi There
speed = number Set unit speed (mutally exclusive to 'throttle')
Think you need to set it as speed not throttle and it needs to be a number e.g 0 (stop)
ScenEdit_SetUnit({side='Venezuelan Fishing Boats', unitname='Spring Aurora', speed = '0'})
ScenEdit_SetUnit ( table )
http://commandlua.github.io/assets/Func ... tUnit.html
DB
Re: Need help--not sure if I'm using the right command, right format, etc.
Posted: Mon Feb 13, 2023 1:56 pm
by KnightHawk75
Mgellis wrote: Mon Feb 13, 2023 1:06 am
All right, I've exhausted what little lua-fu I have. I need your help.
I am trying to create an event that tells a certain ship, when it is damaged, to come to a full stop. Basically, I'm handling a fishing dispute by having Blue do a small amount of damage to a ship that is running away (as opposed to sinking them, for which you lose points), which causes the fishing boat to give up and surrender and not run away anymore because the people on board are like, "Crap! They're serious! Cut the engines!"
I cannot figure out which lua command is used to give a ship orders (like "throttle should now be set to stop"). I have a attached a screenshot of the one I was using, but it is not working. I have looked at various lua documentation and I must be a dumb ass because I cannot figure out what I am doing wrong.
What am I doing wrong?
Thank you in advance.
Capture.JPG
You are correct this doesn't behave as expected sometimes due to mission or even singles if 'manual' flag is not present and your changes are overridden 1 second after it's applied with some default. Following works though.
No matter what the docs say or don't say use:
ScenEdit_SetUnit({guid='4FH7PU-0HMODOH4HQQ6B',throttle="stop",manualSpeed=0}) --to stop
ScenEdit_SetUnit({guid='4FH7PU-0HMODOH4HQQ6B',throttle="full",manualSpeed="off"}) -- to start back up etc.
Also since you're in a damage event and the damaged boat is who you want to stop you could also just use UnitX();
ScenEdit_UnitX().manualSpeed = 0;
ScenEdit_UnitX().throttle = "stop";
-- ScenEdit_UnitX().speed = 0; --add only if you wanted it to stop on a dime vs bleed off.
Re: Need help--not sure if I'm using the right command, right format, etc.
Posted: Tue Feb 14, 2023 1:43 am
by Mgellis
Thank you. I'll try these out and see which one works.
Re: Need help--not sure if I'm using the right command, right format, etc.
Posted: Tue Feb 14, 2023 2:29 am
by DavidRN
Hi
If you wish to set a time frame as in the example 30 minutes with RTB for the unit to move using a UnitIsDetected trigger would you use the following (I tried it and it didnt work, the unit slowed down to 3 knots then upped it and continued on) .
Code: Select all
ScenEdit_SetUnit({guid='DSWMNJ-0HMOC0I06U70M',throttle='stop',manualSpeed='0',timetoready_minutes = '30', rtb = 'True', throttle='full',manualSpeed='off'})
My scenario is different to the origianl posters as I want the detected unit to stop (no weapons fired, no damage) and then move on.
UnitisDetected trigger seems to work for the unit to stop but doesn't appear to work for it to move on?
Assistance would be apprieciated.
DB
Re: Need help--not sure if I'm using the right command, right format, etc.
Posted: Tue Feb 14, 2023 8:11 pm
by KnightHawk75
DavidRN wrote: Tue Feb 14, 2023 2:29 am
Hi
If you wish to set a time frame as in the example 30 minutes with RTB for the unit to move using a UnitIsDetected trigger would you use the following (I tried it and it didnt work, the unit slowed down to 3 knots then upped it and continued on) .
Code: Select all
ScenEdit_SetUnit({guid='DSWMNJ-0HMOC0I06U70M',throttle='stop',manualSpeed='0',timetoready_minutes = '30', rtb = 'True', throttle='full',manualSpeed='off'})
My scenario is different to the origianl posters as I want the detected unit to stop (no weapons fired, no damage) and then move on.
UnitisDetected trigger seems to work for the unit to stop but doesn't appear to work for it to move on?
Assistance would be apprieciated.
DB
DB,
timetoready is only applied when a unit is inside a facility, ie is in it's base as far as I know, it's used for setting the countdown timer there, not once deployed\launched, it should I think have no effect on a unit outside it's base.
I'm confused what you want specifically to happen, and to whom\what after a unit detection event (this also might be better as a separate thread). Do you want the detected unit,detecting unit, or some other unit on the detecting or detector side.. to come to a stop? Then do you want whatever the aforementioned unit it is to 30 minutes later rtb at full speed? If so you will need more than just the detection event. The detection event would need to itself then dynamically generate a second event,and associate time trigger, and associated Lua script to do the rtb, and speed settings (in that order) at the 30 minute from first event mark). All this can be done but I'm unclear of your specifics.