Need help--not sure if I'm using the right command, right format, etc.

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
Mgellis
Posts: 2473
Joined: Sat Aug 18, 2007 2:45 pm
Contact:

Need help--not sure if I'm using the right command, right format, etc.

Post 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
Capture.JPG (34.84 KiB) Viewed 997 times
User avatar
blu3s
Posts: 1403
Joined: Fri Jul 08, 2022 9:45 am

Re: Need help--not sure if I'm using the right command, right format, etc.

Post 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'
DavidRN
Posts: 91
Joined: Tue Jan 17, 2023 8:41 pm

Re: Need help--not sure if I'm using the right command, right format, etc.

Post 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
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

Re: Need help--not sure if I'm using the right command, right format, etc.

Post 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.
User avatar
Mgellis
Posts: 2473
Joined: Sat Aug 18, 2007 2:45 pm
Contact:

Re: Need help--not sure if I'm using the right command, right format, etc.

Post by Mgellis »

Thank you. I'll try these out and see which one works.
DavidRN
Posts: 91
Joined: Tue Jan 17, 2023 8:41 pm

Re: Need help--not sure if I'm using the right command, right format, etc.

Post 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
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

Re: Need help--not sure if I'm using the right command, right format, etc.

Post 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.
Post Reply

Return to “Lua Legion”