Add reference point frustration

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
vettim89
Posts: 3739
Joined: Fri Jul 13, 2007 11:38 pm
Location: Toledo, Ohio

Add reference point frustration

Post by vettim89 »

I have an event trigger set for "unit enters area". I have tested this trigger and is working. However the folling event action fails to run:

local target = ScenEdit_UnitX()
local tname=target.name
ScenEdit_AddReferencePoint({side='Iran', relativeto=tname, bearing = 45, distance=1, bearingtype='fixed', name='HP11', highlighted=true})
ScenEdit_AddReferencePoint({side='Iran', relativeto=tname, bearing = 135, distance=1, bearingtype='fixed', name='HP12', highlighted=true})
ScenEdit_AddReferencePoint({side='Iran', relativeto=tname, bearing = 225, distance=1, bearingtype='fixed', name='HP13', highlighted=true})
ScenEdit_AddReferencePoint({side='Iran', relativeto=tname, bearing = 315, distance=1, bearingtype='fixed', name='HP14', highlighted=true})
ScenEdit_AddMission('Iran', 'Hormuz Harassment 1', 'Support', {zone='HP11','HP12', 'HP13', 'HP14'})
ScenEdit_AssignUnitToMission({guid='W7ZXL3-0HM705AO7FAUL'}, 'Hormuz Harassment 1')

I have been trying to figure this out for a day now. I figure I have the syntax wrong somewhere
"We have met the enemy and they are ours" - Commodore O.H. Perry
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Add reference point frustration

Post by KnightHawk75 »

bad syntax in AddMission and AssignUnitToMission, the ref point creation is fine (though you should probably use guids in relativeto , but it's the other 2 causing you issues.

use following:

Code: Select all

 local target = ScenEdit_UnitX()
 ScenEdit_AddReferencePoint({side='Iran', relativeto=target.guid, bearing = 45, distance=1, bearingtype='fixed', name='HP11', highlighted=true}) 
 ScenEdit_AddReferencePoint({side='Iran', relativeto=target.guid, bearing = 135, distance=1, bearingtype='fixed', name='HP12', highlighted=true})
 ScenEdit_AddReferencePoint({side='Iran', relativeto=target.guid, bearing = 225, distance=1, bearingtype='fixed', name='HP13', highlighted=true})
 ScenEdit_AddReferencePoint({side='Iran', relativeto=target.guid, bearing = 315, distance=1, bearingtype='fixed', name='HP14', highlighted=true}) 
 
 ScenEdit_AddMission('Iran', 'Hormuz Harassment 1', 'Support', {zone={'HP11','HP12', 'HP13', 'HP14'}}) --note the table inside a table)
 ScenEdit_AssignUnitToMission('W7ZXL3-0HM705AO7FAUL', 'Hormuz Harassment 1')  -- no table or 'guid',just straight params.
 




User avatar
vettim89
Posts: 3739
Joined: Fri Jul 13, 2007 11:38 pm
Location: Toledo, Ohio

RE: Add reference point frustration

Post by vettim89 »

Thanks for point out my error, Knighthawk. Unfortunately that did not fix it

So I plugged an actual unit into the Lua console to see if the Action would work

local target = ScenEdit_GetUnit({guid='W7ZXL3-0HM6S2INFIKR3'})
ScenEdit_AddReferencePoint({side='Iran', relativeto=target.guid, bearing = 45, distance=1, bearingtype='fixed', name='HP11', highlighted=true})
ScenEdit_AddReferencePoint({side='Iran', relativeto=target.guid, bearing = 135, distance=1, bearingtype='fixed', name='HP12', highlighted=true})
ScenEdit_AddReferencePoint({side='Iran', relativeto=target.guid, bearing = 225, distance=1, bearingtype='fixed', name='HP13', highlighted=true})
ScenEdit_AddReferencePoint({side='Iran', relativeto=target.guid, bearing = 315, distance=1, bearingtype='fixed', name='HP14', highlighted=true})
ScenEdit_AddMission('Iran', 'Hormuz Harassment 1', 'Support', {zone={'HP11','HP12', 'HP13', 'HP14'}})
ScenEdit_AssignUnitToMission('W7ZXL3-0HM705AO7FAUL', 'Hormuz Harassment 1')


I received this error message:

ScenEdit_AddReferencePoint 0 : ,Missing unit W7ZXL3-0HM6S2INFIKR3 from relative bearing

Could the problem be that I am trying to set up a relative bearing for one side (Iran) that is relative to a unit on another side (Neutral)?
"We have met the enemy and they are ours" - Commodore O.H. Perry
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Add reference point frustration

Post by michaelm75au »

You get that error if it can't find the 'relativeto' unit [W7ZXL3-0HM6S2INFIKR3] on the 'side' [Iran]
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Add reference point frustration

Post by KnightHawk75 »

ORIGINAL: vettim89

Thanks for point out my error, Knighthawk. Unfortunately that did not fix it

