ScenEdit_SelectedUnits ()

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
User avatar
KLAB
Posts: 500
Joined: Tue Feb 27, 2007 5:24 pm

ScenEdit_SelectedUnits ()

Post by KLAB »

ScenEdit_SelectedUnits ()

Does this function work?
If so how?
I want to create a special action that places a landing spot facility at the location of a hovering helicopter, but any helicopter selected not a predetermined one.
The ScenEdit_SelectedUnits () function isn't returning a value for the selected unit or am I missing something?

Any help or pointers appreciated.
K
wirthlin
Posts: 22
Joined: Sat Dec 26, 2020 11:22 pm

Re: ScenEdit_SelectedUnits ()

Post by wirthlin »

KLAB wrote: Wed Apr 06, 2022 9:19 pm ScenEdit_SelectedUnits ()

Does this function work?
If so how?
I want to create a special action that places a landing spot facility at the location of a hovering helicopter, but any helicopter selected not a predetermined one.
The ScenEdit_SelectedUnits () function isn't returning a value for the selected unit or am I missing something?

Any help or pointers appreciated.
K
Hi K,

It does work. Take a look at the snippet below. I created three aircraft and selected them all. But only print out information on the 2nd one selected.

local t=ScenEdit_SelectedUnits()
print(t)

-- Get information on the 2nd one selected.
local myunit=ScenEdit_GetUnit(t.units[2])
print(myunit)


{ units = { [1] = { guid = 'HYXUA2-0HMGO3JLP291Q', name = '3MN-1 Bison B [Bomber]' }, [2] = { guid = 'HYXUA2-0HMGO3JLP292L', name = 'B-52H Stratofortress' }, [3] = { guid = 'HYXUA2-0HMGO3JLP293S', name = 'C-17A Globemaster III SOLL' } } }


unit {
type = 'Aircraft',
subtype = '3101',
name = 'B-52H Stratofortress',
side = 'BLUFOR',
guid = 'HYXUA2-0HMGO3JLP292L',
class = 'B-52H Stratofortress',
proficiency = 'Regular',
latitude = '37.0040975290158',
longitude = '-102.969220619948',
altitude = '10972.8',
heading = '0',
speed = '280',
throttle = 'Loiter',
autodetectable = 'False',
mounts = '2',
magazines = '2',
unitstate = 'Unassigned',
fuelstate = 'None',
weaponstate = 'None',
}

I hope this helps.

R
User avatar
KLAB
Posts: 500
Joined: Tue Feb 27, 2007 5:24 pm

Re: ScenEdit_SelectedUnits ()

Post by KLAB »

wirthlin wrote: Wed Apr 06, 2022 10:40 pm
KLAB wrote: Wed Apr 06, 2022 9:19 pm ScenEdit_SelectedUnits ()

Does this function work?
If so how?
I want to create a special action that places a landing spot facility at the location of a hovering helicopter, but any helicopter selected not a predetermined one.
The ScenEdit_SelectedUnits () function isn't returning a value for the selected unit or am I missing something?

Any help or pointers appreciated.
K
Hi K,

It does work. Take a look at the snippet below. I created three aircraft and selected them all. But only print out information on the 2nd one selected.

local t=ScenEdit_SelectedUnits()
print(t)

-- Get information on the 2nd one selected.
local myunit=ScenEdit_GetUnit(t.units[2])
print(myunit)


{ units = { [1] = { guid = 'HYXUA2-0HMGO3JLP291Q', name = '3MN-1 Bison B [Bomber]' }, [2] = { guid = 'HYXUA2-0HMGO3JLP292L', name = 'B-52H Stratofortress' }, [3] = { guid = 'HYXUA2-0HMGO3JLP293S', name = 'C-17A Globemaster III SOLL' } } }


unit {
type = 'Aircraft',
subtype = '3101',
name = 'B-52H Stratofortress',
side = 'BLUFOR',
guid = 'HYXUA2-0HMGO3JLP292L',
class = 'B-52H Stratofortress',
proficiency = 'Regular',
latitude = '37.0040975290158',
longitude = '-102.969220619948',
altitude = '10972.8',
heading = '0',
speed = '280',
throttle = 'Loiter',
autodetectable = 'False',
mounts = '2',
magazines = '2',
unitstate = 'Unassigned',
fuelstate = 'None',
weaponstate = 'None',
}

I hope this helps.

R
Ah ha, that's brilliant many thanks,

Think this bit was eluding me;

