Jump to content

Mission script error: attempt to index global 'DCS' (a nil value). What is going on?


Go to solution Solved by cfrag,

Recommended Posts

Posted

Recently I've been in a project using deep learning in air combat. And as a crazy player of DCS, it undoubtfully became my choice for simulation. In order to get mission records automatically, the mission needs to unpause itself when started, and I'm stuck on this step.

I check the trigger in mission editor carefully and there is no action to unpause mission. So I try to write a lua script and I checked the official api file in \DCSWorld\API. To my pleasure, I found DCS.setPause() function. However, when I enter it in mission editor and start the mission, an error pop up, saying "attempt to index global 'DCS' (a nil value)". I have tried other functions in DCS api and some lua official api, for example io, and the error still occur (when using io api, the error become "attempt to index global 'io (a nil value)").  It seems that the mission script environment in DCS doesn't contain such api, so lua script cannot use those functions. But in "DCS_ControlAPI" file, it is clearly stated that those api are contained and ready for usage.

How can I solve this error? Or are their other ways to automatically skip pause when mission starts? 

  • Solution
Posted
3 hours ago, JedimasterLu said:

when I enter it in mission editor and start the mission, an error pop up, saying "attempt to index global 'DCS' (a nil value)".

That is mainly because the "DCS" api is available only to the server part of the game, not the mission itself. DCS separates the server and client parts of the game, and each part has access to different API. 

3 hours ago, JedimasterLu said:

some lua official api, for example io

For security reasons, some parts of the Lua API (namely io, lfs and os) are disabled. If enabled for all DCS installation, malicious people would be able to use missions to attack your computer. So each and every DCS installation is 'sanitized', meaning that io, lfs and os are disabled for Lua, and it requires your active participation (you need to edit a text file in DCS) to change that. To get good instructions on how to do that, you can google 'unsanitize DCS' or similar.

3 hours ago, JedimasterLu said:

Or are their other ways to automatically skip pause when mission starts? 

Start the mission as multiplayer (server), and click the "Resume on Load" radio button in Advanced Options.

  • Thanks 1
Posted
54 minutes ago, cfrag said:

Start the mission as multiplayer (server), and click the "Resume on Load" radio button in Advanced Options.

Thanks a lot! It finally works!

55 minutes ago, cfrag said:

If enabled for all DCS installation, malicious people would be able to use missions to attack your computer.

I see. Haven't think of that in security aspect before lol.

  • Recently Browsing   0 members

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