Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

LUA for custom layouts(still needs new trigger, but could be tested i think)

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> LUA for custom layouts(still needs new trigger, but could be tested i think) Page: [1]
Login
Message << Older Topic   Newer Topic >>
LUA for custom layouts(still needs new trigger, but cou... - 2/24/2017 5:25:24 PM   
inanetunaman

 

Posts: 27
Joined: 1/29/2017
Status: offline

well, i stubbornly still want to be able to edit aircraft layouts, and have been told that they won't give us a layout editor to change the database

but there is now a LUA script command to change weapon records, although i am not sure if they can add a weapon record that was not their at first, but the editor can do this so it should(i will have to look more)
so with this, i could "hijack" a layout and remove its weapons and add my new ones(in a simple example, it would replace aim-9m sidewinders with aim-9x sidewinders, but in the same number as before)
the case I currently want to do(although… it may not be relevant in RL) is to equip one of brazil’s A-4 shyhawks with a mid-range AAM , as they have carriers but no carrier based fighters
the reason this example is good is because their Skyhawk has 2 AAW layouts, one using the python 3, and one using the MAA-1, so it is possible to change one layout and still give it a close rage AAW layout

I wanted to add the super 530 missile or the sparrow III(it worked better with radars) to the plane, and it worked well manually in the editor, although I have to add another radar to illumine for the missile (it is possible to make it only illumine but not search), but then it is fine manually
The problem I have is how to remove a sensor that you added with a LUA script (to remove it when it lands, so you don’t end up with 500 radars after a battle) when the plane lands as it will give it a new ID

The other problem I have with testing this is I am unaware how to add a weapon to its “layout” mount, It can be done manually in the editor, and it works great and even affects max range, but when I generated a SBR delta templet it did not contain the change,


So, is there a LUA script that can apply SBR changes, how to you remove sensors that you added later on, and… can I add to the layout, or did I just stumble upon a way to do something we were not supposed to do(you can add it by clicking on one of its current weapons and opening the add weapons window, but can’t by clicking on the mount)

This won’t work practically unless there was an “Aircraft launched” and “aircraft landed” trigger
Any idea how I could format this, I have no experience with LUA scripts, but do know how to program(to a point)
Post #: 1
RE: LUA for custom layouts(still needs new trigger, but... - 2/24/2017 6:52:45 PM   
mikmykWS

 

Posts: 11524
Joined: 3/22/2005
Status: offline
Ok we're not offering or supporting loadout changes at this point. That being said you manually change them but you're going to have oddities because the profiles, fuel, drag etc are all calculated in the original loadout. So this is find to just trying things but you're going to get weird results.

As far as doing the changes in lua same shortcomings but there are likely more than a few ways to do this. You can evaluate add loadouts and in the case of landed etc. you might just be able to evaluate based on altitude. I'd give it a shot and if you get stuck jump on to the q and a site to see if some of the code wizards there can help.

https://commandlua.github.io/#ScenEdit_SetLoadout
https://commandlua.github.io/index.html#LoadoutInfo
https://commandlua.github.io/#WeaponLoaded

etc. etc.

Hope this helps! Let us know how it goes.

Mike

_____________________________


(in reply to inanetunaman)
Post #: 2
RE: LUA for custom layouts(still needs new trigger, but... - 2/24/2017 7:13:57 PM   
inanetunaman

 

Posts: 27
Joined: 1/29/2017
Status: offline
actually, if you add your new weapon INSIDE they layout(this can be done) it appears to factor them into you max range
i don't know if it will affect the launch range, but that is not the most inportant if you put a notice in the briefing, especially because this applies to an AAW patrol, so it would just end up shorting how long you can fly

i have a replay file that shows it works, the plane max range increases right after firing its new missile, but i don't know how to upload it

it already allows me to do this, but only for planes already in the air 1 time, i just want a way to redo these changes every time a plane launches

i understand you don't want to let us edit databases as it could cause errors, but this can be done(mostly) right now, and does not require editing databases(although it would be nice to have extra empty layouts)






----------------
for testing it would be time based, but i hope to suggest a trigger for when aircraft take off or land

< Message edited by inanetunaman -- 2/24/2017 7:35:38 PM >

(in reply to mikmykWS)
Post #: 3
RE: LUA for custom layouts(still needs new trigger, but... - 5/21/2017 1:44:42 AM   
Dan109

 

Posts: 175
Joined: 4/27/2017
Status: offline
I've been thinking of this very same issue. A few behaviors work in our favor:

a.After aircraft is taken off the map, its AirOps State goes from Final Approach to Completed Landing - this lasts for atleast 30s, while going from "runway" to "parking spot"
b.Magazines are updated with "extra equipment on plane" at the conclusion of the "completed landing" phase

Therefore this must be taken care of during the "completed landing phase" - carriers provide more complexity to this, with the elevators, going to the hanger

Issues with lack of LUA:

1. Altitude - can't check on altitude, because altitude of the units is ASL, not AGL - airbases above SL show parked aircraft having a non-zero altitude (actually, I think there is a way with World_GetElevation() )
2. Speed - speed is NEVER set to zero while landed, it has the last speed just before 0 AGL altitude - landing speed is kept while the aircraft is being refueled and loaded
3. unit.unitstate - this state remains at "RTB" or whatever RTB derivative after landing, throughout the entire refueling/rearming - it only changes again after it launches again
4. No way to view the AirOps state of a unit (taking off, airborne, final approach, completed landing, etc)

I agree, an aircraft take off trigger or aircraft landing trigger is the best Command LUA solution

But, I'm not sure if they will develop features mainly to let us hack and override their own game. Maybe...? lol

A solution I have been thinking of for the landing involves the following: (takeoff is trivial, just check unit.airbornetime < 30s)

periodic 29s trigger to check all air units
1.check if within a certain distance between unit and unit.home, using ToolRange()
2.check if AGL altitude is < 1 (AGL altitude = ASL altitude - World_GetElevation(unit.lat/long))

The reason you just can't check for 0 AGL, I would think because of Helo Cargo drops - the above solution thats that into account, in the exceptions of a Helo Cargo mission, a few miles from base (rare, I suppose)



(in reply to inanetunaman)
Post #: 4
RE: LUA for custom layouts(still needs new trigger, but... - 5/21/2017 2:07:45 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
1. There is a property on the unit - airbornetime; This is the time plane has been flying. If it has landed, then this should be zero
2. The aircraft normally takes on the altitude of the base when landed. So try checking the aircraft altitude against that of the base it is at.
3. There is another property - condition; which I think is the state of the aircraft (like readying). I seemed to have missed this in my documentation.

< Message edited by michaelm -- 5/21/2017 2:12:07 AM >


_____________________________

Michael

(in reply to Dan109)
Post #: 5
RE: LUA for custom layouts(still needs new trigger, but... - 5/21/2017 9:19:50 AM   
Dan109

 

Posts: 175
Joined: 4/27/2017
Status: offline
Excellent! I just tried the unit.condition structure. Thanks!!!!

< Message edited by Dan109 -- 5/21/2017 9:22:04 AM >

(in reply to michaelm75au)
Post #: 6
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> LUA for custom layouts(still needs new trigger, but could be tested i think) Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.703