ScenEdit_QueryDB()

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
SeaQueen
Posts: 1436
Joined: Sat Apr 14, 2007 4:20 am
Location: Washington D.C.

ScenEdit_QueryDB()

Post by SeaQueen »

Has anyone figured out how to make this one work yet? I'm unable to find any documentation, but it looks really useful both from an "avoiding magic numbers" perspective and from the perspective of portability between database upgrades in a scenario.
tiag
Posts: 131
Joined: Thu Jun 21, 2018 8:33 am

RE: ScenEdit_QueryDB()

Post by tiag »

Any update from your side on that, SeaQueen? I have been trying to use that but so far no joy.
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: ScenEdit_QueryDB()

Post by michaelm75au »

It isn't showing all the expected fields in either CMO or CMANO for some reason. In my test environment, it works as such.

-- list of object and values of wrapper
local a = ScenEdit_QueryDB('weapon',1398)
print(a.fields)
for k,v in pairs(a.fields) do
if string.find(k,'property_') ~= nil then
local t = string.find(v," , ") -- location of first ,
print("\r\n[object] = " .. string.sub(v,2,t-1) ) -- pull out property name
print( a[string.sub(v,2,t-1)] ) -- value
end
end

{ property_14 = '.sensors , LuaTable , False', property_6 = '.classname , String , False', property_15 = '.directors , LuaTable , False', property_13 = '.warheads , LuaTable , False', property_12 = '.targetLimits , LuaTable , False', property_4 = '.validTargetList , Object , False', property_3 = '.type , Int32 , False', property_10 = '.ranges , LuaTable , False', property_11 = '.launchLimits , LuaTable , False', property_2 = '.name , String , False', property_9 = '.guidance , Int32 , False', property_7 = '.subtype , String , False', property_8 = '.subtypeN , Int32 , False', property_1 = '.dbid , Int32 , False', property_5 = '.OODA , LuaTable , False' }

[object] = sensors
{ [1] = { maxrange = 10, name = 'Active Radar Seeker', type = 2001, role = 2211, dbid = 3763 } }

[object] = classname
AIM-54C Phoenix

[object] = directors
{ [1] = { maxrange = 180, name = 'AN/APG-71', type = 2001, role = 2111, dbid = 1557 }, [2] = { maxrange = 180, name = 'AN/AWG-9', type = 2001, role = 2111, dbid = 2003 } }

[object] = warheads
{ [1] = { name = 'AIM-54C (WDU-29/B) 61kg/135lb Continous Rod', dbid = 38, dp = 61, numof = 1, type = 2008 } }

[object] = targetLimits
{ speed = { max = 2300, min = 0 }, alt_agl = { max = 0, min = 9.10000038146973 }, alt_asl = { max = 24384, min = 0 } }

[object] = validTargetList
{ [1] = 'Aircraft', [2] = 'Missiles & Guided Bombs' }

[object] = type
6

[object] = ranges
{ surface = { max = 0, min = 0 }, air = { max = 120, min = 4 }, land = { max = 0, min = 0 }, subsurface = { max = 0, min = 0 } }

[object] = launchLimits
{ speed = { max = 0, min = 0 }, alt_agl = { max = 0, min = 60.9000015258789 }, alt_asl = { max = 19812, min = 0 } }

[object] = name
AIM-54C Phoenix

[object] = guidance
15

[object] = subtype
Guided Weapon

[object] = subtypeN
2001

[object] = dbid
1398

[object] = OODA
{ evasion = 0, targeting = 0, detection = 0 }
Michael
tiag
Posts: 131
Joined: Thu Jun 21, 2018 8:33 am

RE: ScenEdit_QueryDB()

Post by tiag »

Thank you, Michael. Just a heads-up for you....

The Documentation (http://commandlua.github.io/#ScenEdit_QueryDB) is not up-to-date.
The .fields not working 1115.8.1 in the output of QueryDB. It works though with outputs of other functions.
QueryDB only working with weapon, sensor and mount. It would great to have it working with other classes of CMO, like aircraft, ships, etc.

Thank you again for all energy and time invested to make it working.

Tiago
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: ScenEdit_QueryDB()

Post by michaelm75au »

I have the other database items on the list, but I haven't built the 'wrappers' to show the data. Yet.
It looks like only the first 'device wrapper query' works currently in the released versions.

local a = ScenEdit_GetLoadout( {name='fight #1', guid='30184f60-768b-4e2e-847d-19c97289357e'} )
print(a.fields)
for k,v in pairs(a.fields) do
if string.find(k,'property_') ~= nil then
local t = string.find(v," , ") -- location of first ,
print("\r\n[object] = " .. string.sub(v,2,t-1) ) -- pull out property name
print( a[string.sub(v,2,t-1)] ) -- value
end
end
Michael
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: ScenEdit_QueryDB()

Post by michaelm75au »

Can you check and see if this working under 1121.5?
Michael
tiag
Posts: 131
Joined: Thu Jun 21, 2018 8:33 am

RE: ScenEdit_QueryDB()

Post by tiag »

Will do tonight.

I have the habit of only downloading updates via CMO itself. I understand that those updates available on our Forum are WIP/Beta like?!
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: ScenEdit_QueryDB()

Post by michaelm75au »

I'm confident it should be working now under latest beta build, but I thought it was working before too!![:)]
Michael
tiag
Posts: 131
Joined: Thu Jun 21, 2018 8:33 am

RE: ScenEdit_QueryDB()

Post by tiag »

Sorry for the delayed reply. Week was busy. So, the .fields for the GetLoadout is working in 1121.1, but not for the QueryDB function.

For the code
local a = ScenEdit_QueryDB('weapon',1398)
print(a)
Output:
weapon {
name = 'AIM-54C Phoenix',
dbid = '1398',
type = '6',
subtype = 'Guided Weapon',
validTargetList = 'table',
}
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: ScenEdit_QueryDB()

Post by michaelm75au »

It should be working on the latest build 1121.6
Michael
Post Reply

Return to “Lua Legion”