Jump to content

Loading a thirdparty external lua module for GameGUI use (example files inside)


Drexx

Recommended Posts

I am trying to load the luasql module so that I can write a proper frontend website and have communications between website and server, also log all the events in the database.

 

I am using a 64bit compiled version of luasql (for lua 5.1)

 

The files to access the example are here:

https://www.dropbox.com/sh/hjk9h2c4j6elsfw/AAABBJM5cTUicb5hlvF_R8lqa?dl=0

 

You put the luasql folder in DCS\bin (so it can get access to the library)

and run the dbTestGameGUI.lua from the DCS\bin

 

lua dbTestGameGUI.lua

 

C:\Program Files\Eagle Dynamics\DCS World\bin>lua "c:\Users\andre\Saved Games\DCS\Scripts\DatabaseTestGameGUI.lua"
Event: HAHAHA, Time: 2016-11-04 03:59:20
Event: YESSSSS, Time: 2016-11-04 03:59:20
Event: WEEEENER, Time: 2016-11-04 04:18:20
Event: DCS WROTE TO SERVER!, Time: 2016-11-04 13:34:22

 

it writes to the database and reads from it, this WORKS!

 

but with luarun.exe

 

luarun dbTestGameGUI.lua

C:\Program Files\Eagle Dynamics\DCS World\bin>luarun "c:\Users\andre\Saved Games\DCS\Scripts\DatabaseTestGameGUI.lua"
can't load c:\Users\andre\Saved Games\DCS\Scripts\DatabaseTestGameGUI.lua: [string "c:\Users\andre\Saved Games\DCS\Scripts\DatabaseTestGameGUI.lua"]:2: attempt to index global 'luasql' (a nil value)

 

it has trouble

 

Just an example of loading an external module would be fun or an explanation of the limitations of DCS + GameGUI + loading external modules. Lua.exe runs this code perfectly so theres definitely a different here somewhere

 

Being able to load an external module from GameGUI can open our server up to a TON of possiblities!

 

Thanks!

 

-Drex

-=16AGR=- US East Dynamic Caucasus

Developer of DDCS MP Engine, dynamicdcs.com

https://forums.eagle.ru/showthread.php?t=208608

Link to comment
Share on other sites

Play around luasql and servman on DCSW 1.2.6 years ago, and build an running statistics system

 

It seems that your require("luasql") failed,

check package.path and package.cpath and luasql staffs in proper directory

 

My code:

-- all db operations(create/update/delete/insert) goes into db_ops.lua

 

log("load db_ops.lua ...")

package.path = package.cpath..";.\\Scripts\\Luasql\\?.lua;"

package.cpath = package.cpath..";.\\Scripts\\\\?.dll;"

mysqlenv = nil

mysqlcon = nil

db_initOK = false

luasql = nil

luasql = require "luasql.mysql"

if luasql == nil then

log('luasql loaded NULL!')

else

dofile(rootpath ..'/db_ops.lua')

end

 

 

-- in db_ops.lua

function db_Open()

if ( luasql == nil ) then return end

mysqlenv = luasql:mysql()

if ( mysqlenv ~= nil ) then

-- 数据库名称, 用户名, 密码, 数据库服务器IP [,数据库端口]

mysqlcon = mysqlenv:connect("db_DCSW","db_user","xxxxxx","nnn.nnn.nnn.nnn", nnnn)

if ( mysqlcon == nil ) then

mysqlenv:close()

else

db_initOK = true

end

end

end


Edited by L0op8ack
Link to comment
Share on other sites

  • Recently Browsing   0 members

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