Kanelbolle Posted March 13, 2022 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/
toutenglisse Posted March 14, 2022 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
Solution Grimes Posted March 14, 2022 Solution 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
Kanelbolle Posted April 26, 2022 Author 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/
Kanelbolle Posted May 12, 2022 Author 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/
SC_SquadCentral Posted May 7, 2023 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
Grimes Posted May 7, 2023 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
SOAR Posted March 14, 2024 Posted March 14, 2024 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?
TEMPEST.114 Posted March 14, 2024 Posted March 14, 2024 (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, 2024 by Elphaba
Kanelbolle Posted March 15, 2024 Author Posted March 15, 2024 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/
Kanelbolle Posted March 15, 2024 Author Posted March 15, 2024 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/
Blackbahia Posted August 3, 2024 Posted August 3, 2024 @Kanelbolle does your script also work with FARPs or only with fixed airbases on the map?
Kanelbolle Posted August 4, 2024 Author Posted August 4, 2024 15 hours ago, Blackbahia said: @Kanelbolle does your script also work with FARPs or only with fixed airbases on the map? Not as it it is above, but it is a easy addition to add. You just need to include the FARP category in the function ebc.loadStartingBases() : infoLoaded.desc.category == 1 and in the event handler: CapPlaceDesc.category == 1 WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/
Blackbahia Posted August 4, 2024 Posted August 4, 2024 @Kanelbolle I couldn't manage that. I tried several times, but I think I always destroyed the script. I just don't know enough about scripting....
Kanelbolle Posted August 4, 2024 Author Posted August 4, 2024 49 minutes ago, Blackbahia said: @Kanelbolle I couldn't manage that. I tried several times, but I think I always destroyed the script. I just don't know enough about scripting.... Here is a version with FARPS. Just need a OR when checking the category. ebc-Example_002.lua test_ebc_v002.miz WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/
Blackbahia Posted August 4, 2024 Posted August 4, 2024 Thanks a lot, now it works! I even managed to get the fill colour to be in a circle and change on capture! The trigger action "setMarkupColorFill" is necessary for this. btw: It only works with a FARP if "FARP" or "Invisble FARP" is selected. "Helipad single" and "PAD single" do not work. But the professionals here probably already know that!
Kanelbolle Posted August 8, 2024 Author Posted August 8, 2024 Here is an example that includes single pad, it had category 2. test_ebc_v003.miz ebc-Example_003.lua 1 WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/
shaji Posted November 10, 2024 Posted November 10, 2024 On 3/15/2022 at 12:34 AM, Grimes said: 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. Is there a way to get the missing pieces implemented in the API? Are they going to add them? Line Style and Line Thickness are very important parts of the draw tool, that 1px line is basically invisible.
Recommended Posts