nomsu/core/io.nom
Bruce Hill dcb5e8add2 Fully updated to 3.6, deprecated old LuaCode global functions like "to 1
write 2" and replaced them with method calls like "1::append 2"
2018-08-29 15:10:27 -07:00

24 lines
754 B
Plaintext

#!/usr/bin/env nomsu -V3.6.5.6
#
This file contains basic input/output code
use "core/metaprogramming.nom"
compile [say %message] to (..)
lua> ".."
if \%message.type == "Text" then
return LuaCode(tree.source, "print(", \(%message as lua expr), ");");
else
return LuaCode(tree.source, "print(tostring(", \(%message as lua expr), "));");
end
compile [ask %prompt] to (..)
lua> ".."
if \%prompt.type == "Text" then
return LuaCode.Value(tree.source, "(io.write(", \(%prompt as lua expr), ") and io.read())");
else
return LuaCode.Value(tree.source, "(io.write(tostring(", \(..)
%prompt as lua expr
.., ")) and io.read())");
end