Jump to content

sprhawk

Members
  • Posts

    1
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I don't know whether here is the right place to discuss lua script. I'm new to DCS lua scripting system and 1.2.10 is my first attempt to use lua scripts for DCS. I don't know whether following problems are due to 1.2.10 or existed for some time, but I don't think the current Wiki or Export.lua statements are correct. 1. DCS doesn't require Config/Export/Config.lua and set EnableExportScript = true to enable export.lua. Just copy Scripts/Export.lua as a reference implementation to $USER/Saved Games/DCS/Scripts/Export.lua and the script will be loaded during start of a mission 2. If need to import custom module into Export.lua environment, we need to specify the $USER/Saved Games/DCS/Scripts, eg, many plugins ( iControl or TacView) added one line to the end of Export.lua: dofile(".\\Scripts\\tacview.lua") But now we need current path: local lfs = require("lfs") dofile(lfs.writedir() .. "Scripts\\tacview.lua") 3. About importing LuaSocket In official LuaSocket document, the directory structure is like: <LDIR>/compat-5.1.lua <LDIR>/ltn12.lua <LDIR>/socket.lua <CDIR>/socket/core.dll <LDIR>/socket/http.lua <LDIR>/socket/tp.lua <LDIR>/socket/ftp.lua <LDIR>/socket/smtp.lua <LDIR>/socket/url.lua <LDIR>/mime.lua <CDIR>/mime/core.dll So we can require("socket.url") etc. However DCS puts LuaSocket's *.lua files under LuaSocket directory so that we cannot just require("socket.url") directly The package.path shows: ;.\?.lua;D:\Program Files\Eagle Dynamics\DCS World\bin \lua\?.lua;D:\Program Files\Eagle Dynamics\DCS World\bin\lua\?\init.lua;D:\Progr am Files\Eagle Dynamics\DCS World\bin\?.lua;D:\Program Files\Eagle Dynamics\DCS World\bin\?\init.lua;C:\Program Files (x86)\Lua\5.1\lua\?.luac There isn't a load path to the LuaSocket, so if we need the module under LuaSocet, we need: local lfs = require("lfs") programPath = lfs.realpath(lfs.currentdir()) package.path = programPath .. "LuaSocket\\?.lua;" .. package.path require("socket") require("mime") require("ltn12") require("url") require("http") However, because lua-socket.dll is in package.cpath, if use socket.core directly, just call require("socket.core") 5. if you want to quickly test your lua scripts without restarting DCS missions, you can use bin\luarun.exe to run your lua script file. 6. in CS World\Config\main.cfg, set show_debug_output_console = true ( the last line in mine ) will show up a console window to show debug (lua stdout) output log
×
×
  • Create New...