Jump to content

Add Trigger by lua


Wayan

Recommended Posts

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 by Wayan
Link to comment
Share on other sites

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

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

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

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 by Wayan
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...