Kanelbolle Posted March 13, 2022 Share Posted March 13, 2022 Hi, anyone know if it is possible to example change the color of a "Polygon" that was made in the Draw tool (ME) with a script in mission ? Can't find any documentation on this. WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/ Link to comment Share on other sites More sharing options...
toutenglisse Posted March 14, 2022 Share Posted March 14, 2022 4 hours ago, Kanelbolle said: Hi, anyone know if it is possible to example change the color of a "Polygon" that was made in the Draw tool (ME) with a script in mission ? Can't find any documentation on this. For what I know, you can only change parameters (with SetMarkup... functions) of script created markup ( DCS func markupToAll - DCS World Wiki - Hoggitworld.com ). 1 Link to comment Share on other sites More sharing options...
Solution Grimes Posted March 14, 2022 Solution Share Posted March 14, 2022 Right now they are two very different systems in several respects. You can't modify drawings from the editor via scripting, but you have access to their information. However the scripting engine doesn't have the same parameters as what is available in the editor. The two main ones being that line types are not the same and line thickness is not available in scripting. There are several other differences in the form of format, but those can be worked around. Namely: Scripting color format is {r, g, b, a} in values 0 to 1 while editor is in hex Points for drawings are stored relative to the first point with a mapX and mapY value defining the offset of that first point from map origin Angle of a drawing is often its own value, so similar to mapX and mapY it will offset any points based on that value. Oval and rectangle in drawings are defined as mathematical shapes. In other words a rectangle is height and width instead of being 4 points. Arrow in the editor is a set of points making up a polygon while the scripting arrow is just between two points. Easiest would be to use the editor to get the drawing information but actually add the shape via scripting, then changing it however you see fit via scripting again. Might even be easier to use a group's route to define the points and just call trigger.action.markupToAll with the valid parameters. 1 The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
Kanelbolle Posted April 26, 2022 Author Share Posted April 26, 2022 Thx both for pointing me in the right direction. Haven't done much scripting the last year, so it's like starting from scratch.. I just made a coalition colored circle at every airfield with trigger.action.circleToAll and used trigger.action.setMarkupColor to change it when the airfield got captured WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/ Link to comment Share on other sites More sharing options...
Kanelbolle Posted May 12, 2022 Author Share Posted May 12, 2022 (edited) Hi, for others who wonder how, here is an example on how to draw a circle at an airbase and change the color. Se miz file attached! Draws a blue circle at the first airbase and changes the color to red after 10 seconds. (After the ring is drawn you need to move or zoom the map for it to show. Same when color change) Draw_and_change_circle.miz Edited May 13, 2022 by Kanelbolle 1 WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/ Link to comment Share on other sites More sharing options...
SC_SquadCentral Posted May 7, 2023 Share Posted May 7, 2023 I can't get this to work at multiple air fields. I want to start with all fields as neutral in a white color and then change to the color of the corresponding coalition. I have made this happen at one field and can't get any color to show up at other fields. Here is my miz file for review. World Conquer STEP 2.miz Link to comment Share on other sites More sharing options...
Grimes Posted May 7, 2023 Share Posted May 7, 2023 You have to make sure the markId is unique when you create it. The second input value is used as the id, and you have it being the same for both. You can use the mist.marker.add function to create it if you don't want to have to manage it yourself. local ref = trigger.misc.getZone("Novo") trigger.action.circleToAll(-1 , 1, ref.point , ref.radius , {1, 1, 1, 1} , {0, 0, 0, .2} , 1 , true) local ref = trigger.misc.getZone("Krymsk") trigger.action.circleToAll(-1 , 1, ref.point , ref.radius , {1, 1, 1, 1} , {0, 0, 0, .2} , 1 , true) You could pretty easily use world.getAirbases and the base capture event to draw the circles as needed. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
SOAR Posted March 14 Share Posted March 14 On 5/7/2023 at 6:22 PM, Grimes said: You have to make sure the markId is unique when you create it. The second input value is used as the id, and you have it being the same for both. You can use the mist.marker.add function to create it if you don't want to have to manage it yourself. local ref = trigger.misc.getZone("Novo") trigger.action.circleToAll(-1 , 1, ref.point , ref.radius , {1, 1, 1, 1} , {0, 0, 0, .2} , 1 , true) local ref = trigger.misc.getZone("Krymsk") trigger.action.circleToAll(-1 , 1, ref.point , ref.radius , {1, 1, 1, 1} , {0, 0, 0, .2} , 1 , true) You could pretty easily use world.getAirbases and the base capture event to draw the circles as needed. Would you be willing to post an example script? Does this function constantly monitor airbase status and change the colors accordingly? Link to comment Share on other sites More sharing options...
TEMPEST.114 Posted March 14 Share Posted March 14 (edited) 18 hours ago, SOAR said: Would you be willing to post an example script? Does this function constantly monitor airbase status and change the colors accordingly? No, you'd have to do that in scripting, and then post one of those actions depending on the result. I think an 'example' would basically be writing it for you. Take a look at this: https://wiki.hoggitworld.com/view/DCS_func_addEventHandler Edited March 14 by Elphaba Link to comment Share on other sites More sharing options...
Kanelbolle Posted March 15 Author Share Posted March 15 On 3/14/2024 at 5:03 AM, SOAR said: Would you be willing to post an example script? Does this function constantly monitor airbase status and change the colors accordingly? Can see if i can get one of my scripts cleaned up to post this weekend WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/ Link to comment Share on other sites More sharing options...
Kanelbolle Posted March 15 Author Share Posted March 15 Here is an example that does the following: 1. Checks all airfields what coalition it is 2. Draws a circle at the airbase according to the coalition color 3. Changes the color if it changes coalition between Blue and Red. It does not, change if the airfields go Natural after it has been captured. You need a scheduled function to check this in a loop. Added a example mission and the script. Here is it raw. It's messy and old, but it an working example. ebc = ebc or {} -- do not remove function ebc.loadStartingBases() local baseCheckLoadeed = world.getAirbases() local myBaseLoadedTbl = {} for i = 1, #baseCheckLoadeed do local infoLoaded = {} infoLoaded.id = Airbase.getID(baseCheckLoadeed[i]) infoLoaded.desc = Airbase.getDesc(baseCheckLoadeed[i]) infoLoaded.point = Airbase.getPoint(baseCheckLoadeed[i]) infoLoaded.callsign = Airbase.getCallsign(baseCheckLoadeed[i]) infoLoaded.afcoa = Airbase.getCoalition(baseCheckLoadeed[i]) infoLoaded.afbase = baseCheckLoadeed[i] if (Object.getCategory(baseCheckLoadeed[i]) == 4) and (infoLoaded.desc.category == 0 ) then -- Creates circle on map with same id as Airfiled ID (If you have other drawings on map, you should change what id the drawing gets if (infoLoaded.afcoa == 0 ) then trigger.action.circleToAll(-1 , infoLoaded.id , infoLoaded.point , 6000 , {1,1,1,1} , {0,0,0,0} , 5) elseif (infoLoaded.afcoa == 1 ) then -- RED AIRBASE trigger.action.circleToAll(-1 , infoLoaded.id , infoLoaded.point , 6000 , {1,0,0,1} , {0,0,0,0} , 5) elseif (infoLoaded.afcoa == 2 ) then -- BLUE AIRBASE trigger.action.circleToAll(-1 , infoLoaded.id , infoLoaded.point , 6000 , {0,0,1,1} , {0,0,0,0} , 5) end end -- of if (Object.getCategory(baseCheckLoadeed[i]) == 4) and (infoLoaded.desc.category == 0 ) then end -- of for i = 1, #baseCheckLoadeed do end -- of function ebc.loadStartingBases() ebc.captureHandler = {}; function ebc.captureHandler:onEvent(event) if (world.event.S_EVENT_BASE_CAPTURED == event.id) then if event.place ~= nil then --trigger.action.outText("event not nil radiocargo!",20) local CapPlaceDesc =Airbase.getDesc(event.place) local CapPlaceId = Airbase.getID(event.place) local CapPlaceName = Airbase.getName(event.place) local CapAirbaseName if (CapPlaceDesc.category == 1) then CapAirbaseName = CapPlaceName else CapAirbaseName = CapPlaceDesc.displayName end local targetCoord = Airbase.getByName(CapAirbaseName):getPoint() -- Red Capped base if (CapPlaceDesc.category == 0 ) and (Object.getCategory(event.place) == 4) and (Airbase.getCoalition(event.place) == 1) then trigger.action.outText("Airbase was captured by Red coalition: " ..CapAirbaseName,20) -- local msg = string.format("Airbase ID : %i", CapPlaceId) --trigger.action.outText(msg , 10) -- Smoke trigger.action.smoke(targetCoord, trigger.smokeColor.Red) --Change Color of circle trigger.action.setMarkupColor(CapPlaceId , {1,0,0,1} ) -- Logg _airbaseIDString = string.format("%i", CapPlaceId) env.info('- Airbase was captured by Red coalition: ' .. CapAirbaseName .. ' - AirbaseID: ' .. _airbaseIDString) end -- of if (CapPlaceDesc.category == 0 ) and (Object.getCategory(event.place) == 4) and (Airbase.getCoalition(event.place) == 1) then -- Blue capped airbase if (CapPlaceDesc.category == 0 ) and (Object.getCategory(event.place) == 4) and (Airbase.getCoalition(event.place) == 2) then --CapAirbaseName = CapPlaceDesc.displayName trigger.action.outText("Airbase was captured by Blue coalition: " ..CapAirbaseName,20) -- local msg = string.format("Airbase ID : %i", CapPlaceId) --trigger.action.outText(msg , 10) -- Smoke trigger.action.smoke(targetCoord, trigger.smokeColor.Blue) --Change Color of circle trigger.action.setMarkupColor(CapPlaceId , {0,0,1,1} ) -- Logg _airbaseIDString = string.format("%i", CapPlaceId) env.info('- Airbase was captured by Blue coalition: ' .. CapAirbaseName .. ' - AirbaseID: ' .. _airbaseIDString) end -- of if (CapPlaceDesc.category == 0 ) and (Object.getCategory(event.place) == 4) and (Airbase.getCoalition(event.place) == 2) then -- Does not work since there is no event running on neutral -- Need to check this with a schedual or something if (CapPlaceDesc.category == 0 ) and (Object.getCategory(event.place) == 4) and (Airbase.getCoalition(event.place) == 0) then trigger.action.outText("Airbase is Neutral: " ..CapAirbaseName,20) env.info("Airbase is Neutral: " ..CapAirbaseName) end -- of if (CapPlaceDesc.category == 0 ) and (Object.getCategory(event.place) == 4) and (Airbase.getCoalition(event.place) == 0) then end --if event.place ~= nil end --if (world.event.S_EVENT_BASE_CAPTURED == event.id) then end --end ebc.captureHandler -- Run the first function to make the markers ebc.loadStartingBases() -- Start the monitoring of the event world.addEventHandler(ebc.captureHandler) env.info('EBC loaded!') test_ebc_v001.miz ebc-Example_001.lua WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/ Link to comment Share on other sites More sharing options...
Recommended Posts