Skip to content

Instantly share code, notes, and snippets.

@nilium
Created June 3, 2009 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilium/122739 to your computer and use it in GitHub Desktop.
Save nilium/122739 to your computer and use it in GitHub Desktop.
SuperStrict
Function Script_Require:Int( lvm:Byte Ptr )
Local fname:String
While lua_gettop(lvm) > 0
fname = lua_tostring(lvm, -1)
lua_settop(lvm, -2)
If Not fname Then Throw "Invalid argument to require - nil"
If FileType(fname) <> FILETYPE_FILE Then Throw "Script ~q"+fname+"~q does not exist"
If lual_dofile(lvm, fname) Then Throw "Error executing script ~q"+fname+"~q: "+lua_tostring(lvm, -1)
Wend
Return 0
End Function
Function Main()
Local vm:Byte Ptr = lual_newstate()
luaopen_base(vm)
lua_pushcclosure(vm, Script_Require, 0)
lua_setglobal(vm, "require")
lua_dostring(vm, "require(~qtest.lua~q)")
lua_close(vm)
End Function
Main
-- woop
print("foobar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment