Jump to content

Is "get_base_data" without creating a device possible??


Recommended Posts

Hi guys.

I've been fiddling around with a little script, that should only fetch the base data "get_base_data()" from DCS and store it in a variable.

I don't want to do anything fancy, right now, just that.

As a way of knowing if it works, I did put the "Print_message_to_user" in the script as well.

It looks like this:


local Get_System_info     = GetSelf()
local dev                 = GetSelf()
local update_time_step    = 0.01
local sensor_data         = get_base_data()
  update                      = function ()
    ActualMachSF              = sensor_data:getMachNumber()
    ActualGeforceSF           = sensor_data:getVerticalAcceleration()
    print_message_to_user (ActualMachSF)
    print_message_to_user (ActualGeforceSF)
  need_to_be_closed = false


When I start it via "dofile" from the entry.lua I get an error saying:

attempt to call global 'GetSelf' (a nil value)


If I erase the first 2 lines, the log says:

attempt to call global 'get_base_data' (a nil value)


How can I "connect" my script to the "output"-side of DCS?

Any help would be greatly apreciated :-)

Link to comment
Share on other sites

Well guys, today it dawned on me, that the problem is, that I call my script (as above) from the entry.lua or from the aircraft.lua.

Those files are loaded right at the beginning when DCS initializes itself. It is not so hard to understand, that the above mentioned global variables/functions "get_base_data()"

return a nil value, because there is just nothing to return, or, more precise, those functions/variables are not there when the script is executed.

I tried a little workaround with:


    local function LoGetSelfPlane()
    local selfdata  =   LoGetSelfData()
    if    selfdata  ==  nil then selfdata = "XXX" end
    return selfdata.Name


I switched to the export.lua, since it might be, that FC3 modules hide their data from "get_base_data"...

Don't know for sure, but in the above way, I don't get an error message ind those functions.


I do get the same error in the:




function, which is a bit annoying...well, I'm at it and will see, how it works...


If anyone has any suggestions, I'd be quite happy to be pointed in the right direction...

Link to comment
Share on other sites

  • 1 month later...

Hey PeeJott, this is Immortality from Discord, devices must contain a ID in the device.lua script and be given a value within the devices table in the device_init.lua. For example, your script could be declared this way.

-- devices.lua
devices["MYDEVICE"] = 1 -- or counter() should you have this function defined
-- device_init.lua
devices[MYDEVICE] = {"avLuaDevice", LockOn_Options.script_path.."SYSTEMS/mydevice.lua"}

Additionally make sure you have the following code in you entry.lua and mainaircraft.lua

-- entry.lua
make_flyable('Aircraft', current_mod_path..'/Cockpit/Scripts/', 
	nil, current_mod_path..'/Scripts/Comm.lua') -- makeflyable(aircraft_name, script_path, nil (no efm), comm_script)
-- main_aircraft.lua
aircraft_table = {
	HumanCockpit 		= true, -- these need to be set
	HumanCockpitPath    = current_mod_path..'/Cockpit/Scripts/',



Modules: Mig-21Bis, F-14A&B, Flaming Cliffs 3, Ka50, Mi-24P , & Mig-23MLA


AMD Ryzen 5 1600 @3.6GHz, 16GB 3200MHz, MSI GAMING X GTX1060 6GB, 256GB SSD, T1600m FCS, TrackIR 5



Link to comment
Share on other sites

  • 2 weeks later...

Hi @brianiscool

Thanks a lot for your answer....cool somebody replying. Sadly, the idea was already scrapped since it was an idea to change aerodynamics_table of SFM "on the fly".

The idea was to throw like 6 aerodynamic tables into the aircraft.lua and with a function like if altitude higher than x and lower than y, choose table A, if altitude higher z and lower than w choose table B and so forth.

The idea behind it was to get the plane to behave exactly as it should be in the certain altitudes.

The same idea (which would've been an addon) would work for AoA...but since a lot of guys said, that changing SFM tables on the fly is not possible, since SFM-tables are loaded at the very beginning into DCS and can't be modified afterwards...well the idea was not so interesting anymore ;-)

Link to comment
Share on other sites


  • Recently Browsing   0 members

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