Jump to content

Recommended Posts

Posted

Hello !

I was looking for a script to pause the game and I found in the DCS_ControlAPI  file that there's a function "DCS.setPause(bool)" that should do what I'm looking for. However I can't find anyway to use it. Everytime I try to use DCS functions in a script the functions are not recognized. I don't know how to import them in my script but all the lfs and log functions work properly so I'm really confused here.

Thanks in advance for helping me !

  • 1 year later...
Posted (edited)

1 year + later. I have been trying to use the DCS.getMissionName() function to no avail. I suppose something is blocking it. Perhaps I have to be running as server?

Proper SSE documentation would be appreciated.

 

Edited by Zeagle

 

 

Posted (edited)
4 hours ago, Zeagle said:

I have been trying to use the DCS.getMissionName() function to no avail. I suppose something is blocking it. Perhaps I have to be running as server?

In order to access those methods, you have to run as server, and the code that executes the API must be part of the server-side scripts that run from the /Hooks directory (i.e. not the mission). Those server scripts are firewalled off from code that runs from inside a mission, and the only way these two worlds (server-side script and client mission) can communicate is via flags. So even if you are running a mission on the server, code from within that mission can't access DCS namespace methods.

4 hours ago, Zeagle said:

Proper SSE documentation would be appreciated.

Very much so, indeed.

Edited by cfrag
  • Like 1
  • Thanks 1
Posted

I believe that the 'net' Class is available in the mission scripting environment, so you should be able to access the 'DCS' class using net.dostring_in, use it like this;

net.dostring_in(<environment>, [[string]])

environment: Env to run the snippet, DCS Class is in 'mission' , if that does not work try 'gui'.

string: Actual Lua code as a string for example: "return DCS.setPause(true)"

Let me know if that helps, I'm not at home to verify and it's been a while since I tried this in this way.

Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans.

Discord: PravusJSB#9484   twitch.tv/pravusjsb  https://www.patreon.com/XSAF  https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu

Work with me on Fiverr: https://www.fiverr.com/pravusjsb

  • 2 weeks later...
Posted

@Zeagle: I'm happy to see that @PravusJSB is correct. 'gui' as environment was the secret sauce for me:

local missname = net.dostring_in("gui", "return DCS.getMissionName()")
trigger.action.outText("mission is named <" .. missname .. ">", 30)

works and will output your mission's name (minus the .miz) to your screen.

Thanks, @PravusJSB!

 

Posted

env.getMissionName() from the mission environment will return the full path and filename of the mission ( IE: C:\user\name\saved games\DCS.openbeta\Missions\mymission.miz ).

  • Thanks 1
Posted
21 hours ago, Sean B. said:

env.getMissionName() from the mission environment

That is incredibly helpful, thank you! Is there more documentation on what's available in env? I'm looking at the fine SSE doc, but did not find it there. Any pointers appreciated 🙂 

 

Posted
7 hours ago, cfrag said:

That is incredibly helpful, thank you! Is there more documentation on what's available in env? I'm looking at the fine SSE doc, but did not find it there. Any pointers appreciated 🙂 

 

It's always a very helpful thing to know what functions are available to you in the Lua environments, both Mission/Server etc. It's worth a dump of the global state of both of these every now and then because sometimes new things dont get documented or there are things in there that have never been. Doing a filtered dump of classes and functions is easy enough, drop me a line if you need help to do that.

  • Like 1

Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans.

Discord: PravusJSB#9484   twitch.tv/pravusjsb  https://www.patreon.com/XSAF  https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu

Work with me on Fiverr: https://www.fiverr.com/pravusjsb

  • Recently Browsing   0 members

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