Query Unit OutofComms

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
TitaniumTrout
Posts: 472
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

Query Unit OutofComms

Post by TitaniumTrout »

I can set a unit out of comms using :

Code: Select all

ScenEdit_SetUnit({unitname="USS Barry", OutOfComms="True"})

This works and the unit is out of comms.

Is there a way to use Lua to query if a unit is outofcomms?

I've tried

Code: Select all

 local unit = ScenEdit_GetUnit({side="OPFOR", unitname="USS Barry"})
 print(unit.outofcomms)
 

This returns a bunch of errors including "unable to load one or more of the requested types.".

Whicker
Posts: 664
Joined: Tue Jun 19, 2018 9:54 pm

RE: Query Unit OutofComms

Post by Whicker »

hmmm. I figured it would be in the unit wrapper some where but I don't see it.

local a = ScenEdit_GetUnit({side="OPFOR", unitname="USS Barry"})
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) ) -- property name
print( a[string.sub(v,2,t-1)] ) -- value of property
end
end

that will return all kinds of stuff, but I don't see anything about comms. Sometimes things are in a table and not directly accessible like you tried to do, but in this case it just looks like it doesn't exist.
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Query Unit OutofComms

Post by michaelm75au »

Looks like I never added anything to show the state of Comms Network
Michael
User avatar
TitaniumTrout
Posts: 472
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

RE: Query Unit OutofComms

Post by TitaniumTrout »

Cool, thanks for the info guys. I'll bust my through an alternate method.
Post Reply

Return to “Lua Legion”