Page 1 of 1

Lua Help

Posted: Sat Jan 07, 2017 1:41 am
by DWReese
Hi Gang,

I need just a little assistance with Lua. I have read every help file, watched every video, read every article, but I am still having a difficult time finding a way to make something happen. If anyone knows how to do this, can they please share what should be displayed in the Lua box.

I have two task forces heading toward each other. each has fought off numerous attacks from the air. Each has launched all of their SSM at the opposition. The existing mission is not designed to terminate the mission unless there is damage/destruction to some of the ships of the task force. Thus far, there is nothing.

What I would like to do is to instruct the task force to turn around after it has exhausted most (or all) of its SSMs or SAMs. I don't need my exact situation figured out, if you happen to know of another scenario where this had already been done, I can just view that one and figure it out. The Mission Editor works fine if I wanted to make the trigger damaged/destroyed ships, but there is nothing there to cover exhausting your weapons, so I need the Lua.

Any ideas?

If you like, you can contact me at dwreese@bellsouth.net if you would like to communicate directly without involving bandwidth.

Thank you in advance.

Doug

RE: Lua Help

Posted: Sat Jan 07, 2017 3:28 am
by Rory Noonan
The withdraw settings for offensive and defensive weapons don't work?

RE: Lua Help

Posted: Sat Jan 07, 2017 9:07 am
by ColonelMolerat
Sorry I don't know enough to help with your specific situation, but in case you don't know, the LUA API can be found here:

http://commandlua.github.io/

That has all of the Command-related LUA you can use.
There is also a beta list that includes LUA that isn't used yet, but hopefully will be in the game one day:

https://commandlua.github.io/beta/index.html

RE: Lua Help

Posted: Sat Jan 07, 2017 9:09 am
by DWReese
I'm not going to say that withdraw doesn't work. I'm just going to say that it didn't work for me. Of course, the categories are a little vague. What is considered to be a primary weapon? If dealing with a task Force, do you add all of the SAMs or SSMs collectively, or does it just pick the best SAM or the best SSM? Does it even work with a Task Force collectively? Or, do I have to designate each ship individually to make it work?

I spent all day yesterday testing this. I set the parameters to withdraw after the most minimal of damage, but it did not happen. Perhaps you have to have a designated base to withdraw to? I don't know.

Mike did address this topic, and said that a forced withdraw could be best accomplished through Lua, so that is why I am asking about Lua. I just don't know how to go about setting it up. If there was an example of someone else doing this, then I could just more-or-less copy that format.

Thanks.

Doug


RE: Lua Help

Posted: Sat Jan 07, 2017 9:24 am
by DWReese
Thank you,

Yes, I've been looking through them, as well. Unfortunately, I don't see (or recognize) anything that appears to make it withdraw when certain weapons are low.

Thanks anyway.

Doug

RE: Lua Help

Posted: Sat Jan 07, 2017 11:26 am
by kevinkins
Can someone point to a discussion on how the withdraw and redeploy operations work in detail for ships? Forum searching is still down. Searching really needs to be fixed.

Kevin

RE: Lua Help

Posted: Sat Jan 07, 2017 12:36 pm
by DeSade
1. I'm pretty sure you need to assign home base to ships in group for withdraw doctrine to work.

2. This doctrine will work for specific ships afaik, not for whole group - so if particular ship in group reaches predefined in withdraw doctrine low level of ordnance, then it will detach from the group and try to RTB. Unfortunately the doctrine setting "weapon state RTB" works only for air ops. At least I got such result when trying.

3. I don't think you could overcome it with LUA - I tried to test RTB flag which is part of unit descriptor, hoping that detecting any ship with RTB status will enable me to RTB whole group, but it looks like RTB flag can only be set (in set unit), not get.

RE: Lua Help

Posted: Sat Jan 07, 2017 1:06 pm
by kevinkins
I was thinking if you could detect when a certain weapon magazine(s) were empty (ready time = 0?), you could assign the ship to a mission that takes them (or a group) out of harm's way.

Kevin

RE: Lua Help

Posted: Sat Jan 07, 2017 1:11 pm
by mikmykWS
ORIGINAL: DeSade

1. I'm pretty sure you need to assign home base to ships in group for withdraw doctrine to work.

2. This doctrine will work for specific ships afaik, not for whole group - so if particular ship in group reaches predefined in withdraw doctrine low level of ordnance, then it will detach from the group and try to RTB. Unfortunately the doctrine setting "weapon state RTB" works only for air ops. At least I got such result when trying.

3. I don't think you could overcome it with LUA - I tried to test RTB flag which is part of unit descriptor, hoping that detecting any ship with RTB status will enable me to RTB whole group, but it looks like RTB flag can only be set (in set unit), not get.

RTB should be fixed at next release. It now works. You could use lua to assign things to different missions based on any number of conditions.

Thanks!

Mike

RE: Lua Help

Posted: Sat Jan 07, 2017 2:15 pm
by kevinkins
Hi Mike ...

In the withdraw/redeploy settings: are the primary weapons defined in the DB? Or is that determined by trial and error?
Can lua functions detect when a specific weapon is used up? Nothing in the documentation jumps out at me/us. Command keeps track of weapon expenditures so in theory the data resides somewhere.

Thanks

Kevin

RE: Lua Help

Posted: Sat Jan 07, 2017 2:28 pm
by Dimitris
http://www.warfaresims.com/?page_id=2711
To support pier operations, new ‘Withdraw’ and ‘Redeploy’ doctrine settings have been added to the AI behavior of ships/subs. These control the criteria/thresholds that the ship/sub AI will use in order to RTB (if it is underway) and re-deploy (if it is docked). The thresholds cover damage, fuel, primary attack & defence weapons. Each threshold type has several appropriate values.

[NOTE #1: The definition of primary attack/defence weapon points to the longest-ranged ASuW weapon (attack) and AAW/ASW (defence) weapon, and uses the default DB-fed values for reference. So for example if an Aegis cruiser is stocked with SM-2s on its DB-pristine version but the scen author opts to clean them out and re-stock with TLAMs and a few ESSMs, the cruiser is considered as "primary defence weapon exhausted" even though it still has the ESSMs].

[NOTE #2: The rules for picking the primary attack/defence weapon are slightly different for submarines. Hunter-killer subs (both nuclear and DE) consider torpedoes their primary weapon for both attack and defence even if they carry other longer-ranged weapons (missiles etc.). Cruise- and ballistic-missile subs however, consider their missiles their primary attack weapon.]



RE: Lua Help

Posted: Sat Jan 07, 2017 2:34 pm
by mikmykWS
Hi Kevin

Next update might be a little more helpful here as you're getting some new functions that deal with mags etc.In the meantime you know what's in the mag and you could probably count destroyed weapons or something.

Long term... If one of you could put together a lua request around this it would be great. If you could generate a list of potential things that would be amazing.

Thanks!

Mike


RE: Lua Help

Posted: Sat Jan 07, 2017 9:39 pm
by kevinkins
Thanks guys. Will proceed with the short and long term recos.

RE: Lua Help

Posted: Mon Mar 06, 2017 12:56 pm
by VIF2NE
There is a way to remove the unit from the group if you use LUA?