Post your best Lua script examples here

User avatar
By alonewolfx2
#3142 Thank you for your hard work :D
zeroday wrote:2AM morning here. continue tomorrow :D
User avatar
By zeroday
#3176 Write a lua module in pure lua

save this to "myfile.lua"
Code: Select all--myfile.lua

local myfile = {}
function myfile.print(name)
  file.open(name)
  repeat
    local line=file.readline()
    if line then line=(string.gsub(line,"\n","")) print(line) end
  until not line
  file.close()
end
return myfile


use it:
Code: Select allmf=require("myfile")
mf.print("init.lua")
User avatar
By gerardwr
#3233 IOT example:
- sends ADC value to a webserver every 3 seconds (need connection to TOUT pin of ESP, not tested myself)
- sends GPIO value to a webserver at every GPIO level change (interrupt at every UP or DOWN flank)
- provides a webpage with some ESP data

Schermafbeelding 2014-11-24 om 17.43.30.png


Schermafbeelding 2014-11-24 om 17.37.48.png


Upload the file below to init.lua on the ESP, and reboot the ESP.
(2.54 KiB) Downloaded 1748 times