optionSelector.src
// expect a l(list) containing this structure [func, params, display_text] // also instead of a func in the first param you can set the string "return" to make the function return instead option_selector = function(m) while true for i in m.indexes print "[<color=yellow>" + i + "</color>] " + m[i][2] end for selected = user_input("select a option: ").to_int if selected isa string or m.hasIndex(selected) == false then print "<color=red>ERROR: invalid option, try again</color>" continue end if selected = m[selected] if selected[0] == "return" then return selected[0](selected[1]) return end while end function // tests hack = function(ip) print "hacking ip " + ip end function ips = ["20.20.20.20", "20.20.20.21", "20.20.20.22", "20.20.20.23"] for i in ips.indexes ips[i] = [@hack, ips[i], ips[i]] end for ips.push ["return", null, "find a random ip to hack"] //print ips option_selector ipsif
readme.md