Город МОСКОВСКИЙ
00:58:51

Lua C API tutorial: using the stack and working with tables

Аватар
Комплексное число и комплексная аналитика
Просмотры:
17
Дата загрузки:
11.12.2024 07:54
Длительность:
00:58:51
Категория:
Обучение

Описание

This tutorial covers the most fundamental functions of Lua's C API. This will be useful to anyone:
* writing a Lua module that needs to run C code,
* embedding Lua as a scripting language, or
* creating a framework or game engine using Lua.

I don't specifically talk about C++ or Objective-C, but Lua's C API is compatible with those languages as well.

I previously made a video covering how to compile a C module, and how Lua loads C modules: https://www.youtube.com/watch?v=UiZ051A22h8

This video starts out using a some skeleton C code for an example module. That skeleton code can be found here: https://gist.github.com/tylerneylon/5b9ab5ffcc616cd2a337

In order to compile the skeleton code, you'll need the files lua.h, luaconf.h, and lauxlib.h. Those can be found in any source download of Lua. Check your local Lua version by running "Lua -v" and then download the same-version source from here: http://www.lua.org/ftp/

This video also uses an educational module called apidemo. If you have luarocks, you can install this module by running:

sudo luarocks install apidemo

This module is open source; here is the repo for it:

https://github.com/tylerneylon/lua_api_demo

If you like this tutorial, please subscribe to find out when more come out. I also live stream tutorials and game coding sessions: https://www.livecoding.tv/gaarlicbread/

Рекомендуемые видео