为什么要将lua嵌入游戏引擎中? [英] Why embed lua into a game engine?

查看:244
本文介绍了为什么要将lua嵌入游戏引擎中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在从头开始研究构建基本的游戏引擎,并列出了其他引擎共有的功能后,更大的事情之一就是它们具有嵌入式脚本语言,例如lua或python.

I've been looking into building a basic game engine from the ground up and after making a list of features that are common to other engines, one of the bigger things is the fact that they have an embedded scripting language like lua or python.

我的问题是,嵌入式脚本语言比仅制作用户可以包含在c ++文件中的头文件(或类似文件)更好的方法是什么,它可以使他们访问许多功能和状态.我敢肯定那里有一个很好的答案,我只是还没有偶然发现.

My question is how is an embedded scripting language superior to just making a header file (or something of the like) that the user can include in a c++ file which gives them access to many of the functions and states. I'm sure there's a very good answer out there, I just haven't stumbled on it yet.

除了为什么需要它之外,诸如lua之类的语言在游戏引擎等事物中用于什么?

Also beyond why it's needed, what are languages like lua used for in things like game engines?

推荐答案

Lua是一种比C ++更简单的语言,所有需要编辑的都是文本编辑器.这使您可以在设计师和最终用户的手中编写事件和/或高级游戏逻辑的脚本.动态类型和垃圾回收使他们可以编写非常简洁的代码,这些代码专注于游戏逻辑,而不是像C ++这样的语言所获得的所有系统级内务处理工作.沙箱操作也容易得多.

Lua is a far simpler language than C++, and all you need to edit it is a text editor. This puts the ability to script events and/or high level game logic in the hand of your designers and end users. Dynamic typing and garbage collecting allows them write very succinct code that focusses on game logic rather than all the systems-level housekeeping chores you get in a language like C++. It's also far easier to sandbox.

Lua是一种流行的选择,因为它体积小,可移植,易于破解的ANSI C代码库.易于嵌入,扩展,并且-对于游戏开发人员而言最重要的是-它具有最小的运行时占用空间(最快的解释语言之一).它也是易学/读/写语法的完美结合,但具有强大的功能,例如协程,在游戏中非常有用.

Lua is a popular choice because it's small, portable, hackable ANSI C code base; easy to embed, extend, and -- most importantly for game developers -- it has a minimal runtime footprint (one of the fastest interpreted languages). It's also a great combination of easy to learn/read/write syntax, but with powerful features like coroutines which can be very useful in games.

这篇关于为什么要将lua嵌入游戏引擎中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