Jump to content

Export Script that is run on "Plane Selected"


Recommended Posts

Posted

I couldn't find any function for the export script (like "LuaExportStart"), that is run when you've selected a plane (like "OnSimulationStart").

So to get the players plane for now, I do the following:

function LuaExportActivityNextEvent(t)
	local tNext = t

	if OutputFile then
		local OwnAirframe = LoGetSelfData()
		
		OutputFile:write(string.format("Name = %s\n", OwnAirframe.Name))
	end

	tNext = tNext + 10.0
	return tNext
end

Is there any better way to do this?

Thanks!

OpenXR-Switcher: to easily switch OpenXR runtimes as well as en-/disable API layers

Kneeboard-Picture-Viewer: my own take on a Kneeboard for a 2nd monitor, that acts more or less as a better picture viewer.

F-15CX mod: my own take on a simple F-15C upgrade

English Avionics with Native Betty: you can now have English HUD on non US planes and still hear the native Betty!

Posted

Hm, I just came to realize, this only works if you have only the "Player" aircraft. If you can choose (ie. it's set to "Client"), the Name attribute is NIL. So this script doesn't really always work...

OpenXR-Switcher: to easily switch OpenXR runtimes as well as en-/disable API layers

Kneeboard-Picture-Viewer: my own take on a Kneeboard for a 2nd monitor, that acts more or less as a better picture viewer.

F-15CX mod: my own take on a simple F-15C upgrade

English Avionics with Native Betty: you can now have English HUD on non US planes and still hear the native Betty!

Posted (edited)

Okay, I've finally figured out how to use Hooks.

BUT: I haven't found a way yet to determine the player aircraft when in Singleplayer where you can choose your aircraft/faction.

Because "onSimulationStart" gets called before the player chooses the aircraft ("Choice of role" screen) and thus any player/aircraft data is NIL.

And "onPlayerChangeSlot" seems to be purely a Multiplayer function, as it's never called in SP.

How would I hook into that? How'd I get the aircraft in such multi-role SP missions?

Cheers!

Edited by dlder

OpenXR-Switcher: to easily switch OpenXR runtimes as well as en-/disable API layers

Kneeboard-Picture-Viewer: my own take on a Kneeboard for a 2nd monitor, that acts more or less as a better picture viewer.

F-15CX mod: my own take on a simple F-15C upgrade

English Avionics with Native Betty: you can now have English HUD on non US planes and still hear the native Betty!

Posted

"onPlayerStart(id)" and "onGameEvent" doesn't seem to get called either, but maybe I can work with "onSimulationResume"...

 

OpenXR-Switcher: to easily switch OpenXR runtimes as well as en-/disable API layers

Kneeboard-Picture-Viewer: my own take on a Kneeboard for a 2nd monitor, that acts more or less as a better picture viewer.

F-15CX mod: my own take on a simple F-15C upgrade

English Avionics with Native Betty: you can now have English HUD on non US planes and still hear the native Betty!

Posted (edited)
5 hours ago, dlder said:

"onPlayerStart(id)" and "onGameEvent" doesn't seem to get called either, but maybe I can work with "onSimulationResume"...

 

You can use: onShowBriefing()

It will be shown when the user has already selected the aircraft and advanced. Briefing is shown at that moment

Edited by okopanja
  • Thanks 1
Posted

Thanks mate, really appreciate it! I've now been using "onSimulationResume" which works great; in both SP scenarios as well as in MP 🙂

I didn't find "onShowBriefing" on hoggitworld... so where do you look for these functions? Is there a documentation somewhere inside the DCS installation or something?

 

OpenXR-Switcher: to easily switch OpenXR runtimes as well as en-/disable API layers

Kneeboard-Picture-Viewer: my own take on a Kneeboard for a 2nd monitor, that acts more or less as a better picture viewer.

F-15CX mod: my own take on a simple F-15C upgrade

English Avionics with Native Betty: you can now have English HUD on non US planes and still hear the native Betty!

Posted
2 minutes ago, dlder said:

Thanks mate, really appreciate it! I've now been using "onSimulationResume" which works great; in both SP scenarios as well as in MP 🙂

I didn't find "onShowBriefing" on hoggitworld... so where do you look for these functions? Is there a documentation somewhere inside the DCS installation or something?

 

There is no documentation, but it's there in ED's code. 😉

I faced the same issue and resolved it with onSimulationResume, but that was before I found out onShowBriefing. I will probably switch to the later, since it appears to be more reliable.

  • Like 1
Posted (edited)

Ok... I've 2.9beta installed and searched the scripts folder for that function but couldn't find it.

And if I try to use it as a callback function, it doesn't work either... how are you using/implementing that function if I might ask? 'cause it doesn't seem to be a HOOK function.

edit: ok, found it: GameGUI.lua in MissionEditor

Edited by dlder

OpenXR-Switcher: to easily switch OpenXR runtimes as well as en-/disable API layers

Kneeboard-Picture-Viewer: my own take on a Kneeboard for a 2nd monitor, that acts more or less as a better picture viewer.

F-15CX mod: my own take on a simple F-15C upgrade

English Avionics with Native Betty: you can now have English HUD on non US planes and still hear the native Betty!

Posted (edited)

So, I've tried it and here's what I found out:

onSimulationStart()

  • only works in SP with aircraft set to "Player"

onShowBriefing()

  • only works in SP with aircraft set to "Client"

onPlayerChangeSlot(id)

  • only works in MP

onSimulationResume()

  • works everywhere / always
Edited by dlder

OpenXR-Switcher: to easily switch OpenXR runtimes as well as en-/disable API layers

Kneeboard-Picture-Viewer: my own take on a Kneeboard for a 2nd monitor, that acts more or less as a better picture viewer.

F-15CX mod: my own take on a simple F-15C upgrade

English Avionics with Native Betty: you can now have English HUD on non US planes and still hear the native Betty!

Posted
1 minute ago, dlder said:

So, I've fully tried it and here's what I found out:

onSimulationStart()

  • only works in SP with aircraft set to "Player"

onShowBriefing()

  • only works in SP with aircraft set to "Client"

onPlayerChangeSlot(id)

  • only works in MP

onSimulationResume()

  • works everywhere / always

I would write 3rd function with the real logic and call it from onShowBriefing/onPlayerChangeSlot.

onSimulationResume gets triggered in other situations as well. E.g. pause/resume

Also, check how it works in:

-SP

- MP on your own PC

- dedicated server (with paused and unpaused mission)

If it is not a secret: what are you trying to do?

Posted

A very simple and quick task: export the type of the players plane, so that I can setup my VoiceAttack profile for a specific airframe (walking through checklists and maybe specific "AI Comms"

OpenXR-Switcher: to easily switch OpenXR runtimes as well as en-/disable API layers

Kneeboard-Picture-Viewer: my own take on a Kneeboard for a 2nd monitor, that acts more or less as a better picture viewer.

F-15CX mod: my own take on a simple F-15C upgrade

English Avionics with Native Betty: you can now have English HUD on non US planes and still hear the native Betty!

Posted
51 minutes ago, dlder said:

A very simple and quick task: export the type of the players plane, so that I can setup my VoiceAttack profile for a specific airframe (walking through checklists and maybe specific "AI Comms"

Interesting, e.g. I personally wanted to switch my VKB profile on airframe change, except for now that software does not allow it yet. (trying to get them to listen and provide at least command line tool).

  • Like 1
  • Recently Browsing   0 members

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