Guest User

PSP Lua lua_lib.c

a guest
Feb 12th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <pspkernel.h>
  2. #include <pspdebug.h>
  3. #include <pspdisplay.h>
  4.  
  5. #include "lua_lib.h"
  6.  
  7. #include "lua.h"
  8. #include "lualib.h"
  9. #include "lauxlib.h"
  10.  
  11. #define printf pspDebugScreenPrintf
  12.  
  13. extern int lua_print(lua_State *L)
  14. {
  15.     int arg_len = lua_gettop(L);
  16.     int n;
  17.     for (n=1; n <= arg_len; n++) {
  18.         printf("%s%s", lua_tostring(L, n), "\t");
  19.     }
  20.     printf("\n");
  21.     return 0;
  22. }
  23.  
  24. lua_State* lua_lib_newstate()
  25. {
  26.     lua_State* L;
  27.     L = luaL_newstate();
  28.     luaL_openlibs(L);
  29.    
  30.     lua_register(L, "print", lua_print);
  31.     lua_register(L, "isRunning", lua_isRunning);
  32.     lua_register(L, "setDebugScreen", lua_setDebugScreen);
  33.     lua_register(L, "vblank", lua_vblank);
  34.    
  35.     lua_register(L, "getPad", lua_getPad);
  36.     lua_register(L, "isKeyDown", lua_isKeyDown);
  37.    
  38.     return L;
  39. }
Add Comment
Please, Sign In to add comment