【问题标题】:How do I connect prints with scripts in roblox?如何将打印件与 roblox 中的脚本连接起来?
【发布时间】:2021-03-18 01:47:20
【问题描述】:

我需要让 print 执行等待命令。我该怎么做?

while true do
    wait(color.Parent.Time.Value == 0)
    if not parent.BrickColor == color then
        Hide()
    end
    wait(not color.Parent.Time.Value == 0)
    Show()
    parent.BrickColor = BrickColor.Random()
end

【问题讨论】:

  • 您能否再解释一下“通过打印执行”是什么意思?您是否希望这些wait() 命令仅在它们内部的条件为真时才发生?或者您是否希望将传入的值也打印到控制台?还是别的什么?
  • 我需要''stop''命令来停止它想要的字符串被打印出来。

标签: lua scripting roblox


【解决方案1】:

我想你要找的是repeat wait() until ...

while true do
    repeat wait() until color.Parent.Time.Value == 0
    if not parent.BrickColor == color then
        Hide()
    end
    repeat wait() until not color.Parent.Time.Value == 0
    Show()
    parent.BrickColor = BrickColor.Random()
end

在原型设计或早期开发构建中使用它很好,但您应该尽量避免在生产代码中使用它,在此处查看替代方案 https://devforum.roblox.com/t/avoiding-wait-and-why/244015

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-02
    • 2018-04-06
    相关资源
    最近更新 更多