Wayan Posted February 18, 2019 Share Posted February 18, 2019 (edited) Hi there, maybe i absolutely on the wrong track, but is there a way to add a trigger with a lua script? background, we like to fly with music, so i added various radio events for the F10 menu by lua. Now it would be nice to set the triggers with a lua script because it would be usable in another mission. so... is there a way? Greetings Wayan Edited February 21, 2019 by Wayan Link to comment Share on other sites More sharing options...
dark_wood Posted February 18, 2019 Share Posted February 18, 2019 Take a look here: https://forums.eagle.ru/showthread.php?t=124546 I think you can try Erforces's code: local M1 = missionCommands.addSubMenu("Level 1", nil) local M2 = missionCommands.addSubMenu("Level 2", M1) missionCommands.addCommand("COMMAND SUB2", M2,function() trigger.action.setUserFlag(1, true) end, nil) missionCommands.addCommand("COMMAND SUB1", M1,function() trigger.action.setUserFlag(2, true) end, nil) Link to comment Share on other sites More sharing options...
Wayan Posted February 19, 2019 Author Share Posted February 19, 2019 Thanks dark_wood, but this is what I already have, no it would be a nice way if you could add the trigger, triggered by this flag, directly to the lua. something pseudo: if(flag = 1) soundtoblue(music.ogg) } problem is, i think this has to be added to some kind of eventlistener, but i didn't find anything in the world entity, only thing i found is setting flags, not getting or reacting to them. Greetings Wayan Link to comment Share on other sites More sharing options...
dark_wood Posted February 19, 2019 Share Posted February 19, 2019 Maybe something like this: if trigger.misc.getUserFlag(1) == 1 then soundtoblue(music.ogg) end Link to comment Share on other sites More sharing options...
dark_wood Posted February 19, 2019 Share Posted February 19, 2019 (edited) And to be sure, trigger first a message: if trigger.misc.getUserFlag(1) == 1 then trigger.action.outText('Good job!' , 10) end Dcumentation: https://wiki.hoggitworld.com/view/DCS_func_getUserFlag Edited February 19, 2019 by dark_wood Link to comment Share on other sites More sharing options...
A101Wayz Posted February 20, 2019 Share Posted February 20, 2019 Did you get the chance to try out that solution? This should do the trick without the need to mess with user flags (provided you have a function "soundtoblue" that works. local function PlayMusic(params) soundtoblue(params.track) end local M1 = missionCommands.addSubMenu("Play Music", nil) missionCommands.addCommand("Play Track 1", M1,PlayMusic, {track = "music1.ogg"}) missionCommands.addCommand("Play Track 2", M1,PlayMusic, {track = "music2.ogg"}) missionCommands.addCommand("Play Track 3", M1,PlayMusic, {track = "music3.ogg"}) Wayz Out Intel Core i9 9900K | ASUS ROG Strix Z390E Gaming MB | G.Skill Ripjaws V 32gb DDR4-3200 | GeForce RTX 2080 Ti | Samsung 970 EVO Plus NVMe HTC Vive Pro VR | Logitech G x56 HOTAS | Logitech G PRO Pedals Link to comment Share on other sites More sharing options...
Wayan Posted February 21, 2019 Author Share Posted February 21, 2019 (edited) Thanks @ A101Wayz, as this is the solution that worked flawlessly for me :) I didn't think of providing a local funktion for playing, only flags in my head :) And no need for a dedicated playing function :) trigger.action.outSoundForCoalition(...) is enough :) Greetings Wayan Edited February 21, 2019 by Wayan Link to comment Share on other sites More sharing options...
Recommended Posts