Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何重新启动或调用function Lua中的函数_Function_Lua - Fatal编程技术网

如何重新启动或调用function Lua中的函数

如何重新启动或调用function Lua中的函数,function,lua,Function,Lua,我想知道如何使用Lua重新启动或调用函数中的函数 所以我可以这样做 function a() print("Function Starts") a() end a() 因此,这将启动函数a,打印输出,然后重新启动函数a。对于命令控制台,您通常会无限期地循环,直到用户输入一些特殊关键字(如“退出”)或ctrl-break。比如说, local moreCommands = true while moreCommands do command = io.read() -- get use

我想知道如何使用Lua重新启动或调用函数中的函数

所以我可以这样做

function a()
print("Function Starts")
a()
end
a()

因此,这将启动函数a,打印输出,然后重新启动函数a。

对于命令控制台,您通常会无限期地循环,直到用户输入一些特殊关键字(如“退出”)或ctrl-break。比如说,

local moreCommands = true
while moreCommands do 
    command = io.read() -- get user input
    if command == 'quit' then 
         moreCommands = false
    else
         assert(loadstring(command))()
    end
end

这是一个无限递归。您想要的更可能是一个循环(for、while)。你能提供一个实际用途吗?@wb Derp。我没想到那个。我只是想在minecraft中使用computercraft制作一个命令控制台。我不明白你最后打算做什么。也许一个停止变量可以帮助您:本地停止;函数a()打印('bla')如果不停止,则a()结束;我不明白这个问题?您认为您的代码有什么问题?你期待什么结果?