Post your best Lua script examples here

User avatar
By Hoksmur
#7326 It isn't the bigest problem. You can test, how much memory spend short functions.
Code: Select allfx=function() print("Mem free: "..tostring(node.heap()) ) end
s=string.dump(fx)
print(#s)

204 byte
Code: Select allM.setapi=function (tab,callb) M.apifunc=callb end

144 byte
Not bad, but you should count bytes! :cry:
Forth? Who can port Forth to this chip ?..
User avatar
By ozayturay
#7857 Using ESPlorer v0.1 build 206 on a ESP03 module I'm getting unexpected symbol error. The only modification i made is renaming init.lua file to lhttpd.lua

Code: Select allNodeMCU 0.9.5 build 20150118  powered by Lua 5.1.4

> for n,s in pairs(file.list()) do print(n.." size: "..s) end
log.txt size: 17
index.html size: 230
lhttpd.lua size: 3020
index.pht size: 848

> dofile("lhttpd.lua")
lhttpd.lua:1: unexpected symbol near '?'



Any ideas?
User avatar
By gerardwr
#7860
ozayturay wrote:Using ESPlorer v0.1 build 206 on a ESP03 module I'm getting unexpected symbol error. The only modification i made is renaming init.lua file to lhttpd.lua

Code: Select allNodeMCU 0.9.5 build 20150118  powered by Lua 5.1.4

> for n,s in pairs(file.list()) do print(n.." size: "..s) end
log.txt size: 17
index.html size: 230
lhttpd.lua size: 3020
index.pht size: 848

> dofile("lhttpd.lua")
lhttpd.lua:1: unexpected symbol near '?'



Any ideas?


In luatool (from the same developer as Esplorer) I had to delete the very 1st character (I believe it's just a blank) in the lhttpd.lua file, then it uploads OK. Maybe it's the same for Esplorer.

Let us know how it goes.