Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Get Circle/Make RP not working

 
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 Legion >> Get Circle/Make RP not working Page: [1]
Login
Message << Older Topic   Newer Topic >>
Get Circle/Make RP not working - 3/23/2021 1:13:11 AM   
vettim89


Posts: 3614
Joined: 7/14/2007
From: Toledo, Ohio
Status: offline
I modified this function from Knighhawk to pass a side, unit, and radius of a circle or RP

local function BuildCircleOfRPs(theside,pguid, range)
local unit=ScenEdit_GetUnit({guid=pguid})
local tableofcirclepoints = World_GetCircleFromPoint({latitude=unit.latitude,longitude=unit.longitude,numpoints=12,radius=range})
local counter = 1;
for k,v in ipairs(tableofcirclepoints) do
ScenEdit_AddReferencePoint({side=theside,latitude=v.latitude,longitude=v.longitude, relativeto=unit.guid, name=unit.name .. "-" .. counter})
counter = counter +1;
end
end

The call is

local patrol=ScenEdit_UnitX()
local function BuildCircleOfRPs('Iran',patrol.guid,1)

So basically when a patrol boat undocks it enters a zone that should trigger the event and then have a circle of RPs generated around the PB

This is not working

_____________________________

"We have met the enemy and they are ours" - Commodore O.H. Perry
Post #: 1
RE: Get Circle/Make RP not working - 3/23/2021 5:48:29 AM   
KnightHawk75

 

Posts: 1408
Joined: 11/15/2018
Status: offline
You're not calling your function, you're redefining it in the last line.

You also don't need counter here?
Also if you already have the unit wrapper from UnitX call why pass the guid and get the unit again, you can just pass the wrapper itself.

try
local function BuildCircleOfRPs(theside, unit, range)
  local tableofcirclepoints = World_GetCircleFromPoint({latitude=unit.latitude,longitude=unit.longitude,numpoints=12,radius=range})
  for k,v in ipairs(tableofcirclepoints) do
    ScenEdit_AddReferencePoint({side=theside,latitude=v.latitude,longitude=v.longitude, relativeto=unit.guid, name=unit.name .. "-" .. counter})
  end
end

local patrol=ScenEdit_UnitX()
BuildCircleOfRPs('Iran',patrol,1)


(in reply to vettim89)
Post #: 2
RE: Get Circle/Make RP not working - 3/23/2021 11:17:04 PM   
vettim89


Posts: 3614
Joined: 7/14/2007
From: Toledo, Ohio
Status: offline

quote:

ORIGINAL: KnightHawk75

You're not calling your function, you're redefining it in the last line.

You also don't need counter here?
Also if you already have the unit wrapper from UnitX call why pass the guid and get the unit again, you can just pass the wrapper itself.

try
local function BuildCircleOfRPs(theside, unit, range)
  local tableofcirclepoints = World_GetCircleFromPoint({latitude=unit.latitude,longitude=unit.longitude,numpoints=12,radius=range})
  for k,v in ipairs(tableofcirclepoints) do
    ScenEdit_AddReferencePoint({side=theside,latitude=v.latitude,longitude=v.longitude, relativeto=unit.guid, name=unit.name .. "-" .. counter})
  end
end

local patrol=ScenEdit_UnitX()
BuildCircleOfRPs('Iran',patrol,1)




That fixed it, thanks as always

_____________________________

"We have met the enemy and they are ours" - Commodore O.H. Perry

(in reply to KnightHawk75)
Post #: 3
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Get Circle/Make RP not working 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.178