[lua] drawing circles script (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios



Message


Michal Pielaszkiewicz -> [lua] drawing circles script (9/30/2016 4:18:40 PM)

Hi,
Recently I was frustrated witch placing SAM's and assigning for it areas, trying to make it circle...
I've found code on Baloogan forum (unfortunately now I can not enter his forum?) that creates "circles" from RP's, unfortunately that script works only on equator and with increasing deviation shape of circles is getting werid, so I've modified original code to include nav. deviation - now circles are nice at any latitude, I've also changed inputs, so now you have to provide unit which is center of area, radius in Nm and number of verticals.

How to use,

First paste this code to script console and run:

-- RP.01
-- Written by Baloogan
-- Modified draw_circle by Yautay
 
function draw_circle(a,b,t,txt)
    if txt == nil then
       txt = ""
    end
    t = t
    tg = t - 1
    lat1 = a.latitude
    lon1 = a.longitude
    r = b / 60 
 
    for i=0,tg do
        th = 2 * math.pi * i / t 
	rlat = lat1 + r * math.cos(th)
        rlon = lon1 + r * math.sin(th) / math.cos(math.rad(lat1))
        ScenEdit_AddReferencePoint({
            side='PlayerSide',
            lat=rlat,
            lon=rlon,
            name=txt,
            highlighted="yes"})
    end
 
end



Now paste this code, change red syntax for your own side/unit name (here is Red and test), change radius (350) and desired number of verticals (24). Run it...

 
local unit = ScenEdit_GetUnit({side="Red", name="test"})
draw_circle({latitude=unit.latitude, longitude=unit.longitude}, 350, 24, "RP")





thewood1 -> RE: [lua] drawing circles script (10/1/2016 12:08:39 AM)

That is a big contribution for someone with only 13 posts in two years. Well done. And you are the god of lurkers.




temkc5 -> RE: [lua] drawing circles script (10/3/2016 3:51:18 AM)

Thank you Michal [&o]




Michal Pielaszkiewicz -> RE: [lua] drawing circles script (10/4/2016 9:36:44 AM)

temkc5, does it work now?
M




temkc5 -> RE: [lua] drawing circles script (10/4/2016 11:18:15 PM)

Yes it work.

Wish I could say perfectly but it seems to has you said "not like spaces in the name" ie: Osama Bin Laden Airbase [:D]

But Trump Airport should work [8D]

Overall it's like that muscle car grandad is trying to restore once you get the engine going all the blood sweat and tears feels worth it

Keep Up The Great Work CMANO Community

(I only cut and paste the script and tried to enter the side & name to how the Lua prefers)




U6443 -> RE: [lua] drawing circles script (10/5/2016 3:21:24 PM)

Hi

Yes it works, for units...
Could somebody try to include Reference Points as source?

That would be great
Thank's
Andy




stilesw -> RE: [lua] drawing circles script (10/5/2016 4:00:32 PM)

U6443,
I do not think you can use a reference point as the origin point. However you can create a temporary unit, say a small building on land or oil platform at sea, and use it as the center point. After the points are created just delete the building/platform and the RPs remain.

-Wayne Stiles




U6443 -> RE: [lua] drawing circles script (10/5/2016 5:38:46 PM)

Thank's

I would use this script for playing, not for creating scenarios.....

I hope in future it would be possible to create circles from reference points.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.625