Fibaro requesting prices Lua 5.1 - lua

Luarocks wont work on fibaro, so im removing this

As Egor suggested, Fibaro sandboxes their Lua environment. A full list of what is removed is listed at https://manuals.fibaro.com/knowledge-base-browse/blocked-lua-commands/, but it includes require, dofile, load, loadfile, loadstring, several functions in the os library, and the entire io and package library.
That effectively requires all of your code to be contained in a single file, with no access to modules, packages, or libraries other than the remaining parts of the standard library, which means you simply can't do what you're trying to do here.

Related

Is there a way to dynamically call functions from different files in Lua 5.0?

I'm trying to execute Lua scripts, but the file names of the files that will contain the functions that need to be run are variable.
I've tried looking for ways to include whole folders of Lua files at a time, implement some kind of dependency injection, use variables across files without including the files. All of them have yielded no result.
I'm using a Lua 5.0.2 interpreter that I can't change/replace. I also can't really use LuaRocks modules.
It's for an old game called Zoo Tycoon 2.

ESP8266 - Is it possible to just run Lua from C (not the full NodeMCU environment)?

I'm working with ESP8266 and I don't want to use Lua for the whole project, I just want to run a few snippets of Lua code, received from wifi/sd card. I'd need to start a Lua environment and run the scripts, which would then eventually call some native functions for low level tasks. In other words, I just want to use Lua as simple scripting language (as it's intended to be) to implement some dynamic behavior. Is it possible? Is there any build of lualib for arduino?
Thanks in advance!
You can simply embed Lua in a extlibs/ folder for example and link to it when compiling your program.
There is existing Lua binaries but building it yourself is easy and better (as it's multiplatform).
OK, I know both answers told me I can just embed the code into my project, however, I found out I need to make some small changes. I made an example working project available here and the following list of changes had to be made:
The flags LUA_32BITS and LUA_USE_LONGJMP (C exception handling) were enabled
The following libraries were excluded: io, os, package, coroutine
The following functions were removed from C API: luaL_fileresult, luaL_execresult, luaL_loadfile, luaL_loadfilex, luaL_dofile, luaB_loadfile, luaB_dofile
Lua output messages are redirected to the Serial interface, check tinylua.h, tinylua.cpp and lauxlib.h to change this behavior
Hope this helps!
The ESP8266 has up to 4MB of program storage. Theoretically you can get up to 16MB as the datasheet specifies.
As I remember, compiling an amalgamated version of Lua (all sources in one file), occupies less than 100kb.
So, you can compile the Lua library and use it as needed on esp8266, even using Arduino IDE.
But you will get NAKED Lua if you do so... No nifty libraries to control Wifi, serial, SD, ports... You would have to provide that in C, or use NodeMCU code as you need.
You can try LuaJIT and access C code directly from Lua, cutting out the need for writing libraries. I have no idea of how you would compile it to Esp8266, or if anyone have tried this before, but you can do it "for science" and tell us how it turned out.

How to use external library with love2d

I'm trying to use the luafun library with love2d.
Running lua main.lua, however love . complains about the missing fun library.
I have installed luafun with luarocks.
There's two options.
If you want to distribute whatever you're building, you almost certainly don't want users to install Lua, luarocks, etc. etc. - so the best way is to simply put any libraries into the folder that your game/program/… lives in. (If a library contains compiled things, you'll need to build per platform/OS and then you'll actually want a build process that spits out the various variants, but if it's all-Lua, there's no platform-specific stuff, so just copy it in.)
The other option (mostly for when you only need it to work on your machine) is to adjust package.path and then love will find things just fine. If you use LUA_INIT / LUA_PATH on your machine, Love ignores them but you can manually fetch & process them using os.getenv, dofile / load(code)() & friends. (As the very simplest special case of this, if luarocks is installed in the standard Lua search path, saying require "luarocks.loader" might be enough to get all luarocks-installed packages to work.)

Using external modules with statically linked lua

Recently, I've purchased a game that uses lua for modding support. Unfortunately, lua has been statically linked and there are no dll's at all. It appears to be running lua 5.2 and I don't think any of the lua functions have been modified. I don't have access to the source but debugging info was included with the executable. I'm attempting to use an external library (luasockets) which seems to come with it's own version of lua (lua5.1.dll). Loading the library causes the game to immediately crash without a useful stacktrace. any way to make this work short of rewriting all the lua functions in the exe?

Building Lua modules for Lua embedded in Rust (rust-lua53)

I'm currently using the rust-lua53 crate to embed Lua into a Rust project. rust-lua53 downloads and builds the Lua tarball during "cargo build" (in its build.rs).
I'd like to make other Lua libraries (written in C) available to Lua code in my application, eg LPeg or LFS, but it's not obvious to me how to do it.
My ideas so far are:
Build the libraries against a stock Lua and hope I get away with it (or have to check it matches every subsequent rust-lua53 release)
Somehow expose the relevant headers from rust-lua53 (can a crate include extra files like that?)
Change to a different Rust/Lua binding which somehow makes this easier.
Fork rust-lua53 and make it embed the extra libraries I want as well as the plain Lua interpreter.
Implement the functionality in Rust instead of relying on C libraries. Plausible for LFS in my application, but re-implementing LPeg is beyond what I want to do right now!

Resources