QueryDB - what am I doing wrong?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

QueryDB - what am I doing wrong?

Post by KnightHawk75 »

Code: Select all

local b = ScenEdit_QueryDB('submarine',554)
 print(b); -- returns nil
 b = ScenEdit_QueryDB('ship',3100)
 print(b); -- returns nil
 b = ScenEdit_QueryDB('aircraft',333)
 print(b); -- returns nil
 b = ScenEdit_QueryDB('facility',2416)
 print(b); -- return nil
 b = ScenEdit_QueryDB('satellite',143)
 print(b); -- returns nil
 b = ScenEdit_QueryDB('sensor',651)
 print(b); -- works but returns nothing useful
 b = ScenEdit_QueryDB('mount',2302)
 print(b); -- works bus returns nothing useful
 b = ScenEdit_QueryDB('weapon',2378)
 print(b); -- works validTargetlist is useful but
 --was expecting things like range,speed,damage,warhead dp
 --b = ScenEdit_QueryDB('warhead',2378) -- doesn't exist 
 print(b);

Basically I was looking for\expecting to be able to look up the cruise speed of unit, and a given weapon speed and range, and then use that to help calculate mission and weapons release ref points... without having to re-create the db myself in tables for every unit\weapon type in a scenario. Is QueryDB not meant to return this sort of data?

Additionally anyone know how to query the current state of EMCON, I can clearly set it via SetEMON() and get\set the obeyflag on off, but seems I can't find how to query the state of the setting prior to making changes, like if inherit is set and sonar are on and obey is on, maybe I don't want to do a particular thing etc. I checked GetDoctrine but it's not included there.
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: QueryDB - what am I doing wrong?

Post by michaelm75au »

Only weapon, mount and sensor have been converted.
>> -- 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_9 = '.guidance , Int32 , False', property_2 = '.name , String , False', property_6 = '.classname , String , False', property_3 = '.type , Int32 , False', property_4 = '.validTargetList , Object , False', property_13 = '.warheads , LuaTable , False', property_14 = '.sensors , LuaTable , False', property_15 = '.directors , LuaTable , False', property_5 = '.OODA , LuaTable , False', property_7 = '.subtype , String , False', property_12 = '.targetLimits , LuaTable , False', property_1 = '.dbid , Int32 , False', property_8 = '.subtypeN , Int32 , False', property_11 = '.launchLimits , LuaTable , False', property_10 = '.ranges , LuaTable , False' }

[object] = guidance
15

[object] = name
AIM-54C Phoenix

[object] = classname
AIM-54C Phoenix

[object] = type
6

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

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

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

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

[object] = OODA
{ detection = 0, evasion = 0, targeting = 0 }

[object] = subtype
Guided Weapon

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

[object] = dbid
1398

[object] = subtypeN
2001

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

[object] = ranges
{ land = { min = 0, max = 0 }, surface = { min = 0, max = 0 }, subsurface = { min = 0, max = 0 }, air = { min = 4, max = 120 } }
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: QueryDB - what am I doing wrong?

Post by KnightHawk75 »

Ahhh it's all in fields, makes sense now why wasn't showing with simple print lol.
Thanks michael!
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: QueryDB - what am I doing wrong?

Post by michaelm75au »

I've tended to add fields to wrappers for the simple reason sometimes I even forget what has been added.[:D]
Michael
boogabooga
Posts: 1021
Joined: Wed Jul 18, 2018 12:05 am

Re: QueryDB - what am I doing wrong?

Post by boogabooga »

I'm bumping this very useful thread for easy reference for what I am working on- and to lend moral support to the ScenEdit_QueryDB developent. :)

Thank you to the posters.
The boogabooga doctrine for CMO: Any intentional human intervention needs to be able to completely and reliably over-ride anything that the AI is doing at any time.
Post Reply

Return to “Lua Legion”