lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Hi,
> 
> noob question alert. I've been googling around, trying to figure out how I
> can use lua libraries (I was looking at LuaSocket) from inside of an
> embedded application. So far, I've only found instructions for how to do
> install libraries into standalone interpreters. I'm new to some of the
> lua-specific terminology as well, so it looks like I'm stumped. Any hints
> would be greatly appreciated.
> 
> Background info: I'm using a mechanical simulation tool (GUI and Windows
> based, if that matters) that calls Lua functions. Say, you want to apply a
> force as a function of time, then the function could look like function
> force(t)
> 	return 2*t
> end
> for example. It would be really neat if we could take input from a network
> port, a joystick,  or something along those lines. I am guessing that
> taking network input will let you pipe whatever input you want from
> wherever you want, but any hints on a better / simpler idea is also
> appreciated!
> 
> Cheers
> Paul

It depends on the Lua engine embedded. If it's a 'stock' Lua engine, then you should be able to simply use 'require' to load luasocket. But in many environments where Lua is embedded, the functionality has been reduced to prevent security issues (and maybe stability if using c libraries). So your primary source should be the applications documentation, and otherwise; just experiment.

Try
  local socket = require("luasocket")
And see what happens. Probably good to have a look at the paths as well; package.path and package.cpath to see where you should put your libraries.

Hth

Thijs