我应该支持哪种游戏内脚本语言?

发布于 2024-08-05 10:17:46 字数 1061 浏览 10 评论 0原文

游戏内脚本将控制 NPC/AI 逻辑。

如果我要实现游戏内脚本功能,它应该支持哪种语言?

  • JavaScript(内置浏览器支持)
  • TCL (java 解释器)
  • Lua (流行)
  • < a href="http://en.wikipedia.org/wiki/Squirrel_(programming_language)" rel="nofollow noreferrer">Squirrel
  • CSI
  • 其他

请记住,我的实现将在.net、flash、javascript 和 java 等多个平台上运行。

列出的可能性的优点和缺点是什么?实施解释器需要多长时间?

游戏脚本编写者正在寻找哪些功能? 其他游戏正在实施什么?

我想投票给 javascript,因为每个人都可以读写它。

你有什么想法?

The ingame script will control NPC/AI logic.

If I were to implement ingame scripting feature which language should it support?

Keep in mind my implementation will run on multiple platforms like .net, flash, javascript and java.

What are the pro's and con's of the listed possibilities? How long will it take to implement the interpreter?

What features are ingame scripters looking for?
What are other games implementing?

I am thinking to vote for javascript due to the fact that everybody can read and write it.

What are your thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

写下不归期 2024-08-12 10:17:46

我会使用 Lua,因为它非常容易嵌入。嵌入 Python 似乎很复杂,我并没有真正追求这一点。

如果您愿意,此链接可能会进一步有用了解更多关于嵌入 Lua 及其优点/缺点。

I'd use Lua, because it's terribly easy to embed. Embedding Python appeared to be complicated and I haven't really pursued that.

This link may be of further use if you want to know more about embedding Lua and its advantages/disadvantages.

橘香 2024-08-12 10:17:46

使用Lua。 这是一种美丽的语言,在游戏行业广泛采用

大多数平台都有 Lua 绑定:

还有 llvm- lua项目,这可能有助于将Lua移植到其他平台。

至于 JavaScript 作为宿主平台...这个主题经常出现在 Lua 邮件列表中,但尚未发布正式的解决方案。如果您确实需要在 JS 中托管 Lua,请在 Lua 邮件列表中询问,也许有人可以分享他们在该主题上的经验。

Use Lua. It is a beautiful language, widely adopted in game industry.

There are Lua bindings for most of your platforms:

There is also llvm-lua project, which may be helpful for porting Lua to other platforms.

As for JavaScript as a host platform... This subject recurrently appears in the Lua mailing list, but no serious solution were published yet. If you really need to host Lua in JS, please ask in the Lua mailing list, perhaps some people could share their experience on the subject.

热情消退 2024-08-12 10:17:46

我更喜欢 Python,因为它可以绑定多种语言。

I would prefer Python for its bindings in many languages.

庆幸我还是我 2024-08-12 10:17:46

我认为你的意思是“集成”解释器,而不是“实现”它。根据您的技能,为脚本语言创建解释器可能会花费大量时间。

I think you mean "integrate" the interpreter, and not "implement" it. Depending on your skills, creating an interpreter for a scripting language could take a lot of time.

寄居人 2024-08-12 10:17:46

我确信 Python 和 Lua 具有 .NET 和 Java 的绑定——您可以嵌入解释器。不知道Javascript和Flash是否有绑定。

Python 的问题在于它有三种变体,都是由不同的人制作的。

  • IronPython for .NET
  • Jython for Java
  • 和常规 CPython

我没有使用过 Jython,所以我不会对此发表评论。但 IronPython 和 CPython 之间存在某些可移植性问题。例如:IronPython 不支持本机 C 扩展。如果用 CPython 编写的脚本使用了这些脚本,那么将很难将它们移植到 IronPython。此外,如果 IronPython 脚本使用任何 .NET 库,您将很难将它们移植到 CPython。

另一方面,Lua 的实现来自一个地方,我预计不会出现这样的问题。

I know for sure that Python and Lua have bindings for .NET and Java -- you can embed the interpreters. Don't know whether there are any bindings for Javascript and Flash.

The problem with Python is that there are three variants all made by different people.

  • IronPython for .NET
  • Jython for Java
  • and the regular CPython

I haven't worked on Jython so I won't comment about it. But there are certain portability issues between IronPython and CPython. For example: IronPython doesn't support native C extensions. If there are scripts written in CPython which use these, you will have a hard time porting them to IronPython. Also, if the IronPython scripts use any .NET libraries, you will have a hard time porting them to CPython.

Implementations of Lua, on the other hand, come from a single place and I don't expect such problems.

岁吢 2024-08-12 10:17:46

这取决于您的代码的复杂程度(NPC 的行为会变得多么复杂)。 Tcl、Lua 和 JavaScript 用于简单任务。用这些语言快速编写大量代码往往会变得难以维护(特别是对于临时用户而言)。

Squirrel 使用类似 C 的语法,大多数人都会熟悉这种语法,但是工具支持怎么样?如果您必须用记事本编写所有内容,那也会严重限制您。

Python 是一种成熟的语言,易于学习(只需将 Lua“教程”与 Python 附带的“教程”进行比较即可)。虽然各种Python版本可能看起来令人生畏(请参阅Rohit的回答),游戏中的 Python 代码对于所有这些都是相同的。它附带一个 IDE (IDLE),还有其他支持 Python 的 IDE,可以为您提供代码完成、调试、运行测试用例等。

That depends on how complex your code will be (how complicated the behavior of NPCs can become). Tcl, Lua and JavaScript are for simple tasks. Writing large pieces of code in these languages quickly tends to become unmaintainable (especially for casual users).

Squirrel uses a C-like syntax which most people will be comfortable with but how about tooling support? If you have to write everything with Notepad, that will severely limit you, too.

Python is a mature language that is easy to learn (just compare the Lua "tutorial" to the one which comes with Python). While the various Python versions might seem intimidating (see Rohit's answer), the Python code in your game will be the same for all of them. It comes with an IDE (IDLE) and there are other IDEs which support Python which gives you code completion, debugging, running test cases, etc.

如果没有 2024-08-12 10:17:46

如果您想使用 Python,请考虑使用 Stackless,因为它在线程方面比普通的 CPython 更好。它被用在一些 MMORPG(EVE Online、IIRC)中,因此它在游戏中有一些记录。另外,它非常适合延续(这是它最初开发的部分原因),这是游戏中使用的“模拟”类型逻辑的一个很好的模型。

If you want to use Python consider using Stackless as it is rather better at threading than stock CPython. It's used in some MMORPGs (EVE Online, IIRC) so it's got some track record in games. Plus, it is very good for continuations (part of the reason it was developed in the first place), which is quite a good model for 'simulation' type logic that one use in games.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文