sandbox.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536
  1. -- sample sandbox environment
  2. function get_sandbox_env ()
  3. return {
  4. ipairs = ipairs,
  5. next = next,
  6. pairs = pairs,
  7. pcall = pcall,
  8. tonumber = tonumber,
  9. tostring = tostring,
  10. type = type,
  11. unpack = unpack,
  12. io = { close = io.close, flush = io.flush, input = io.input, open = io.open, output = io.output,
  13. popen = io.popen, read = io.read, type = io.type, write = io.write},
  14. string = { byte = string.byte, char = string.char, find = string.find,
  15. format = string.format, gmatch = string.gmatch, gsub = string.gsub,
  16. len = string.len, lower = string.lower, match = string.match,
  17. rep = string.rep, reverse = string.reverse, sub = string.sub,
  18. upper = string.upper },
  19. math = { abs = math.abs, acos = math.acos, asin = math.asin,
  20. atan = math.atan, atan2 = math.atan2, ceil = math.ceil, cos = math.cos,
  21. cosh = math.cosh, deg = math.deg, exp = math.exp, floor = math.floor,
  22. fmod = math.fmod, frexp = math.frexp, huge = math.huge,
  23. ldexp = math.ldexp, log = math.log, log10 = math.log10, max = math.max,
  24. min = math.min, modf = math.modf, pi = math.pi, pow = math.pow,
  25. rad = math.rad, random = math.random, sin = math.sin, sinh = math.sinh,
  26. sqrt = math.sqrt, tan = math.tan, tanh = math.tanh },
  27. table = { insert = table.insert, maxn = table.maxn, remove = table.remove,
  28. sort = table.sort },
  29. utf8 = { char = utf8.char, charpattern = utf8.charpattern, codes = utf8.codes,
  30. codepoint = utf8.codepoint, len = utf8.len, offsets = utf8.offsets},
  31. -- ArduPilot specific
  32. millis = millis,
  33. servo = { set_output_pwm = servo.set_output_pwm},
  34. }
  35. end