LUA proc.wait_input() causes Orbiter to freeze instead of getting input

EarthMoon

The Earth and the Moon
Joined
Jul 12, 2022
Messages
54
Reaction score
38
Points
18
Location
Germany
Preferred Pronouns
He, His, Him or You, Your, Yours
I am trying to code an MFD with Lua. The MFD has one button for input, but rather than opening an input box, it freezes the program forever.

The MFD is properly registered in Config\MFD\ScriptMFD.cfg and ScriptMFD is enabled in the Modules tab.

This is a slightly modified and simplified version of my original MFD code because I don't want anyone to copy my original MFD:
--[[
Name = NameOfMFD
Script = MFDDebug.cfg
Key = 76 ; L key
Persist = vessel
END_PARSE
--]]

vi = vessel.get_focusinterface()

function do_something() end

function func_inp()
do_something(proc.wait_input("<Input box title>:"))
end

function buttonlabel(bt)
if bt == 0 then return "INP" else return nil end
end

function buttonmenu()
return {{l1="Input", l2="<second line>",sel="i"}},2
end

function consumebutton(bt,event)
if event%PANEL_MOUSE.LBPRESSED == PANEL_MOUSE.LBDOWN and bt == 0 then
func_inp()
return true
end
return false
end

function update(skp)
mfd:set_title(skp,"<MFD Title>")
local t = "<One line of text>"
skp:text(10,30,t,#t)
end
The code uses proc.wait_input(str) to get input. According to the Help menu, it does exactly what I want:
Screenshot (131964).png
Short: "This function opens a dialog box, waits for input and returns the input."

But when clicking INP, Orbiter immediately freezes without even asking for input, it doesn't even highlight the INP button anymore:
Screenshot (131963).png
The same also happened longer time ago when I was coding another MFD (cause: proc.wait_input()) so I had to remove the input function.

Why is Orbiter freezing instead of kindly asking for simple text input?

I'm using Orbiter 2016 with D3D9Client.
 

Gondos

Well-known member
Joined
Apr 18, 2022
Messages
233
Reaction score
272
Points
78
Location
On my chair
I am trying to code an MFD with Lua. The MFD has one button for input, but rather than opening an input box, it freezes the program forever.

The MFD is properly registered in Config\MFD\ScriptMFD.cfg and ScriptMFD is enabled in the Modules tab.

This is a slightly modified and simplified version of my original MFD code because I don't want anyone to copy my original MFD:

The code uses proc.wait_input(str) to get input. According to the Help menu, it does exactly what I want:
View attachment 37683
Short: "This function opens a dialog box, waits for input and returns the input."

But when clicking INP, Orbiter immediately freezes without even asking for input, it doesn't even highlight the INP button anymore:
View attachment 37682
The same also happened longer time ago when I was coding another MFD (cause: proc.wait_input()) so I had to remove the input function.

Why is Orbiter freezing instead of kindly asking for simple text input?

I'm using Orbiter 2016 with D3D9Client.
Looking at the code, I think that this function only works in scenario script and not in MFD/ScriptVessel context.
 

EarthMoon

The Earth and the Moon
Joined
Jul 12, 2022
Messages
54
Reaction score
38
Points
18
Location
Germany
Preferred Pronouns
He, His, Him or You, Your, Yours
Looking at the code, I think that this function only works in scenario script and not in MFD/ScriptVessel context.
But how else can I create an input box like this one (preferably in Lua without the use of C(++))?
Screenshot (132105).png
 

EarthMoon

The Earth and the Moon
Joined
Jul 12, 2022
Messages
54
Reaction score
38
Points
18
Location
Germany
Preferred Pronouns
He, His, Him or You, Your, Yours
Ok.... seems like I have to workaround this restriction with the use of a small .exe program... (the rest of the MFD is coded in Lua and porting this MFD to an MFD .dll and setting up a compiler requires a lot more effort than using os.popen and Python with a py to exe packager). Thx!
 
Last edited:

Gondos

Well-known member
Joined
Apr 18, 2022
Messages
233
Reaction score
272
Points
78
Location
On my chair
Ok.... seems like I have to workaround this restriction with the use of a small .exe program... (the rest of the MFD is coded in Lua and porting this MFD to an MFD .dll and setting up a compiler requires a lot more effort than using os.popen and Python with a py to exe packager). Thx!
There's a new PR to add support for this in OpenOrbiter, just waiting for an answer regarding documentation before setting it as ready for merge.
 

EarthMoon

The Earth and the Moon
Joined
Jul 12, 2022
Messages
54
Reaction score
38
Points
18
Location
Germany
Preferred Pronouns
He, His, Him or You, Your, Yours
There's a new PR to add support for this in OpenOrbiter, just waiting for an answer regarding documentation before setting it as ready for merge.
Ok, but I want my MFD to be for Orbiter 2016 because not everyone is using OpenOrbiter and I don't want (and possibly almost no one else wants) to download an unofficial/a new Orbiter version just for one MFD. I already have two Orbiter versions (2016 and 2010-P1) although I nowadays only use 2016 and I don't need nor want a third one yet.
(Site note: Using an own .exe program additionally allows for a more beautiful custom UI rather than Orbiter's default old looking grey text boxes)
 

Gondos

Well-known member
Joined
Apr 18, 2022
Messages
233
Reaction score
272
Points
78
Location
On my chair
Because you don't want to does not mean nobody wants to. I cannot travel back in time and add the API you require in older versions, I can only make it available in future versions.
You're welcome
 
Top