2019-01-15 15:53:31 -08:00
|
|
|
#!/usr/bin/env nomsu -V6.15.13.8
|
2018-06-14 22:17:26 -07:00
|
|
|
#
|
|
|
|
This file contains basic input/output code
|
2018-11-11 15:50:46 -08:00
|
|
|
|
2019-01-10 16:33:37 -08:00
|
|
|
use "core/metaprogramming"
|
2018-07-20 20:27:15 -07:00
|
|
|
|
2018-11-08 15:23:22 -08:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2019-01-15 15:53:31 -08:00
|
|
|
external:
|
|
|
|
(say $message) compiles to:
|
|
|
|
lua> ("
|
|
|
|
if \$message.type == "Text" then
|
|
|
|
return LuaCode("say(", \($message as lua expr), ");");
|
|
|
|
else
|
|
|
|
return LuaCode("say(tostring(", \($message as lua expr), "));");
|
|
|
|
end
|
|
|
|
")
|
|
|
|
|
|
|
|
(say $message inline) compiles to:
|
|
|
|
lua> ("
|
|
|
|
if \$message.type == "Text" then
|
|
|
|
return LuaCode("io.write(", \($message as lua expr), ")");
|
|
|
|
else
|
|
|
|
return LuaCode("io.write(tostring(", \($message as lua expr), "))");
|
|
|
|
end
|
|
|
|
")
|
|
|
|
|
|
|
|
(ask $prompt) means:
|
|
|
|
$io.write $prompt
|
|
|
|
return ($io.read())
|