Embedding Lua in the Source Engine: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<div style="margin:auto;text-align:center;"> | |||
'''[[User:Andrewmcwatters|Andrew C. P. McWatters]]''' ([mailto:mcwattersandrew@gmail.com mcwattersandrew@gmail.com]), 2010 | '''[[User:Andrewmcwatters|Andrew C. P. McWatters]]''' ([mailto:mcwattersandrew@gmail.com mcwattersandrew@gmail.com]), 2010 | ||
Line 29: | Line 29: | ||
* If you're working with a mod's source code, rather than a plugin, the files above should be placed within '''src/game/shared''' | * If you're working with a mod's source code, rather than a plugin, the files above should be placed within '''src/game/shared''' | ||
* In your project files, place both the '''LuaManager.cpp''' and '''LuaManager.h''' in the '''Source Files''' filter | * In your project files, place both the '''LuaManager.cpp''' and '''LuaManager.h''' in the '''Source Files''' filter | ||
{{wip}} | |||
== External links == | |||
* [http://www.lua.org/about.html Lua: about] | |||
* [http://lua-users.org/wiki/BindingCodeToLua lua-users wiki: Binding Code To Lua] |
Revision as of 11:00, 18 February 2010
What is Lua?
Lua is a powerful, fast, lightweight, embeddable scripting language.
Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.
You can find out more about Lua on their website, here.
Overview
Lua is currently the leading scripting language in games, and for Steam users, is synonymous with Garry's Mod. Unfortunately, Garry's Mod isn't open source, and as a result, we cannot use Team Garry's implementation of Lua for our and others' benefit. However, my project, Half-Life 2: Sandbox is currently the leading open source project dedicated to bringing the developer community a method for embedding Lua into their mod nearly seamlessly, and in this article I'll explain how.
Half-Life 2: Sandbox uses a pure variant of Lua, different than Garry's implementation of the language, which has restrictions on many libraries, and modified syntax for C++ styled comments. Half-Life 2: Sandbox's goal is to provide a neutral, clean, standardized and well documented code base for interfacing with Lua, unlike articles seen within the Valve Developer Community such as the LuaBind oriented Lua tutorial or Adding Lua article.
Implementation
Files
Installation
The Lua manager scripts found in the Half-Life 2: Sandbox source code were written generically so they could be added to any mod.
- If you're working with a mod's source code, rather than a plugin, the files above should be placed within src/game/shared
- In your project files, place both the LuaManager.cpp and LuaManager.h in the Source Files filter

As a courtesy, please do not edit this while this message is displayed.
If this page has not been edited for at least several hours to a few days, please remove this template. This message is intended to help reduce edit conflicts; please remove it between editing sessions to allow others to edit the page.
The person who added this notice will be listed in its edit history should you wish to contact them.