Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: a3dcreator on April 23, 2018, 03:55:53 PM

Title: how can i use my own lua libraries in mach 4 ?
Post by: a3dcreator on April 23, 2018, 03:55:53 PM
i want to use some linear algebra libraries inside of my lua scripts in MACH4.
Is this possible? if so is there a specific directory where i have to save these libraries in order for lua to import them properly.

help appreciated.
Title: Re: how can i use my own lua libraries in mach 4 ?
Post by: joeaverage on April 23, 2018, 09:13:59 PM
Hi,
way above my paygrade...ah, hang on I don't get paid...LOL.

If I understand correctly Lua is a plugin to the core C/C++ program and thats where a library would normally be.
That would in turn require access to the plugin which is NFS property. They might be agreeable to a library addition.

Could you program (in Lua) the components/functions you want and put them in a module? Daz has done a good
video on modules in recent times.

Craig
Title: Re: how can i use my own lua libraries in mach 4 ?
Post by: a3dcreator on April 23, 2018, 09:30:10 PM

yes i figured i could do that. but i was trying to avoid all the work. there are functions that reference other functions and so on...
I would have to also make those dependencies again. or just simply rewrite the functions so they fit into this ideology.

thanks for the response!
Title: Re: how can i use my own lua libraries in mach 4 ?
Post by: joeaverage on April 23, 2018, 10:29:42 PM
Hi,
as far as I know all the standard libraries of Lua 5.2 are implemented.
Is the library you have have the same form as the standard libraries?

Craig
Title: Re: how can i use my own lua libraries in mach 4 ?
Post by: a3dcreator on April 23, 2018, 10:38:14 PM
Here is a possible library i would like to use.
http://scilua.org
Title: Re: how can i use my own lua libraries in mach 4 ?
Post by: joeaverage on April 23, 2018, 11:10:00 PM
Hi,
very kool! I'm not sure but LuaJIT is different to plain Lua.
Whether there is sufficent compatability to include it as a library in plain Lua I don't know.

How about putting LuaJIT in a module of its own? It would give you control of libraries etc without
bugging the hell out of NFS.

Craig
Title: Re: how can i use my own lua libraries in mach 4 ?
Post by: rhtuttle on April 24, 2018, 10:39:13 AM
any lua/dll module/library that is located in the 'modules' directory that conforms to lua 5.2 can be loaded at run load time, see the screen load script:

--Master module
package.loaded.MasterModule = nil
mm = require "mcMasterModule"
   
--Probing module
package.loaded.Probing = nil
prb = require "mcProbing"
--mc.mcCntlSetLastError(inst, "Probe Version " .. prb.Version());

If the module extension is different than .lua then change your load path to search for that as well.

package.path = path .. "\\Profiles\\" .. profile .. "\\Modules\\?.lua;" .. path .. "\\Modules\\?.lua;"

LuaJIT is a compiler.  Mach4 runs it's own compiler to compile all lua, mcs files at each load and I don't believe you can just include the compiled module in the modules directory, but then again I haven't tried.  Good question though.

I'm not sure if the sci modules are 5.2 compatible.

MTCW

RT