Appendix Ε
– Introduction to Lua
This appendix attempts to serve as a reference for the basic concepts of Lua programming. This section is from another of my publications, Mastering the Nmap Scripting Engine. If you are interested in learning more about NSE development, I recommend that you read that book as well.
Flow control structures
Some classic control structures are implemented in Lua, such as the if-then conditional statements, a few different loop types, and the break and continue functions. Let's review those structures briefly.
Conditional statements – if, then, elseif
The if-then conditional statement evaluates an expression and executes a block of code if true:
if status.body then
--Do something end
Lua also supports an elseif
Get Nmap Network Exploration and Security Auditing Cookbook - Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.