自身内部的重复功能

问题描述 投票:0回答:1

这里是示例代码:

local function name()
  startingAction()
  if trigger() then
    endingAction()
    return true
  else
    resetAction()
    startingAction()
    if trigger() then
              endingAction()
      return true
    else
      resetAction()
      startingAction()
      if trigger() then
        endingAction()
        return true
      else
        return false
      end
    end
  end

基本上是一个执行某项功能的函数,但是如果在它之间做不到,我想通过在其前面加上另一个动作来重复此函数。样本深度为3级,但我希望能够控制重复次数。有什么建议吗?

lua
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.