Lua scripting to trigger RTL

I want to built a Agri drone, I’m using a flowmeter, my requirement is when the tank gets empty, i want to trigger RTL using lua scrip.
Im not from the programming domain, hope someone will help for this…