Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Lua question: "inArea" syntax

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua question: "inArea" syntax Page: [1]
Login
Message << Older Topic   Newer Topic >>
Lua question: "inArea" syntax - 6/27/2017 9:33:09 PM   
CCIP-subsim


Posts: 695
Joined: 11/10/2015
Status: offline
Another quick Lua question for those in-the-know:

I've been trying to get the program to return 'true'/'false' for me in reference to whether a selected unit/contact is in a defined area (as the Lua documentation says), but I can't figure out the correct way of doing this. I have no trouble defining an area of ref points, but I can't seem to get to give me any meaningful return.

Say, if I wanted to check whether unit MyUnit is in an area defined by points A,B,C,D. I've tried a few things, but none of them work, including...
ab = ScenEdit_GetUnit({side='MySide', name='MyUnit'})
return ab.inArea({'A','B','C','D'})


or ab.inArea{'A','B','C','D'}, or ['A','B','C','D'] or (area={'A','B','C','D'}) etc., with no luck.
I've also tried things like

MyArea = ScenEdit_GetReferencePoints({side='MySide',area={'A','B','C','D'})
ab = ScenEdit_GetUnit({side='MySide', name='MyUnit'})
return ab.inArea(MyArea)


and other things of some sort. Still nada!

If someone can help me figure out what I'm doing wrong, I'd greatly appreciate it!

Alternatively, I was wondering if I could also do something similar using a Lua condition script or a similar workaround - in this case, what I'm trying to do is create different rules for scoring the destruction of the same unit types on the same side, depending on whether they were destroyed inside a particular area, or outside of it. The only other method I can think of is a lot more unwieldy, which would basically involve temporarily changing unit sides while they are in a particular area. inArea method was what I thought would be easiest for it!
Post #: 1
RE: Lua question: "inArea" syntax - 6/28/2017 2:35:17 PM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
That function is not yet enabled. It is on the Command Beta page which means it is not yet available.
As I may have mentioned several times, the beta page contains things yet to be available. I will move them to the normal Command page as they are released.

_____________________________

Michael

(in reply to CCIP-subsim)
Post #: 2
RE: Lua question: "inArea" syntax - 6/28/2017 2:38:23 PM   
CCIP-subsim


Posts: 695
Joined: 11/10/2015
Status: offline
quote:

ORIGINAL: michaelm

That function is not yet enabled. It is on the Command Beta page which means it is not yet available.
As I may have mentioned several times, the beta page contains things yet to be available. I will move them to the normal Command page as they are released.


Aha, I meet my nemesis the beta feature again!

I realized that when I start typing in CommandLua, it defaults to the beta page instead of the current version doc in my browser, so that explains why I keep bumping into it. Thanks!

And I did find a good enough workaround for what I was doing in any case :)

< Message edited by CCIPsubsim -- 6/28/2017 2:40:57 PM >

(in reply to michaelm75au)
Post #: 3
RE: Lua question: "inArea" syntax - 6/28/2017 2:39:58 PM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Duplicate

< Message edited by michaelm -- 6/28/2017 2:42:34 PM >


_____________________________

Michael

(in reply to michaelm75au)
Post #: 4
RE: Lua question: "inArea" syntax - 6/28/2017 2:41:53 PM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
For reference, this is how I have used that function that in my testing
-- one unit has trigger event, any more in the area
local result = false
local minReq = 2
local area = {'rp-6074','rp-6075','rp-6076','rp-6077'}
local landed = ScenEdit_GetKeyValue("UnitsLandedAtBase")
local units={}
if landed == nil then
  units[1] = UnitX.guid
else
  local found = false
  for i = 1, #units
  do
    if units[i] == UnitX.guid then
      found = true
      break  -- exists in list
  end
  if found == false then
    units[#units +1] = UnitX.guid 
  end
end 

-- check if units still there
  for i = 1, #units
  do
    local unit = ScenEdit_GetUnit({guid=units[i]})
    if unit == nil then
      table.remove(units,i)
    else if unit:inArea( area ) == false then
      table.remove(units,i)
    end
  end

landed=table.concat(units,',')
ScenEdit_SetKeyValue( "UnitsLandedAtBase", landed)
return result


_____________________________

Michael

(in reply to michaelm75au)
Post #: 5
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua question: "inArea" syntax Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

1.047