2018-07-18 17:55:29 -07:00
|
|
|
#!/usr/bin/env nomsu -V2.4.4.3
|
2018-06-14 22:17:26 -07:00
|
|
|
#
|
|
|
|
This file contains basic input/output code
|
|
|
|
|
|
|
|
use "core/metaprogramming.nom"
|
2018-07-17 23:08:13 -07:00
|
|
|
compile [say %message] to (..)
|
2018-06-14 22:17:26 -07:00
|
|
|
lua> ".."
|
|
|
|
if \%message.type == "Text" then
|
2018-06-20 15:22:03 -07:00
|
|
|
return LuaCode(tree.source, "print(", \(%message as lua expr), ");");
|
2018-06-14 22:17:26 -07:00
|
|
|
else
|
2018-06-20 15:22:03 -07:00
|
|
|
return LuaCode(tree.source, "print(tostring(", \(%message as lua expr), "));");
|
2018-06-14 22:17:26 -07:00
|
|
|
end
|
|
|
|
|
2018-07-17 23:08:13 -07:00
|
|
|
compile [ask %prompt] to (..)
|
2018-06-14 22:17:26 -07:00
|
|
|
lua> ".."
|
|
|
|
if \%prompt.type == "Text" then
|
2018-06-18 15:44:29 -07:00
|
|
|
return LuaCode.Value(tree.source, "(io.write(", \(%prompt as lua expr), ") and io.read())");
|
2018-06-14 22:17:26 -07:00
|
|
|
else
|
2018-06-18 15:44:29 -07:00
|
|
|
return LuaCode.Value(tree.source, "(io.write(tostring(", \(%prompt as lua expr), ")) and io.read())");
|
2018-07-17 23:08:13 -07:00
|
|
|
end
|