LUA scripts for MQTT clients are uploaded to esp8266 with luatool.py
python ./path/to/script/luatool.py -p /dev/ttyS0 -f /path/to/LUA-script/init.lua -t init.lua
Below are lua scripts for MQTT clients.
init.lua is base background operation – connects to WiFi network.
Remember to change NETMASK and IP for AP and clients (aaa.bbb.ccc.ddd) according to your network settings!