游戏脚本需要哪些语言功能?
我正在考虑设计一种游戏脚本语言,并且想知道游戏行业的工作人员认为良好的游戏脚本语言的基本项目/属性是什么。 这包括以下内容:
- 静态类型与动态类型
- 它应该针对谁: 程序员还是设计师?
- 语法(必须看起来像 C 语言吗?)
- 应该有多高级? (例如 C 与 Lisp ——或者命令式与功能式)
- 它必须能够做什么。 有多快 有必要吗?
另外,我从一些来源听说脚本往往非常简单,因为它们是由设计师而不是程序员编写的。 是这样吗?
I am looking into designing a game scripting language and was wondering what people employed in the games industry considered essential items/properties for a good game scripting language. This includes things like:
- static vs dynamic types
- Who should it be aimed at:
programmers or designers? - syntax(must it look like C?)
- How high level should it be? (C vs Lisp for example
-- or imperative vs functional) - What must it be able to do. How fast does
it need to be?
Also, I have heard from a few sources that scripts tend to be very simple as they are written by designers more than programmers. Is this the case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如何研究一下在游戏中实际用于编写脚本的语言,例如 Python 和 <有一些想法吗?
两者恰好都是动态类型,并且就语法而言,Python 与 C 非常不同,而 Lua 与 C 也不太相似。
可能它们用于游戏脚本的原因是易于将语言嵌入为脚本发动机,如果还有别的的话。 如果要在设计语言时考虑到设计师的需求,那么可能必须更改该语言的要求才能满足设计人员的需求,而不是拥有一种更容易集成到游戏中的语言。
How about looking into languages that are actually used for scripting in games like Python and Lua for some ideas?
Both happen to be dynamically typed, and in terms of syntax, Python is very not C-like, and Lua is not terribly similar to C.
Probably the reason why they are used for game scripting is the ease of embedding the language as a scripting engine, if anything else. If the language is to be designed with designers in mind, then the perhaps the requirements for the language would have to be changed in order to fit the designers needs, rather than having a language that is more easily integrated into a game.
您似乎在问一个非常笼统的问题(如果您不知道脚本语言必须做什么,或者需要多快)并期待具体的答案。
脚本语言的主要原因是允许人们在不破解源代码的情况下改变游戏。 我们就这样吧。
因此,它应该更多地针对设计人员,因为他们不会破解源代码,而程序员会。 它需要足够快才能正常运行游戏。 它需要足够强大,以便设计师能够放入他们要放入的任何东西。(是的,这些是模糊的答案,但你没有提供足够的信息来更具体。)
所以,忘记主要供程序员使用的功能,例如任何特定的语法模型或静态类型。 设计人员不会对 C 语法一窍不通,也不想担心静态类型或内存管理。
使用已经建立的语言有一些真正的优势。 设计师可能对此有一些经验,它已经记录在案,并且已经为您完成了许多困难的工作。 这包括语言设计:程序员不一定善于发现脚本语言的优点。
这表明类似 Lua 或 Python 的东西。
You seem to be asking a very general question (if you don't know what the scripting language has to do, or how fast it needs to be) and expecting specific answers.
The main reason for a scripting language is to allow people to change the game without hacking the source code. Let's go with that.
It should therefore be aimed more at designers, since they aren't going to hack the source code, and the programmers will. It needs to be fast enough to run the game properly. It needs to be powerful enough for the designers to put in whatever it is they're going to put in. (Yes, these are vague answers, but you don't give enough information to be more specific.)
So, forget about the features that would be of use primarily for programmers, like any particular syntax model or static typing. Designers aren't baby-ducked on C syntax, and don't want to worry about static typing or memory management.
There's some real advantages to using an already established language. The designers might have some experience with it, it's already documented, and a lot of the hard stuff has already been done for you. This includes the language design: programmers are not necessarily good at seeing what is good about a scripting language.
This suggests something like Lua or Python.
我理想的游戏脚本语言应该具有类似 Python 的语法,并且可以像 LUA 一样轻松地嵌入到其他语言中。
此外,它应该能够嵌入到 XNA 中,而 XNA 目前(并且可能永远)缺乏 LuaInterface 和嵌入式 IronPython 所依赖的反射功能。
My ideal game scripting language would have a Python-like syntax and could be embedded into other languages as easily as LUA.
Additionally, it should be able to be embedded inside XNA, which does currently (and will probably forever) lack the reflection features that LuaInterface and embedded IronPython depend upon.
这部分取决于哪个部门将负责大部分脚本编写。 例如,如果关卡设计师正在编写大部分脚本,那么最好的语言类型将是更接近自然语言的语言,不需要陡峭的学习曲线。 关卡设计师不一定要学习 C/C++ 等复杂语法只是为了播放声音。
伪语言可能看起来像这样(TES 构造集脚本是这样的):
但是如果程序员是做大量脚本的人,那么使用更复杂的语言(如 Lua 或 Squirrel 和类)可能会更灵活和更强大,物体之类的。
创建“更简单”的脚本语言的一个好处是,实现并不像更困难的语言那么复杂,并且还允许您轻松开发工具来通过 GUI 创建脚本,例如从声音列表中选择播放、要附加的怪物物品列表等。
It depends partially on what department will be doing the majority of scripting. If the level designers, for example, are doing a large portion of scripting then the best type of language would be something closer to natural language that doesn't require a steep learning curve. A level designer doesn't necessarily want to learn complex syntax like C/C++ just to play a sound.
A pseudo language might look like this (TES Construction Set scripting is like this):
But if the programmers are the ones doing a lot of the scripting then its probably more flexible and powerful to use a more complex language like Lua or Squirrel with classes, objects and such.
One good side of creating a "simpler" scripting language is that implementation isn't nearly as complex as the more difficult languages and would allow you to also easily develop tools to create scripts via a GUI, such as choosing from a list of sounds to play, a list of monster items to attach, etc.