How to use these commands? Give me some examples, please.

Interesting mapping tools and mapping help.

Moderator: Morax

How to use these commands? Give me some examples, please.

Postby Ghoustaq » 26 Apr 2018, 19:12

1.DrawCircle
INFO: Draw a 3d circle at a with size s and color c
2.DrawLine
INFO: Draw a 3d line from a to b with color c
3.DrawLinePop
INFO: Draw a 3d line from a to b with color c with a circle at the end of the target lin
4.GetHighlightBackgroundColor
INFO: color GetHighlightBackgroundColor()
5.GetHighlightForegroundColor
INFO: color GetHighlightForegroundColor()
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: How to use these commands? Give me some examples, please

Postby Uveso » 26 Apr 2018, 20:56

Nope sorry, those commands are secret :)

Code: Select all
DrawCircle( Position, Radius, Color )
DrawCircle( VECTOR3( {100, 50, 200} ), 5, 'ff00ff00' )


Example:
Code: Select all
function DrawBaseRanger()
    -- Render the radius of any base and expansion location
    if Scenario.MasterChain._MASTERCHAIN_.BaseRanger then
        for Index, ArmyRanger in Scenario.MasterChain._MASTERCHAIN_.BaseRanger do
            for nodename, markerInfo in ArmyRanger do
                -- Draw the inner circle black
                DrawCircle(markerInfo.Pos, markerInfo.Rad-0.5, 'ff000000')
                -- Draw the main circle white
                DrawCircle(markerInfo.Pos, markerInfo.Rad, 'ffFFE0E0')
            end
        end
    end
end


Code: Select all
DrawLinePop( Position1, Position2, Color )
DrawLinePop( VECTOR3( {100, 50, 200} ), VECTOR3( {150, 50, 250} ), 'ff00ff00' )


I don't know the other 2 commands. But i guess the name tells us what they will do ;)
User avatar
Uveso
Supreme Commander
 
Posts: 1788
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 70 times
Been liked: 291 times
FAF User Name: Uveso

Re: How to use these commands? Give me some examples, please

Postby Ghoustaq » 27 Apr 2018, 19:25

@Uveso

Thanks! Do you know how to deal with the error? :?:
WARNING: Error running lua script: attempt to get as number a table value
stack traceback:
[C]: in function `DrawLine'
...me commander - forged alliance\maps\11\11_script.lua(31): in function <...me commander - forged alliance\maps\11\11_script.lua:8>


VECTOR3( {2684.5, 63.96, 489.5} ) is the position of BUFFAREA_1 and VECTOR3( {2682.5, 63.96, 514.5} )is the position of BUFFAREA_2
Code: Select all
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')

function OnPopulate()
    ScenarioUtils.InitializeArmies()   
    ForkThread(DrawBoundaryLine)
end

function DrawBoundaryLine(self)
    local location
    local entities
    local unitsA
    local unitsB
    local ArmyBrain
    while true do
        for k = 1, 3 do
            location = ScenarioUtils.MarkerToPosition('BuffArea_' .. k)
            entities = GetUnitsInRect( Rect(location[1]-11, location[3]-11, location[1]+11, location[3]+11) )
            if entities then
                unitsA = EntityCategoryFilterDown(categories.MOBILE, entities)
                unitsB = EntityCategoryFilterDown(categories.HYDROCARBON + categories.MASSEXTRACTION, entities)
            end
            if unitsB then
                -- check first if the trigger unit is still present
                if unitsB[1] and not unitsB[1].Dead and not unitsB[1]:BeenDestroyed() then
                    ArmyBrain = unitsB[1]:GetAIBrain() -- unitsB[1] is the first unit inside the unitsB table
                    for _, instigator in unitsA do
                        if VDist3(instigator:GetPosition(), location) <= 8 then
                           if instigator:GetAIBrain()== ArmyBrain then
                                DrawLine( VECTOR3( {2684.5, 63.96, 489.5} ), VECTOR3( {2682.5, 63.96, 514.5} ), 'ff00ff00' )
                           end
                        end
                    end
                end   
            end
        end
        WaitSeconds(5) -- waits 5 second. Can be reduced to 1 tick if needed
   end
end
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: How to use these commands? Give me some examples, please

Postby speed2 » 27 Apr 2018, 19:28

WARNING: Error running lua script: attempt to get as number a table value
stack traceback:
[C]: in function `DrawLine'
...me commander - forged alliance\maps\11\11_script.lua(31): in function <...me commander - forged alliance\maps\11\11_script.lua:8>

The function needs a number and you're feeding it with a table.
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: How to use these commands? Give me some examples, please

Postby Uveso » 28 Apr 2018, 00:39

You don't need to write the Vector stuff, its only for explanation that we need 3 values for the position:
Code: Select all
DrawLine( {2684.5, 63.96, 489.5} , {2682.5, 63.96, 514.5} , 'ff00ff00' )
User avatar
Uveso
Supreme Commander
 
Posts: 1788
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 70 times
Been liked: 291 times
FAF User Name: Uveso

Re: How to use these commands? Give me some examples, please

Postby speed2 » 28 Apr 2018, 07:50

Btw. when you don't know how to use something, you can try to search our game repo on the github, it usually have same examples https://github.com/FAForever/fa
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: How to use these commands? Give me some examples, please

Postby Ghoustaq » 28 Apr 2018, 17:46

Uveso wrote:You don't need to write the Vector stuff, its only for explanation that we need 3 values for the position:
Code: Select all
DrawLine( {2684.5, 63.96, 489.5} , {2682.5, 63.96, 514.5} , 'ff00ff00' )

@Uveso

OK! I got it :)
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq


Return to Mapping

Who is online

Users browsing this forum: No registered users and 1 guest