gpt4 book ai didi

screeps - 从控制台与脚本交互

转载 作者:行者123 更新时间:2023-12-02 14:16:39 25 4
gpt4 key购买 nike

有什么方法可以从控制台调用模块或函数吗?例如,创建 worker 小兵的模块,从控制台使用 my_module.add_creep 调用?

最佳答案

对于给定的示例,请使用 require('my_module').add_creep();require 函数返回分配给该模块中的 module.exports 的任何内容。

@cho:require 不必返回函数。它而是返回一个函数,因为该模块包含一个函数。如果模块分配如下 module.export = {test: 'test'},则遵循代码段 require('that_module') 将返回 {test: 'test '}等等...

注意:不确定其他人是否有此问题,但有时控制台根本不返回结果... 在这种情况下,请尝试重新加载页面。 只需确保游戏正常执行命令时不会暂停...

关于screeps - 从控制台与脚本交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27074408/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com