Jump to content

Can a lua script be executed by a button press?


Go to solution Solved by Chump,

Recommended Posts

Posted (edited)

Well, the first step would be to rewrite it in LUA (which is quite different from JavaScript), and make it Chrome-independent, since DCS doesn't talk to Chrome. Once you get that small matter of programming done, I think you should be able to use training commands that look for a specific button press.

EDIT: In case my sarcasm was too subtle, the first thing you should do is take a good hard look at the feasibility of the whole idea. The first two steps in particular.

Edited by Dragon1-1
Posted (edited)

Adding to what @Dragon1-1 said, since it was written as a Chrome plug-in, it will not be a direct port. Although it is possible to trigger LUA with a new key/button press using listen_command(), the next hurdle would be that DCS does not have native voice recognition to generate the input to send to ChatGPT.

Edited by Chump
lol @ ChatGPT
Posted

Yeah, that's kind of what "making it Chrome-independent" was about. Also very much nontrivial, since Chrome is how it talks to ChatGPT in first place. It seems to use Windows dictation feature, so at least that shouldn't depend on DCS. Indeed, it makes no sense for DCS to ever make its own voice recognition, seeing as Windows already handles that, and programs like VA just make macros based on it. 

  • Like 1
  • Solution
Posted

@skypickle You would add your LUA script into the creators table in device_init.lua. Your script would then call the listen_command(), and you would trigger it with an input definition. You can see how it is done by looking at other LUAs that are called from device_init.lua.

For example:

-- devices.lua
devices["newThing"] = counter()

-- device_init.lua
creators[devices.newThing] = {
	"avLuaDevice",
	LockOn_Options.script_path .. "newThing.lua"
}

-- newThing.lua
GetSelf():listen_command(1234)

-- default.lua
{ down = 1234, name = _("My New Thing Command"), category = _("MODS") },

There is a bit more to it like defining the functions/logic that is triggered, but this should get you started.

Posted
On 2/26/2023 at 8:41 PM, Dragon1-1 said:

Well, the first step would be to rewrite it in LUA (which is quite different from JavaScript), and make it Chrome-independent, since DCS doesn't talk to Chrome. Once you get that small matter of programming done, I think you should be able to use training commands that look for a specific button press.

EDIT: In case my sarcasm was too subtle, the first thing you should do is take a good hard look at the feasibility of the whole idea. The first two steps in particular.

 

  It does not seem "crazy", it depends on what you want to do and obtain. You can execute any executable or batch in windows in an lua by using  os.execute() . This is what I use in the encyclopedia that I have slightly "tuned" to be able to go directly to detailed info on the displayed plane/object in wikipedia by a push on a button, I have also another button to go directly to corresponding DCS forum topics....         

  • Like 1
Posted

Interesting. If you have that part figured out, it can be done. Although, worth noting that a JavaScript plugin is not an executable, but if you can run Chrome from DCS (and don't mind the waste of memory), you should be able to do that.

  • Recently Browsing   0 members

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