Created
June 3, 2009 02:24
-
-
Save nilium/122739 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- woop | |
print("foobar") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment