-
Posts
386 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Everything posted by Kanelbolle
-
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)
-
DCS get table of all units in lua (using MIST)
Kanelbolle replied to Nilusink's topic in Mission Editor
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 -
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
-
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
-
Think you are looking for CTLD for MOOSE. flightcontrol-master.github.io/MOOSE_DOCS/Documentation/Ops.CTLD.html
-
I cant get trigger.misc.getUserFlag to work
Kanelbolle replied to Zachc12385's topic in Scripting Tips, Tricks & Issues
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 -
C-130 seam to have it:
-
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.
-
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)
-
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.
-
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
-
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.
-
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
-
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
-
A better way if you are planing on adding it to a multiplayer game and a specific group would be to add it when the group i alive. Remember to change the group name in the script to your missions group name: _GpName = "Aerial-1" See the example .miz file. Test-RespawnUnits-RadioMenu2.miz
-
Here is a easy example how to do it. I just do this: 1. Load MIST first 2. Load the script i made straight in to the mission editor with a "Do Script" The menu will be added 5 sec in to the mission to the group. Just note that in this example the Group (you) have to spawn before 5 sec to it to work. The code is a simple example, it can be better and expanded but is just for showing the idea how it can be done: function respawnunits() mist.cloneInZone('Ground-1', 'TroggerZone1', true, 200, {offsetRoute = true, initTasks = true}) end _GpName = "Aerial-1" if _GpName ~= nil then -- if (Group.getByName(_GpName) and Group.getByName(_GpName):getSize() > 0) and (Group.isExist(gp) == true) then if (Group.getByName(_GpName) and Group.getByName(_GpName):getSize() > 0) then _GpID = Group.getByName(_GpName):getID() local rootMenu = missionCommands.addSubMenuForGroup(_GpID, "My Menu") missionCommands.addCommandForGroup(_GpID, 'Respawn Group!', rootMenu , respawnunits, nil) end -- of if (Group.getByName(_GpName) and Group.getByName(_GpName):getSize() > 0) and (Group.isExist(gp) == true) then end -- of if _GpName ~= nil then Test-RespawnUnits-RadioMenu1.miz
-
No, MIST does not have a command to add a spawn to the Radio menu. All available MIST commands are listed here: Mission Scripting Tools Documentation - DCS World Wiki - Hoggitworld.com But there is simply no need to have a dedicated MIST function to this since its quite easy in vanilla scripting or even just right in the editor. For example if you just crate a function called "spawnenemy", you can just add it to your plane using your group ID with this command: missionCommands.addCommandForGroup(groupId, 'Name in the menu', nil , spawnenemy) I can create quick example mission for you when i get home if you want more info, but have to wait a few hours until i get home
-
Hi! You can find the Forum page for them here: The Github link is on the first page of each forum page. I have no experience with Moose, so can not say how easy it is. Have used MIST and it is quite easy to spawn units with. The documentation is also quite good, example if you want to keep cloning a group in a zone you can use this (Se bottom for other types of spawns): MIST cloneInZone - DCS World Wiki - Hoggitworld.com Hope this helps
-
New in Scripting, Count online clients
Kanelbolle replied to Marcos Paes's topic in Scripting Tips, Tricks & Issues
Hi again. If you simply want the amount of players in the mission you don't need to do a loop like the example. Would refrain from using numbers for flag names to, gets confusing fast. local bluePlayers = coalition.getPlayers(2) -- local currentFlagValue = trigger.misc.getUserFlag("PlayerAmount") --Not needed trigger.action.setUserFlag("PlayerAmount", #bluePlayers) env.info("Amount of players: " .. #bluePlayers) -
New in Scripting, Count online clients
Kanelbolle replied to Marcos Paes's topic in Scripting Tips, Tricks & Issues
Hi! You can use coalition.getPlayers for this. See the example on hoggit. https://wiki.hoggitworld.com/view/DCS_func_getPlayers Then sett your flag with trigger.action.setUserFlag https://wiki.hoggitworld.com/view/DCS_func_setUserFlag Hope this helps -
The filter system of slots is in 2.9. The select slots directly on the map and the dynamic slot system has not been released yet.
-
Just open the miz file wilth your zip file program (rename the file from .miz to .zip) of choice and then open the mission files. Remove the required pack. It is close to the top of the file. Then change the .zip file back to .miz.
-
Look here: The place in the action list where "immortal" is makes a difference. If it's not nr 1 it will not work. Players should not be able to damage the unit if it is sett correctly.