Jump to content

a_do_script() return value pass-thru mangled with DCS 2.9.18.12722


Recommended Posts

Posted (edited)

DCS 2.9.18.12722 re-introduces a_do_script() and a_do_file() return value pass-thru, after a previously failed attempt:

Quote

Scripting API. Added possibility to pass args and return values from mission scripting a_do_script() and a_do_file() APIs.

Unfortunately, return values are only partially passed thru. Specifically, the last return value is always dropped. That results in no return value being passed thru if a single return value is used:

return a_do_script("return 42")

Yields a nil return value. %DCS_INSTALL_DIR%/API/Sim_ControlAPI.html gives a more complex example with multiple return values being passed thru:

-- original example in Sim_ControlAPI.html
local a, b, c = a_do_script("return 1,2,3")
-- added return code for illustration
return {a = a, b = b, c = c}

It results in the following return value (instead of a=1,b=2,c=3):

{
	["a"] = nil, -- added for illustration purposes
	["b"] = 1,
	["c"] = 2
}

Steps to Reproduce

Run the above code snippets in the mission Lua state via a DCS Lua console of your choice, e.g., my WebConsole.lua. Note that this will require modification of autoexec.cfg to provide access to the mission state via net.dostring_in() from the userhooks state.

 

P.S.: This could have been easily caught automatically by a very simple unit test. I'd like to encourage ED to start using these tests to avoid delivering broken releases. As this is not the first occurrence of broken a_do_script() code, it is apparent that your current testing strategies are insufficient.

Edited by Actium
  • Recently Browsing   0 members

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