Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions lua/do_file/do_file.odin
Original file line number Diff line number Diff line change
@@ -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)
}
5 changes: 5 additions & 0 deletions lua/do_file/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
print(2+2)

print(16*2)

print("Here's some " .. "string concatenation!")