Jump to content

Kanelbolle

Members
  • Posts

    213
  • Joined

  • Last visited

Everything posted by Kanelbolle

  1. You can delete it your self by pressing Hide in the "Moderation Action" meny on top of this post.
  2. 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
  3. Can see if i can get one of my scripts cleaned up to post this weekend
  4. To do Color you just use the color variable for the command: https://wiki.hoggitworld.com/view/MIST_markerAdd Example: vd.color = {1,1,1,1}
  5. Not that i know of, maybe look at all the available commands: https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation You have to keep track of the id's you crate if you want to delete them, as i showed you before, but you can put them all in a table instead of individual strings. See here: https://www.tutorialspoint.com/lua/lua_tables.htm I would highly recommend you start taking a LUA tutorial if you are going to code for DCS
  6. This is the getGroupPoints that gets this points from the waypoints of the group. It only seam to make polygons, not lines. Here is a quick and dirty example to make a drawing using a loop that gets a units route : function makeLineFromUnitRoute(_unitName) local test = {} local posTbl = {} local _last = nil test.pos = mist.getGroupPoints(_unitName) for k,v in pairs(test.pos) do env.info(v) if (k == 1) then _last = test.pos[k] env.info("Adding First off all pos: " .. test.pos[k].x) elseif (k ~= _last) then env.info("Pos: " .. k) env.info("Adding new pos: " .. test.pos[k].x) posTbl = { [1] = _last, [2] = { ["x"] = test.pos[k].x, ["y"] = test.pos[k].y, }, } local vd = {} vd.id = mist.marker.getNextId() vd.pos = posTbl vd.lineType = 1 vd.mType = 'line' mist.marker.add(vd) env.info("Made Line from point " .. k .. posTbl[1].x .. " to " .. posTbl[2].x) trigger.action.outText("Made Line to point " .. k , 10) _last = test.pos[k] end posTbl = {} end end makeLineFromUnitRoute('Ground-1')
  7. "Wargames - Test Server" is up with a new concept i am testing. Helicopter and Combined Arms PvPvE mission with capture the zone. You are welcome to join if you fly helicopters. Running on the PG map now.
  8. Ah.. your still trying to use the markers in the ME with code. As i said already, it seam to be bugged.. Just do it with code as i showed before.. See attached mission test-DrawingLines-.miz
  9. Can't seam to open your mission file. But do you have a unique id for all the markers ? Example if you do this: _mId1 =mist.marker.getNextId() _mId2 =mist.marker.getNextId() They will both get the same id. The getNextId() actively gets the existing id's and gets the next, so you have to create a drawing before calling it again.... You have to do it like this: -- Create Trigger Zones and get them by name here local _tZone1 = trigger.misc.getZone("L1Start") local _tZone2 = trigger.misc.getZone("L1End") local _tZone3 = trigger.misc.getZone("L2") -- Save the marker id to a variable for later _mId1 =mist.marker.getNextId() -- Create the line trigger.action.lineToAll(-1 , _mId1 , _tZone1.point , _tZone2.point , {1,0,0,1} , 1 , false) -- Save the marker id to a variable for later _mId2 =mist.marker.getNextId() -- Create the line trigger.action.lineToAll(-1 , _mId2 , _tZone2.point , _tZone3.point , {1,0,0,1} , 1 , false) You could also just put the ID's manually: -- Create Trigger Zones and get them by name here local _tZone1 = trigger.misc.getZone("L1Start") local _tZone2 = trigger.misc.getZone("L1End") local _tZone3 = trigger.misc.getZone("L2") -- Save the marker id to a variable for later _mId1 = 90001 -- Create the line trigger.action.lineToAll(-1 , _mId1 , _tZone1.point , _tZone2.point , {1,0,0,1} , 1 , false) -- Save the marker id to a variable for later _mId2 = 90002 -- Create the line trigger.action.lineToAll(-1 , _mId2 , _tZone2.point , _tZone3.point , {1,0,0,1} , 1 , false) But i would just do a integer variable that you count up every time. _midCounter = 90000 _midCounter = _midCounter + 1 _mId1 = _midCounter _midCounter = _midCounter + 1 _mId2 = _midCounter
  10. Yea, have been trying for some hours now to remove markers from ME but seam to be bugged... But if you want to do it by code you can just set out Trigger zones in ME where the lines should go and make them like this: -- Create Trigger Zones and get them by name here local _tZone1 = trigger.misc.getZone("L1Start") local _tZone2 = trigger.misc.getZone("L1End") -- Save the marker id to a variable for later _mId =mist.marker.getNextId() -- Create the line trigger.action.lineToAll(-1 , _mId , _tZone1.point , _tZone2.point , {1,0,0,1} , 1 , false) -- Remove the line later trigger.action.removeMark(_mId)
  11. Hi Right place to ask is here : https://forum.dcs.world/forum/1160-scripting-tips-tricks-issues/ Use this example : local u = mist.getUnitsInZones(mist.makeUnitTable({'[all]'}), {'KutaisiBattle'}) for i = 1, #u do local _uName = Unit.getName(u[i]) trigger.action.outText("checking ".. _uName, 2, false) end Se here : https://wiki.hoggitworld.com/view/MIST_getUnitsInZones
  12. Here is an example miz and the code: local _var = {} -- Create a drawing 1 _var.id = mist.marker.getNextId() _var.pos = mist.getGroupPoints('Ground-1') _var.mType = 'freeform' -- Add to a global variable or a table while you create the marker shapeinfo1 = mist.marker.add(_var) -- Create a drawing 2 _var.id = mist.marker.getNextId() _var.pos = mist.getGroupPoints('Ground-2') _var.mType = 'freeform' -- Add to a global variable or a table while you create the marker shapeinfo2 = mist.marker.add(_var) -- Run this where you want to delete the drawing mist.marker.remove(shapeinfo1) mist.marker.remove(shapeinfo2) From examples here: https://wiki.hoggitworld.com/view/MIST_markerAdd https://wiki.hoggitworld.com/view/MIST_markerRemove You could also use markerGet to get the drawping info if you have a name, but have not tried this. https://wiki.hoggitworld.com/view/MIST_markerGet test-Mist-CreateDeleteDrawing-.miz
  13. Not sure what you mean. Works just fine for me. See example mission and code -- Activation happens in the mission editor, but you could add it to the code. _GpName = "Ground-1" if (Group.getByName(_GpName):getUnit(1):isActive() == false) then trigger.action.outText("Group was not active, activating group :" .. _GpName , 10) elseif (Group.getByName(_GpName):getUnit(1):isActive() == true) then trigger.action.outText("Group is allready active :" .. _GpName , 10) end test-checkactivegroup.miz
  14. Sounds like you need to make a script that monitors the event kill : https://wiki.hoggitworld.com/view/DCS_event_kill And sends a text to the unit that is the killer with: https://wiki.hoggitworld.com/view/DCS_func_outTextForUnit You can search the forum for examples, but here is one:
  15. Think you are looking for CTLD for MOOSE. flightcontrol-master.github.io/MOOSE_DOCS/Documentation/Ops.CTLD.html
  16. Hi! Have not tested your code, but looks like its the ",1)" in your if statement. Should look like this: if trigger.misc.getUserFlag(5) == 5 then Here is an example i tested and works: trigger.action.setUserFlag(5, math.random(1, 2)) if trigger.misc.getUserFlag(5) == 2 then trigger.action.outText("Flag is correct!",20) else trigger.action.outText("Flag is wrong!",20) end Hope this helps
  17. Would be much more effective to have a safe zone script, like this:
  18. C-130 seam to have it:
  19. I just copy the trigger and remove the condition from the on i am testing. Other way around i set a condition that will not be possible to avoid it to trigger.
  20. As far as i remember the path you are loading file has to have \\ and not \ Like this: assert(loadfile("E:\\DCS Scripts\\Test-01.lua"))() or you can put the path in like this [[E:\DCS Scripts\Test-01.lua]] And if not done, you have to open for IO and LFS by de-sanitizeing them in disk:\DCS World OpenBeta\Scripts\MissionScripting.lua (Comment them out) sanitizeModule('io') sanitizeModule('lfs') -- Do this at own risk, since it opens DCS scripts to read and wirte to your system. (Don't run other people's missions or join mp servers with them dezanitized)
  21. That is correct. The reason it has to be like that is because the group has to exist in the game before the menu is added. This is why i used the trigger "Group alive", the script runs when the group is spawning. If you want it to add to a coalition you can use the "EVENTS" way i mentioned. Or you can make a scheduled function that check if the group has spawned. And add it if it is the first time it spawned. You'd have to track what group has gotten the menu already. Or you can go with the simple way and use something that already has been made before like this: GitHub - Markoudstaal/DCS-Simple-Spawn-Menu: A script for DCS that uses group names to create a spawn menu.
  22. If you want it on more planes just put the function "function respawnunits(_spawnType)" in it own "DO SCRIPT" before the planes reciving the menu code maybe with a "TIME MORE" at "1" sec, instead of "Group alive" (Might have to add it at mission start, but you can try with time more first.) Then add a new trigger for "each" plane that has a different group name at the start with the "Group alive" as a trigger as my examples has. For each plane the "DO SCRIPT" has the rest of the script starting with: _GpName = "Aerial-1" etc...... rest of the code... The next trigger DO SCRIPT starts _GpName = "{Carrier} F-14B" etc...... rest of the code... You can also add an array with all the names and make a function that checks that array for the names, but will not make much sense in this case, since it wont reduce the amount of code. Or you can dive in to EVENTS and add the code at birth to the planes with : DCS event birth - DCS World Wiki - Hoggitworld.com How to add events ( https://wiki.hoggitworld.com/view/DCS_func_addEventHandler ) But this is getting advanced... You can see an example of someone using it here: https://forum.dcs.world/topic/212625-lua-spawn-crew-chief-in-front-of-client/#comment-3987771 Or you can search this forum for more examples of using "Events". Should be plenty of examples. (If you search for "addEventHandler", you will get many examples for different events) Might want to take look at this forum post to for a intro to lua: https://forum.dcs.world/topic/100222-tutorial-introduction-to-lua-scripting/ Hope this helps
  23. Ah, you mean the MIST script that is added to the mission? You can just download it from the link I shared from page 1. Then add it under Triggers with a event "MISSION START" and a "DO SCRIPT FILE". The install instructions are included. (Just open my mission in the Mission editor and look how it is added) Or download it directly from here: https://github.com/mrSkortch/MissionScriptingTools/releases If you want to get the script file out of my mission, you can just change the .Miz file I added and change the extention to .zip (it's just a zip file, so it has the name "Test-RespawnUnits-RadioMenu3.zip") and get it from the mission there. Then add it as described above.
  24. Happy to help! If you are serious about learning to script in DCS i would recommend doing a LUA tutorial first like this, or just search on google for one: https://www.lua.org/pil/1.html Then go to DCS scripting here: https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation To get sub menu's you use the "missionCommands.addSubMenuForGroup" command, you can find it here: https://wiki.hoggitworld.com/view/DCS_func_addSubMenuForGroup Here is a example of multiple menus and a function that can take arguments passed from the command you press in the menu. function respawnunits(_spawnType) if _spawnType == "Unarmed" then mist.cloneInZone('Ground-1', 'TriggerZone1', true, 200, {offsetRoute = true, initTasks = true}) elseif _spawnType == "APC" then mist.cloneInZone('Ground-2', 'TriggerZone1', true, 200, {offsetRoute = true, initTasks = true}) end -- of if _spawnType == "Unarmed" then end -- of function respawnunits(_spawnType) _GpName = "Aerial-1" if _GpName ~= nil then if (Group.getByName(_GpName) and Group.getByName(_GpName):getSize() > 0) then _GpID = Group.getByName(_GpName):getID() local rootMenu = missionCommands.addSubMenuForGroup(_GpID, "My Menu") _menu1 = missionCommands.addSubMenuForGroup(_GpID, "Ground Units", rootMenu) _menu2 = missionCommands.addSubMenuForGroup(_GpID, "Unarmed", _menu1) _menu3 = missionCommands.addSubMenuForGroup(_GpID, "APC", _menu1) missionCommands.addCommandForGroup(_GpID, 'Respawn Unarmed Group!', _menu2 , respawnunits, "Unarmed") missionCommands.addCommandForGroup(_GpID, 'Respawn APC Group!', _menu3 , respawnunits, "APC") end -- of if (Group.getByName(_GpName) and Group.getByName(_GpName):getSize() > 0) then end -- of if _GpName ~= nil then Where to put the code i presume you are asking ? I just add it as a "DO Script", but you can also use a "DO SCRIPT FILE". Here is to find it in the missions: Test-RespawnUnits-RadioMenu3.miz
  25. hehe Yea, jumping right in to LUA scripting without doing a proper introduction to the language in a course or online tutorial will do that to you
×
×
  • Create New...