`showcase of lua using configuration files

disable escapekey
set window on

`initialize LUA
LUA MAKE

`load config file
LUA LOAD FILE "config.txt"
check_for_error()

`get variables
age = LUA INT("age")
`age$ = LUA STRING$("age")   `this is also valid!
check_for_error()
nick$ = LUA STRING$("nick")
check_for_error()
size# = LUA FLOAT("size")
check_for_error()

`print variables
print "Hello " + nick$
print "You are " + str$(age) + " years old!"
print "size: " + left$(str$(size#),4) + " meters"
print ""

`function tests and memory leak analysis -- they work
print "hit any key to quit."
while (scancode()=0)
   i = rnd(33)
   LUA SET INT "int", i
   if i <> LUA INT("int") then print "int error!"
   f# = rnd(100) / 100.0
   LUA SET FLOAT "float", f#
   if f# <> LUA FLOAT("float") then print "float error!"
   s$ = str$(rnd(10000))
   LUA SET STRING "string", s$
   if s$ <> LUA STRING$("string") then print "string error!"
   check_for_error()
endwhile


`LUA will automatically be terminated when calling 'end'
end


function check_for_error()
   `Display message and terminate program if a Lua error has occurred.
   if LUA ERROR()
      print LUA ERROR MSG$()
      wait key
      end
   endif
endfunction