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