Jump to content

ME dynamic map drawings scripting


ienatom
Go to solution Solved by ienatom,

Recommended Posts

Hello everyone,

I am building a mission and I was wondering if anyone had any knowledge on how to either change color or show/hide a polygon in the F10 map when some kind of event happens (like aerodrome conquest, coalition in zone and such). 

What I am aiming to achieve is to change the color of a polygon (that starts red for example) over a map area once the airbases in it are conquered. Once this happens the color of the polygon should change to blue (or it can also hide the red polygon and show a blue polygon with the same shape if that's not possible).

Does anyone know how this can be done?

Link to comment
Share on other sites

4 minutes ago, ienatom said:

how to either change color or show/hide a polygon in the F10 map when some kind of event happens (like aerodrome conquest, coalition in zone and such). 

Use this to draw and re-draw when the color changes.

Use this to remove before redrawing

 

  • Like 1
Link to comment
Share on other sites

Thanks man, so the polygon is defined by trigger zones right? If I place 4 trigger zones and define them in the script it will build a polygon out of those 4 vertices?

Can it be defined by the same shape as a single rectangular trigger zone?


Edited by ienatom
Link to comment
Share on other sites

6 minutes ago, ienatom said:

Thanks man, so the polygon is defined by trigger zones right? If I place 4 trigger zones and define them in the script it will build a polygon out of those 4 vertices?

Can it be defined by the same shape as a single rectangular trigger zone?

 

If you use MIST, you can draw a trigger zone with : mist.marker.drawZone

MIST markerDrawZone - DCS World Wiki - Hoggitworld.com

Link to comment
Share on other sites

8 minutes ago, ienatom said:

Does this only draw circles?

no, it draws the type you are using.

 

see the description on the page:

Description
Function will use a zone as defined in the editor as a basis for a shape drawn on the map. By default it will inherit the color the user chooses for the zone. Any valid entry for mist.marker.add will be inherited by the shape.

Edited by Kanelbolle
Link to comment
Share on other sites

3 minutes ago, Kanelbolle said:

no, it draws the type you are using.

 

see the description on the page:

Description
Function will use a zone as defined in the editor as a basis for a shape drawn on the map. By default it will inherit the color the user chooses for the zone. Any valid entry for mist.marker.add will be inherited by the shape.

 

Ah sorry I missed that part, I'll try with that. So it would be a combination of what you suggested + what cfrag said regarding removal of the zones?

Link to comment
Share on other sites

10 minutes ago, ienatom said:

Ah sorry I missed that part, I'll try with that. So it would be a combination of what you suggested + what cfrag said regarding removal of the zones?

IF you don't want to remove the marker and just change the color with:
trigger.action.setMarkupColor
trigger.action.setMarkupColorFill

(Just search for the commands on the same page)

No need to remove them if it's not what you want to do. Only thing you need to store what ID the shapes have, so you can change the correct one.


Edited by Kanelbolle
Link to comment
Share on other sites

26 minutes ago, Kanelbolle said:

IF you don't want to remove the marker and just change the color with:
trigger.action.setMarkupColor
trigger.action.setMarkupColorFill

(Just search for the commands on the same page)

No need to remove them if it's not what you want to do. Only thing you need to store what ID the shapes have, so you can change the correct one.

 

Gotcha, so I can use mist.marker.drawZone to use a ME polygon and then trigger.action.setMarkupColor and trigger.action.setMarkupColorFill to respectively change the color of the border and the fill. Correct?


Edited by ienatom
Link to comment
Share on other sites

2 minutes ago, ienatom said:

Gotcha, so I can use mist.marker.drawZone to use a ME polygon and then trigger.action.setMarkupColor and trigger.action.setMarkupColorFill to respectively change the color of the border and the fill. Correct?

 

yes

  • Like 1
Link to comment
Share on other sites

19 minutes ago, Kanelbolle said:

yes

Would this work? (the rgb color is actually blue and the default, ME defined color is red)

It doesn't work, can anyone correct my mistake?
2023-05-19 13:10:53.445 ERROR   SCRIPTING (Main): Mission script error: [string "trigger.action.SetMarkupColor('CYPRUS NORTH', {0, 128, 255, 125})..."]:1: attempt to call field 'SetMarkupColor' (a nil value)
stack traceback:
    [C]: in function 'SetMarkupColor'
    [string "trigger.action.SetMarkupColor('CYPRUS NORTH', {0, 128, 255, 125})..."]:1: in main chunk

Cattura.PNG


Edited by ienatom
Link to comment
Share on other sites

Look here for an example. Main thing i see you are putting a name to the ID, it should be a unique number. (not "CYPRUS NORTH")

I have a example in the post aswell how to do a simple circle and change the color.
 

 


Edited by Kanelbolle
Link to comment
Share on other sites

1 minute ago, Kanelbolle said:

Look here for an example. Main thing i see you are putting a name to the ID, it should be a unique number. (not "CYPR_US NORTH")

I have a example in the post aswell how to do a simple circle and change the color.
 

 

So now the question is: how do I find the ID of a drawing? 😂

Link to comment
Share on other sites

2 minutes ago, ienatom said:

So now the question is: how do I find the ID of a drawing? 😂

You don't find it. You just put one in that is unique. Exampel if you don't any in the mission you can start on 1.

If you have others, you can example start as 2000. Or you can get the next available one with mist.marker.getNextId()

Link to comment
Share on other sites

2 minutes ago, Kanelbolle said:

You don't find it. You just put one in that is unique. Exampel if you don't any in the mission you can start on 1.

If you have others, you can example start as 2000. Or you can get the next available one with mist.marker.getNextId()

So do I need to define the drawings ID first via markerDrawZone?

Link to comment
Share on other sites

5 minutes ago, Kanelbolle said:

Correct.

So to define it as zone with name CYPRUS NORTH, defined as ID 1 and visible to all it would be something like this?


mist.marker.drawZone('CYPRUS NORTH', 1)

Then, in another action define the trigger to change the color like I did before


Edited by ienatom
Link to comment
Share on other sites

Here is a example:

local myzoneid = mist.marker.getNextId()
local dzvars = 
		 {
			id = myzoneid,
		 ignoreColor = true,
		 markForCoa = "all", 
		 color = {1,1,0,1},
		 fillColor = {255,255,0,.2},
		 lineType = 2,
		 readOnly = true,

		 }

mist.marker.drawZone("zonename", dzvars)

 


Edited by Kanelbolle
Link to comment
Share on other sites

7 minutes ago, Kanelbolle said:

Here is a example:

local myzoneid = mist.marker.getNextId()
local dzvars = 
		 {
			id = myzoneid
		 ignoreColor = true,
		 markForCoa = "all", 
		 color = {1,1,0,1},
		 fillColor = {255,255,0,.2},
		 lineType = 2,
		 readOnly = true,

		 }

mist.marker.drawZone("zonename", dzvars)

 

 

2023-05-19 13:45:32.552 ERROR   SCRIPTING (Main): Mission script error: [string "local myzoneid = mist.marker.getNextId()..."]:5: '}' expected (to close '{' at line 3) near 'ignoreColor'

 

local myzoneid = mist.marker.getNextId()
local dzvars = 
         {
            id = myzoneid
         ignoreColor = true,
         markForCoa = "all", 
         color = {255,0,0,125},
         fillColor = {255,0,0,20},
         lineType = 2,
         readOnly = true,

         }

mist.marker.drawZone("CYPRUS NORTH", dzvars)

This is what I modified, taking into consideration that the zone I drew is called CYPRUS NORTH

Link to comment
Share on other sites

2 hours ago, ienatom said:

2023-05-19 13:45:32.552 ERROR   SCRIPTING (Main): Mission script error: [string "local myzoneid = mist.marker.getNextId()..."]:5: '}' expected (to close '{' at line 3) near 'ignoreColor'

 

local myzoneid = mist.marker.getNextId()
local dzvars = 
         {
            id = myzoneid
         ignoreColor = true,
         markForCoa = "all", 
         color = {255,0,0,125},
         fillColor = {255,0,0,20},
         lineType = 2,
         readOnly = true,

         }

mist.marker.drawZone("CYPRUS NORTH", dzvars)

This is what I modified, taking into consideration that the zone I drew is called CYPRUS NORTH

You copied it before i cud fix it. it should be

id = myzoneid,
Link to comment
Share on other sites

On 5/19/2023 at 5:55 PM, Kanelbolle said:

You copied it before i cud fix it. it should be

id = myzoneid,

Ah gotcha, so initial the script runs without issues.

I created the polygon with the defined name CYPRUS NORTH and made it "common", so of course I can see it on the map.

When the selected aerodrome switches function though, the log returns an error: 

2023-05-21 22:55:29.199 ERROR   SCRIPTING (Main): Mission script error: [string "local trigger.action.SetMarkupColor(1, {0, 128, 255, 12})..."]:1: unexpected symbol near '.'

The second part of the script where this error is located goes like this:
 

local trigger.action.SetMarkupColor(1, {0, 128, 255, 12})
local trigger.action.SetMarkupColorFill(1, {0, 128, 255, 20})

 

Link to comment
Share on other sites

9 hours ago, ienatom said:

Ah gotcha, so initial the script runs without issues.

I created the polygon with the defined name CYPRUS NORTH and made it "common", so of course I can see it on the map.

When the selected aerodrome switches function though, the log returns an error: 

2023-05-21 22:55:29.199 ERROR   SCRIPTING (Main): Mission script error: [string "local trigger.action.SetMarkupColor(1, {0, 128, 255, 12})..."]:1: unexpected symbol near '.'

The second part of the script where this error is located goes like this:
 

local trigger.action.SetMarkupColor(1, {0, 128, 255, 12})
local trigger.action.SetMarkupColorFill(1, {0, 128, 255, 20})

 

lua is Case sensetive.
should be "trigger.action.setMarkupColor(number id , table color )"

You don't need "local" in front of it. I would recommend starting with a Lua beginners guide if you are going to script in DCS. There are many if you google it.
You will avoid a lot of headache if you know the basics 🙂

 

Link to comment
Share on other sites

48 minutes ago, Kanelbolle said:

lua is Case sensetive.
should be "trigger.action.setMarkupColor(number id , table color )"

You don't need "local" in front of it. I would recommend starting with a Lua beginners guide if you are going to script in DCS. There are many if you google it.
You will avoid a lot of headache if you know the basics 🙂

 

Yeah I will find one and read it soon, the more I try to script the more I realize that it's hard without a basic knowledge 😂

It's so easy to get lost in these stupid mistakes...

Anyway, now I don't have any error in the log so I guess that the script is formally correct, but the color doesn't change anyways


Edited by ienatom
Link to comment
Share on other sites

30 minutes ago, ienatom said:

Yeah I will find one and read it soon, the more I try to script the more I realize that it's hard without a basic knowledge 😂

It's so easy to get lost in these stupid mistakes...

Anyway, now I don't have any error in the log so I guess that the script is formally correct, but the color doesn't change anyways

 

Probably the the ID of the shape you are trying to change that is not correct.

Try to Hard code it:

 

local myzoneid = 1005
local dzvars = 
		 {
			id = myzoneid,
		 ignoreColor = true,
		 markForCoa = "all", 
		 color = {1,1,0,1},
		 fillColor = {255,255,0,.2},
		 lineType = 2,
		 readOnly = true,

		 }

mist.marker.drawZone("zonename", dzvars)
trigger.action.setMarkupColor(myzoneid , {0, 128, 255, .2} )

 

Not sure you can use the 12 in "{0, 128, 255, 12}"
As far as i know it is a value between 0 and 1

 

Edit: There is also a bug in DCS that sometimes you need to zoom on the map to get the updated color.

Also sometimes the shapes disrepair, then you need to leave the slot and select it again. At least in multiplayer.


Edited by Kanelbolle
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...