问题描述
我在 love2d 中编写代码作为服务器(使用命令行和可视化形式),我如何接受来自命令行的输入?
解决方法
试试这个...
function love.inp()
-- Building a prompt
_PROMPT='Input: '
-- Put out the prompt
io.write(_PROMPT:format())
-- Getting input from stdin
local result=io.read()
-- Do something with it
print('Getting:',result)
-- Cleaning up...
_PROMPT=empty
result=empty
end
要达到该功能,请尝试...
love.keyreleased(key)
if key=="c" then love.inp() end
end