diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a11d7ca..1878112 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -64,6 +64,7 @@ jobs: odin check lua/global_variables $FLAGS odin check lua/hellope_lua $FLAGS + odin check lua/do_file $FLAGS odin check math/noise/draw_texture $FLAGS odin check math/rand/markov $FLAGS diff --git a/lua/do_file/do_file.odin b/lua/do_file/do_file.odin new file mode 100644 index 0000000..0c8c342 --- /dev/null +++ b/lua/do_file/do_file.odin @@ -0,0 +1,27 @@ +package hellope_lua + +import lua "vendor:lua/5.4" +import "core:fmt" + +// The file of code the Lua VM will run +FILE :: "main.lua" + +main :: proc() { + // Create new Lua state + state := lua.L_newstate() + + // Open the base libraries (print, etc...) + lua.open_base(state) + + // Run code and check if it succeeded + if lua.L_dofile(state, FILE) != 0 { + // Get the error string from the top of the stack and print it + error := lua.tostring(state, -1) + fmt.println(error) + // Pop the error off of the stack + lua.pop(state, 1) + } + + // Closes the Lua VM, deallocating all memory + lua.close(state) +} \ No newline at end of file diff --git a/lua/do_file/main.lua b/lua/do_file/main.lua new file mode 100644 index 0000000..cea47ad --- /dev/null +++ b/lua/do_file/main.lua @@ -0,0 +1,5 @@ +print(2+2) + +print(16*2) + +print("Here's some " .. "string concatenation!") \ No newline at end of file