Post your best Lua script examples here

User avatar
By gerardwr
#3490
gerardwr wrote:I upload an intermediate source


Here is quick and dirty pdf file for the brave that want to experiment.

Good luck!
(134.97 KiB) Downloaded 349 times
Last edited by gerardwr on Sat Nov 29, 2014 2:37 am, edited 1 time in total.
User avatar
By zeroday
#3499
gerardwr wrote:I upload an intermediate source, because I'm stuck with some HW problems (Often my ESP's will not Restart to the Lua prompt but only display rubbish in the terminal. By Resetting the ESP it generally comes alive after a few HW resets, but not anymore! I power it from an FTDI usb-serial adapter with a 33uF elco across the power terminals, I suspect that's the culprit)

In the upload is the latest webserver.lua to upload to init.lua. I continued with the version that was modified by alonewolfx2:
- some cleaning of the code
- javascript lines added by alonewolfx2 are commented out, don't need them now
- .html files are now presented below the header of the (debug) page between horizontal lines, for better appearance
- lua script lines embedded in html source iarerecognised, but NOT yet interpreted an NOT yet executed. File htmllua.html is such a file, can be used for testing. NOTE : these are the lines I was working on before my HW quit.

The latest version I could test looked like:
Schermafbeelding 2014-11-28 om 23.44.45.png


Hope to get my HW problems resolved tomorrow and continue the execution of the lua lines in the HTMl file. I currently have no clue IF and HOW I can get it done. I know there's a lua statement that executes a lua command in a file, so that's hopefully easy. Getting the result from this execution and send it to the browser is the challenge. Perhaps in hindsite it will look simple.

Tips for that, anyone??

Come on guys! The file was downloaded over 100+ times, but only a response from 1 or 2 guys. Don't let alonewolfx2 and me do all the work, step in!! :mrgreen:

Lua webserver 28 nov 2014.zip


WOW, You guys are genius!
can a js lib from cdnjs.cloudflare.com be added? little experience in web program.

btw: the restart issue is much likely a power problem. replace it with a good one(>500mA maybe) usually fix that.
User avatar
By gerardwr
#3505
zeroday wrote:WOW, You guys are genius!


It takes one, to recognize one ;)

I like your Lua firmware, maybe the web server is a good example to show what the firmware can do. If you have thoughts or suggestions for the web server, fell free to list them here. If I manage to get the Lua script embedding in HTML working, I'll probably finish developing the web server, and concentrate on controlling ESP features with some HTML/LUA code.

zeroday wrote:can a js lib from cdnjs.cloudflare.com be added? little experience in web program.

I'm no js expert myself, but considering the fact that js is executed on the browser in your PC, I imagine the (low performance) ESP will not be a bottleneck. In the example of alonewolfx2 some simple js lines adding the jquery library is used, that seems to work.

zeroday wrote:: the restart issue is much likely a power problem. replace it with a good one(>500mA maybe) usually fix that.

[/quote]
I'll try that today. The last weeks I have lived with the required milt-resets, but now it gets annoying.
User avatar
By alonewolfx2
#3509 new version not working for me when i click html links. i used chrome and ie but its same issue. i dont know why?
Attachments
Screenshot 2014-11-29 10.15.02.png