So I plugged an actual unit into the Lua console to see if the Action would work

local target = ScenEdit_GetUnit({guid='W7ZXL3-0HM6S2INFIKR3'})
ScenEdit_AddReferencePoint({side='Iran', relativeto=target.guid, bearing = 45, distance=1, bearingtype='fixed', name='HP11', highlighted=true})
ScenEdit_AddReferencePoint({side='Iran', relativeto=target.guid, bearing = 135, distance=1, bearingtype='fixed', name='HP12', highlighted=true})
ScenEdit_AddReferencePoint({side='Iran', relativeto=target.guid, bearing = 225, distance=1, bearingtype='fixed', name='HP13', highlighted=true})
ScenEdit_AddReferencePoint({side='Iran', relativeto=target.guid, bearing = 315, distance=1, bearingtype='fixed', name='HP14', highlighted=true})
ScenEdit_AddMission('Iran', 'Hormuz Harassment 1', 'Support', {zone={'HP11','HP12', 'HP13', 'HP14'}})
ScenEdit_AssignUnitToMission('W7ZXL3-0HM705AO7FAUL', 'Hormuz Harassment 1')


I received this error message:

ScenEdit_AddReferencePoint 0 : ,Missing unit W7ZXL3-0HM6S2INFIKR3 from relative bearing

Could the problem be that I am trying to set up a relative bearing for one side (Iran) that is relative to a unit on another side (Neutral)?
I ran what's posted in #2 (adjusted for a real guid in my test for the assigntomission call and ), it ran fine.
User avatar
vettim89
Posts: 3739
Joined: Fri Jul 13, 2007 11:38 pm
Location: Toledo, Ohio

RE: Add reference point frustration

Post by vettim89 »

ORIGINAL: michaelm75au

You get that error if it can't find the 'relativeto' unit [W7ZXL3-0HM6S2INFIKR3] on the 'side' [Iran]

Is there away around this? I am guessing you can see what I am trying to do here: I have a merchant ship traversing the Strait of Hormuz and want the Iranian patrol boat to approach to within 1 NM and "harass" it. I thought the easiest was was to create a zone around the target ship and have the Iranian unit assigned to a mission within that zone. If I put "side='Neutral" will the Iran side be able to see those RPs to establish the mission or is there another way to do this?
"We have met the enemy and they are ours" - Commodore O.H. Perry
p1t1o
Posts: 274
Joined: Mon Apr 06, 2015 11:35 am

RE: Add reference point frustration

Post by p1t1o »

in the target field, can you use a wrapper that ID's the target in a way that includes a side? Like:

ScenEdit_AddReferencePoint({side='Iran', relativeto={ScenEdit_GetUnit{side='Neutral', name='unit 1'}}, bearing = 45, distance=1, bearingtype='fixed', name='HP11', highlighted=true})

Would something like that work?
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Add reference point frustration

Post by michaelm75au »

ORIGINAL: vettim89

ORIGINAL: michaelm75au

You get that error if it can't find the 'relativeto' unit [W7ZXL3-0HM6S2INFIKR3] on the 'side' [Iran]

Is there away around this? I am guessing you can see what I am trying to do here: I have a merchant ship traversing the Strait of Hormuz and want the Iranian patrol boat to approach to within 1 NM and "harass" it. I thought the easiest was was to create a zone around the target ship and have the Iranian unit assigned to a mission within that zone. If I put "side='Neutral" will the Iran side be able to see those RPs to establish the mission or is there another way to do this?

In essence, you are really trying to 'box' a contact? The relativity is to an actual unit as a fixed location.
Michael
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Add reference point frustration

Post by michaelm75au »

If you can make points relative to a contact thru GUI (which I think you can now), then you should be able to in Lua. I'll look into it.
You can use the 'contact' as the relative point, but the points don't move as that is based on actual units of side.

Need to think more about it.
Michael
User avatar
vettim89
Posts: 3739
Joined: Fri Jul 13, 2007 11:38 pm
Location: Toledo, Ohio

RE: Add reference point frustration

Post by vettim89 »

Well I solve the problem just not in the way I thought would work. I set up the mission to be a "strike" mission with WMA set to "Weapons Tight" and the engagement range of 0.75 nm). The PB makes a bee line for the target just as desired
"We have met the enemy and they are ours" - Commodore O.H. Perry
User avatar
vettim89
Posts: 3739
Joined: Fri Jul 13, 2007 11:38 pm
Location: Toledo, Ohio

RE: Add reference point frustration

Post by vettim89 »

ORIGINAL: vettim89

Well I solve the problem just not in the way I thought would work. I set up the mission to be a "strike" mission with WMA set to "Weapons Tight" and the engagement range of 0.75 nm). The PB makes a bee line for the target just as desired


No I am incorrect in this resolution. The mission when activated turns the target hostile and then the selcted units start to attack the target. Still chewing on this one
"We have met the enemy and they are ours" - Commodore O.H. Perry
Post Reply

Return to “Lua Legion”