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] Marking contacts friendly via VP_GetSide()

 
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 >> Tech Support >> [LUA] Marking contacts friendly via VP_GetSide() Page: [1]
Login
Message << Older Topic   Newer Topic >>
[LUA] Marking contacts friendly via VP_GetSide() - 5/28/2017 4:53:06 PM   
Imaginos

 

Posts: 1
Joined: 5/28/2017
Status: offline
I'm looking to use lua to mark a neutral contact as friendly as if the track were hooked and the player pressed the "f" key manually. So far I have the below based on the examples in the documentation.
unit = ScenEdit_UnitX()
vp = VP_GetSide({name = "TF599"})
cp = vp.contacts
guid = cp[?12?].guid
contact = VP_GetContact({guid=guid})
contact.posture='Friendly'
I don't understand how VP_GetSide.contacts is indexed and how to pull a contact out of it based on possessing a unit.guid. I've marked the hard spot with a ?12? above. The error in the log says that the index on line 4 is nil, or sometime it seems that no error is generated at all.

Also, the documentation on contacts.posture isn't clear to me. Should I be setting that to the table value 1, the string "1", or the string "friendly"?
Post #: 1
RE: [LUA] Marking contacts friendly via VP_GetSide() - 5/29/2017 9:56:46 AM   
michaelm75au


Posts: 12514
Joined: 5/5/2001
From: Sydney, Australia
Status: offline
vp.contacts returns a table of contacts that the side has.
This is a simpler way:
-- my side
local u = ScenEdit_GetUnit({name = "TF599"})
-- unit that triggered event
local contact = ScenEdit_UnitX()
-- this unit seen as a contact by others
local con = contact.ascontact
-- not generated as a contact yet
if #con ~= 0 then
  -- listed as a contact by some side
  -- what is the side id for the unit
  local myside = ScenEdit_GetSideOptions({side=u.side}).guid
  -- find the side's entry in the triggering unit's contact list
  for x = 1, #con do
    if con[x].side == myside then
      -- contact for my side
      local mycontact = ScenEdit_GetContact(con[x].guid)
      mycontact.posture = 'F'
      break
    end
  end
end


< Message edited by michaelm -- 5/29/2017 10:18:01 PM >


_____________________________

Michael

(in reply to Imaginos)
Post #: 2
RE: [LUA] Marking contacts friendly via VP_GetSide() - 5/29/2017 9:59:27 PM   
DeSade

 

Posts: 155
Joined: 3/1/2004
Status: offline
I think line:

if con[x].side == side then

should look like:

if con[x].side == myside then

otherwise, great example as always Michael, thank you :)

(in reply to michaelm75au)
Post #: 3
RE: [LUA] Marking contacts friendly via VP_GetSide() - 5/29/2017 10:18:57 PM   
michaelm75au


Posts: 12514
Joined: 5/5/2001
From: Sydney, Australia
Status: offline
Your correct. Doing this late at night, and trying to remember what I typed ...

_____________________________

Michael

(in reply to DeSade)
Post #: 4
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support >> [LUA] Marking contacts friendly via VP_GetSide() 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

0.111