Page 1 of 1
ID Definitions
Posted: Thu Jul 07, 2022 2:57 am
by kevinkins
Could someone define these items below and where to find them? They are key to a lot of lua script. I have used them in the past, but the results have been inconsistent. Many lua functions have helpful example code, but others do not have examples. Thanks.
loadoutid
dbid
GUID
Re: ID Definitions
Posted: Thu Jul 07, 2022 9:08 am
by michaelm75au
GUID = this is the unique identifier for unit objects. Every unit/contact/weapon in Command will have one.
You can generally get the GUID by pressing cntl_C while the cursor is on the unit.
dbid = this is the database identifier, the reference into the associated database. You can see this in the database viewer. It is the top line of the information page (#2381 - 3MS-1 Bison....)
loadoutid = this the database identifier for the a/c loadouts. You can see this in the a/c database viewer under loadouts (far right column DB id)
These fields are available in the unit wrappers from SE_GetUnit(...) if required in a script.
local myUnit = ScenEdit_GetUnit({ side = 'United States' , name = 'CG 56 San Jacinto' })
myUnit.guid
myUnit.dbid
myUnit.loadoutdbid
Re: ID Definitions
Posted: Thu Jul 07, 2022 12:35 pm
by kevinkins
Thank you.
GIUD seems to be unique to a running scenario and is separate from database entries which are constants. Is this correct?
I thought I saw loadouts associated with ships as well as a/c. Maybe I just read the forum thread wrong.
Specifically, I am interested in getting to know ScenEdit_SetLoadout (loadoutinfo)
There is no example script in the lua manual for Command. Can you send a few examples of using this function? I want to see if the loadout of an a/c can be set to ferry db = 10111 to simulate dropping weapons while in the air during a battle and if so, what performance change would the player see. There is a discussion of adding a button to do this in the outer forum - like dropping fuel. Maybe a special action might do the trick if the function works this way.
Kevin
Re: ID Definitions
Posted: Thu Jul 07, 2022 1:40 pm
by michaelm75au
Code: Select all
# set a loadout
#on unit guid 'myid'
#ignore magazine check for available weapons
1. Make changes to the unit current loadout - remove 2 of weapon dbid 1814
ScenEdit_SetLoadout({unitname=myid, loadoutid=0, ignoremagazines=true, wpn_dbid=1814, number=2, remove=true})
2. Change the loadout on the unit to ...
ScenEdit_SetLoadout({unitname=myid, loadoutid=21466, ignoremagazines=true})
3. Change the loadout and make instantaneous available (no ready time)
ScenEdit_SetLoadout({unitname=myid, loadoutid=26234, timetoready_minutes=0})
Some quick examples I found in my logs
Re: ID Definitions
Posted: Thu Jul 07, 2022 1:45 pm
by michaelm75au
Note:
From memory, changing loadout id can only be done when parked. Changing the number of weapons onboard can be performed when flying.
In the case of dropping weapons, the a/c is flying so you would need to zero (remove) the weapons of the loadout.
Re: ID Definitions
Posted: Thu Jul 07, 2022 5:05 pm
by kevinkins
Remain a bit unsure where myid is coming from so I retrieved the guid from the getunit function and inserted it as the unitname but this does not set the AIMs (wpn_dbid=27222) to zero:
ScenEdit_SetLoadout({unitname='7HBG6Z-0HMIUT19RQB13', loadoutid=0, ignoremagazines=true, wpn_dbid=27222, number=0, remove=true})
The call does not throw an error but something is off.
Thanks ... Kevin
Re: ID Definitions
Posted: Fri Jul 08, 2022 3:15 am
by michaelm75au
The number is how many to remove. It is more used to probably drop individual weapons
There is another way to jettison weapons - ScenEdit_SetUnit()
ScenEdit_SetUnit({unitname='7HBG6Z-0HMIUT19RQB13', jettison = xxxxx})
Where xxxx is
"HEAVYONLY"
"WEAPONSONLY"
"ALLEXTERNAL"
"ALL"
Don't have an example at the moment.
"HEAVYONLY" = drop tanks, Air2Ground weapons
"WEAPONSONLY" = AG and Air2Air weapons
"ALLEXTERNAL" = drop tanks, all AG/AA, pods
"ALL" = all external and internal loads
"STORE_dbid = specific weapon DBID"
http://commandlua.github.io/assets/Func ... tUnit.html
Re: ID Definitions
Posted: Fri Jul 08, 2022 2:17 pm
by kevinkins
Ran the SetUnit / jettison option using both guid = and unitname = and those constants.
No errors, but nothing is jettisoned. Ran the script from the console with the game clock counting down. The AIMs will fire off at a hostile a/c after the script is run and this is reflected in the friendly unit's weapon record while CMO is running i.e. you can see the available AIMs count down as they fire off. Attached is the file I'm working off.
Kevin
Re: ID Definitions
Posted: Fri Jul 08, 2022 9:58 pm
by michaelm75au
Ran this on loading the scenario file.
local a = ScenEdit_GetLoadout({unitname='7HBG6Z-0HMJ0AM00VRFT'})
print(a.weapons)
local b = ScenEdit_SetUnit({unitname='7HBG6Z-0HMJ0AM00VRFT', jettison='all'})
print(a.weapons)
Output:
{ [1] = { wpn_dbid = 51, wpn_type = 2001, wpn_name = 'AIM-120D AMRAAM P3I.4', wpn_guid = '7HBG6Z-0HMJ0AM00VRGN', wpn_current = 4, wpn_maxcap = 4, wpn_default = 4 } }
{ [1] = { wpn_dbid = 51, wpn_type = 2001, wpn_name = 'AIM-120D AMRAAM P3I.4', wpn_guid = '7HBG6Z-0HMJ0AM00VRGN', wpn_current = 0, wpn_maxcap = 4, wpn_default = 4 } }
The number of AIMs has gone from 4 to 0.
And there should be a message in the log too.
Re: ID Definitions
Posted: Sat Jul 09, 2022 5:30 am
by kevinkins
OK, will give those a try. But will the functions work only on scenario load and therefore are not intended to be run after that i.e during aerial combat while the scenario is running and based on player input via a special action? Thanks.
Kevin
Edit: please send back the file where this function is reducing the AIMs to zero. Need to take a very specific look at the implementation. Everything I try has the AIMs remaining at 4, including running the lua script above with the scenario load event. No message created either. Again, no errors, but this is what I get via the console after the scenario is loaded.
local a = ScenEdit_GetLoadout({unitname='7HBG6Z-0HMJ0AM00VRFT'})
print(a.weapons)
local b = ScenEdit_SetUnit({unitname='7HBG6Z-0HMJ0AM00VRFT', jettison='all'})
print(a.weapons)
{ [1] = { wpn_dbid = 51, wpn_type = 2001, wpn_default = 4, wpn_name = 'AIM-120D AMRAAM P3I.4', wpn_maxcap = 4, wpn_current = 4, wpn_guid = '7HBG6Z-0HMJ0AM00VRGN' } }
{ [1] = { wpn_dbid = 51, wpn_type = 2001, wpn_default = 4, wpn_name = 'AIM-120D AMRAAM P3I.4', wpn_maxcap = 4, wpn_current = 4, wpn_guid = '7HBG6Z-0HMJ0AM00VRGN' } }
Note: wpn_current = 4 unlike what you are getting and there is nothing in the log. It's as if the A/C is read only.
Re: ID Definitions
Posted: Sat Jul 09, 2022 6:29 am
by michaelm75au
Attached save with SA.
Execute SA and it drops the weapons for me.
I am using latest beta.
Re: ID Definitions
Posted: Sat Jul 09, 2022 8:26 am
by kevinkins
What is SA? And I don't see where you placed the script (no events nor in the script console). Puzzled.
Kevin
Re: ID Definitions
Posted: Sat Jul 09, 2022 9:25 am
by michaelm75au
No Special Action in the save??
Re: ID Definitions
Posted: Sat Jul 09, 2022 9:58 am
by kevinkins
Sorry. SA = Special Action. See the script now. Does not work on my end. AIMs remain at 4 and there is nothing in the message log after the SA is executed. Will send this to a couple of friends. Something is set up differently between our systems. Are you testing with the Pro version perhaps? The function is not new so I doubt it's related to the beta version - but who knows and will give that a try. Thanks for the help.
Kevin
Re: ID Definitions
Posted: Sat Jul 09, 2022 10:18 am
by michaelm75au
I was using 1263.1 to test it. But that function should be valid in earlier releases.