1
0
mirror of git://projects.qi-hardware.com/nn-usb-fpga.git synced 2025-01-10 00:10:15 +02:00
nn-usb-fpga/lua/examples/lua_calls_C3/top3.lua
Carlos Camargo 7d9b7b803c Adding LUA tutorials: lua_calls_C1 - lua_calls_C5
Adding blinker demo: lua_blink_led
2010-09-06 20:24:53 -05:00

26 lines
737 B
Lua

--[[ This is a short (demonstration) piece of Lua
script which calls in some C functions from a file
called candy.c; the functions are accessed via a
table called extratasks (that's defines in the
C code) and called via the names dothis and dothat -
again defined in the candy.c file
]]
-- Setting up demo variables that will be passed to C
print("Lua code running ...")
stuff = {hotel = 48, hq = 404, town = 1}
-- Loading and calling the C
require "candy"
summat = extratasks.dothis(stuff)
somemore = extratasks.dothat(summat)
-- Lua code to show you the results
print ("... back into Lua code")
print ("Values in Lua now", summat, somemore)
print ("Table contains ...")
for k,v in pairs(stuff) do
print (k,v)
end