Embedding Lua in the Source Engine: Difference between revisions
(Undo revision 211840 by GamerDude27 (talk)) Tag: Undo |
(did i remove fix it?, im pretty sure there is still alot of "you" here | third person + a lot of other things) |
||
Line 3: | Line 3: | ||
|ru=Embedding_Lua_in_the_Source_Engine:ru | |ru=Embedding_Lua_in_the_Source_Engine:ru | ||
}} | }} | ||
{{orphan | {{orphan}} | ||
<div style="margin:auto;text-align:center;"> | <div style="margin:auto;text-align:center;"> | ||
Line 17: | Line 17: | ||
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. | 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. | ||
Find out more about Lua on [http://www.lua.org/about.html here]. | |||
== Overview == | == Overview == | ||
Lua is currently [http://www.satori.org/2009/03/the-engine-survey-general-results/ the leading scripting language in games], and for Steam users, is synonymous with [[Garry's Mod]]. Unfortunately, Garry's Mod isn't open source | Lua is currently [http://www.satori.org/2009/03/the-engine-survey-general-results/ the leading scripting language in games], and for Steam users, is synonymous with [[Garry's Mod]]. Unfortunately, Garry's Mod isn't open source. However, {{HL2}} [http://code.google.com/p/hl2sb/ 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 this article will explain how. | ||
[[Half-Life 2: Sandbox]] uses a pure variant of Lua, different than | [[Half-Life 2: Sandbox]] uses a pure variant of Lua, different than Facepunch's implementation of the language, which has restrictions on many libraries, and modified syntax for C++ styled comments. [[Half-Life 2: Sandbox]] 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 [http://www.rasterbar.com/products/luabind.html LuaBind] oriented [[Lua tutorial]] or [[Adding Lua]] article. | ||
== Implementation == | == Implementation == | ||
Line 31: | Line 31: | ||
=== Installation === | === 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. | The Lua manager scripts found in the [[Half-Life 2: Sandbox]] source code were written generically so they could be added to any mod. | ||
* | * While working with a mod's source code, rather than a plugin, the files above should be placed within '''src/game/shared''' | ||
* In | * In the project files, place both the '''luamanager.cpp''' and '''luamanager.h''' in the '''Source Files''' filter | ||
* Compile | * Compile the binaries | ||
* Simply add the precompiled '''lua51.dll''' to | * Simply add the precompiled '''lua51.dll''' to the mod's '''bin''' folder! | ||
{{Note|[[Half-Life 2: Sandbox]] has went through several revisions extending its Lua API greatly including many classes and libraries for real-world usage with Source. As a result of these expansions, to be able to use these classes, mod creator should need to add the individual class .cpp and .h files, which are all listed in luamanager.cpp by headers that correspond to .cpp files.}} | |||
== External links == | == External links == | ||
* [http://www.lua.org/about.html Lua: about] | * [http://www.lua.org/about.html Lua: about] | ||
* [http://lua-users.org/wiki/BindingCodeToLua lua-users wiki: Binding Code To Lua] | * [http://lua-users.org/wiki/BindingCodeToLua lua-users wiki: Binding Code To Lua] | ||
* [http://code.google.com/p/hl2sb/ Half-Life 2: Sandbox's google code page] | |||
[[Category:Programming]] | [[Category:Programming]] | ||
[[Category:Scripting]] | [[Category:Scripting]] |
Revision as of 10:18, 15 September 2022

You can help by

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.
Find out more about Lua on 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. However, 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 this article will explain how.
Half-Life 2: Sandbox uses a pure variant of Lua, different than Facepunch's implementation of the language, which has restrictions on many libraries, and modified syntax for C++ styled comments. Half-Life 2: Sandbox 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.
- While working with a mod's source code, rather than a plugin, the files above should be placed within src/game/shared
- In the project files, place both the luamanager.cpp and luamanager.h in the Source Files filter
- Compile the binaries
- Simply add the precompiled lua51.dll to the mod's bin folder!