Get information on the 2nd one selected.
local myunit=ScenEdit_GetUnit(t.units[2])
print(myunit)

Thanks again.
K
User avatar
KLAB
Posts: 500
Joined: Tue Feb 27, 2007 5:24 pm

Re: ScenEdit_SelectedUnits ()

Post by KLAB »

KLAB wrote: Thu Apr 07, 2022 10:04 am
wirthlin wrote: Wed Apr 06, 2022 10:40 pm
KLAB wrote: Wed Apr 06, 2022 9:19 pm ScenEdit_SelectedUnits ()

Does this function work?
If so how?
I want to create a special action that places a landing spot facility at the location of a hovering helicopter, but any helicopter selected not a predetermined one.
The ScenEdit_SelectedUnits () function isn't returning a value for the selected unit or am I missing something?

Any help or pointers appreciated.
K
Hi K,

It does work. Take a look at the snippet below. I created three aircraft and selected them all. But only print out information on the 2nd one selected.

local t=ScenEdit_SelectedUnits()
print(t)

-- Get information on the 2nd one selected.
local myunit=ScenEdit_GetUnit(t.units[2])
print(myunit)


{ units = { [1] = { guid = 'HYXUA2-0HMGO3JLP291Q', name = '3MN-1 Bison B [Bomber]' }, [2] = { guid = 'HYXUA2-0HMGO3JLP292L', name = 'B-52H Stratofortress' }, [3] = { guid = 'HYXUA2-0HMGO3JLP293S', name = 'C-17A Globemaster III SOLL' } } }


unit {
type = 'Aircraft',
subtype = '3101',
name = 'B-52H Stratofortress',
side = 'BLUFOR',
guid = 'HYXUA2-0HMGO3JLP292L',
class = 'B-52H Stratofortress',
proficiency = 'Regular',
latitude = '37.0040975290158',
longitude = '-102.969220619948',
altitude = '10972.8',
heading = '0',
speed = '280',
throttle = 'Loiter',
autodetectable = 'False',
mounts = '2',
magazines = '2',
unitstate = 'Unassigned',
fuelstate = 'None',
weaponstate = 'None',
}

I hope this helps.

R
Ah ha, that's brilliant many thanks,

Think this bit was eluding me;

Get information on the 2nd one selected.
local myunit=ScenEdit_GetUnit(t.units[2])
print(myunit)

Thanks again and it works a charm, I would never have figured the Getunit bit out myself!.
K
wirthlin
Posts: 22
Joined: Sat Dec 26, 2020 11:22 pm

Re: ScenEdit_SelectedUnits ()

Post by wirthlin »

KLAB wrote: Thu Apr 07, 2022 10:22 am
KLAB wrote: Thu Apr 07, 2022 10:04 am
wirthlin wrote: Wed Apr 06, 2022 10:40 pm

Hi K,

It does work. Take a look at the snippet below. I created three aircraft and selected them all. But only print out information on the 2nd one selected.

local t=ScenEdit_SelectedUnits()
print(t)

-- Get information on the 2nd one selected.
local myunit=ScenEdit_GetUnit(t.units[2])
print(myunit)


{ units = { [1] = { guid = 'HYXUA2-0HMGO3JLP291Q', name = '3MN-1 Bison B [Bomber]' }, [2] = { guid = 'HYXUA2-0HMGO3JLP292L', name = 'B-52H Stratofortress' }, [3] = { guid = 'HYXUA2-0HMGO3JLP293S', name = 'C-17A Globemaster III SOLL' } } }


unit {
type = 'Aircraft',
subtype = '3101',
name = 'B-52H Stratofortress',
side = 'BLUFOR',
guid = 'HYXUA2-0HMGO3JLP292L',
class = 'B-52H Stratofortress',
proficiency = 'Regular',
latitude = '37.0040975290158',
longitude = '-102.969220619948',
altitude = '10972.8',
heading = '0',
speed = '280',
throttle = 'Loiter',
autodetectable = 'False',
mounts = '2',
magazines = '2',
unitstate = 'Unassigned',
fuelstate = 'None',
weaponstate = 'None',
}

I hope this helps.

R
Ah ha, that's brilliant many thanks,

Think this bit was eluding me;

Get information on the 2nd one selected.
local myunit=ScenEdit_GetUnit(t.units[2])
print(myunit)

Thanks again and it works a charm, I would never have figured the Getunit bit out myself!.
K
You're quite welcome :)

R
Post Reply

Return to “Lua Legion”