Post your best Lua script examples here

User avatar
By adamjp
#3876 Hi, great work everyone working on the lua scripting and also great work to zeroday for making the esp8266 a little more accessible for non C folks. I've also been hacking away at creating a webserver on the esp8266, as wififofum mentioned in the IOT topic there is a library http://wiki.eluaproject.net/lhttpd which I have managed to port over to the ESP, which includes the php style tags within the HTML.

I have attached the example below, I have not tested this fully, as for the reading of files (file.readline) in the lua implementation from zeroday and the constraints of the device the scripting tags can only be on one line. hope this will help everyone along with their tiny webservers. :D

Edit: Git of simple windows console app downloader and webserver lua scripts https://github.com/MrAPierce/esp8266

Edit: latest webserver 2014-12-04, tested with nodemcu firmware 2014-12-04
Attachments
Updated 2014-12-04
(2.25 KiB) Downloaded 598 times
Last edited by adamjp on Thu Dec 04, 2014 12:31 am, edited 1 time in total.
User avatar
By gerardwr
#3882 Wow that's excellent. I was testing the docode function of the elua webserver on my ESP to see if I could use it for my own browser.

This probably means that:

1. I can scrap my webserver development from this post
http://www.esp8266.com/viewtopic.php?f=19&t=611&hilit=iot+webserver

2. I can close the Poll suggestion a migration of the elua webserver here, you're done !
http://www.esp8266.com/viewtopic.php?f=19&t=697

Too late now, will test tomorrow.

Thanks a million!
User avatar
By adamjp
#3884 No probs, there is an issue with the sample index.pht posting back to the webserver seems to crash the module at the moment no sure what is causing the issue but hey, we are at least a couple of steps forward. :D

Cheers.
User avatar
By gerardwr
#3897 Had a 1 minute look at your code, but not tested yet.

Looks neat! Had I seen the elua sample sooner, it would have saved me some late-nighters.

Saw the remark of only processing single-line Lua scripts. In my webservercode processing of multiple lines work, but each of multiple lines I tested were one-liners in itsself. Not sure how it would behave with for..end loop spread across multiple lines.

Will do a real test of your code later. Can't wait!

Have a nice day, you made mine! Thanks for sharing.