Root/lua/examples/lua_calls_C3/top3.lua

1
2--[[ This is a short (demonstration) piece of Lua
3script which calls in some C functions from a file
4called candy.c; the functions are accessed via a
5table called extratasks (that's defines in the
6C code) and called via the names dothis and dothat -
7again defined in the candy.c file
8]]
9
10-- Setting up demo variables that will be passed to C
11print("Lua code running ...")
12stuff = {hotel = 48, hq = 404, town = 1}
13
14-- Loading and calling the C
15require "candy"
16summat = extratasks.dothis(stuff)
17somemore = extratasks.dothat(summat)
18
19-- Lua code to show you the results
20print ("... back into Lua code")
21print ("Values in Lua now", summat, somemore)
22print ("Table contains ...")
23for k,v in pairs(stuff) do
24        print (k,v)
25        end
26

Archive Download this file

Branches:
master



interactive