Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. Pokes_Icons = {
  2. ["Bulbasaur"] = {
  3. on = 12906,
  4. off = 12908,
  5. used = 12907,
  6. }
  7. }
  8.  
  9. enum Pokes_Stats_t
  10. {
  11. OFFENSE = 0,
  12. DEFENSE,
  13. SPECIALATTACK,
  14. SPECIALDEFENSE,
  15. VITALITY,
  16. AGILITY,
  17. ICONON,
  18. ICONOFF,
  19. ICONUSE,
  20. TYPEONE,
  21. TYPETWO
  22. };
  23.  
  24. std::map <std::string, std::map <Pokes_Stats_t, int32_t> > pokeStat;
  25. bool loadPokes(){
  26. lua_State* L = lua_open();
  27. std::string pokeName = "";
  28. if(!L){
  29. return false;
  30. }
  31.  
  32. if(luaL_dofile(L, "Poke_Config.lua"))
  33. {
  34. lua_getglobal(L, "Pokes_Icons");
  35. lua_pushnil(L);
  36. while(lua_next(L, -2) != 0) {
  37. if(lua_istable(L, -1) && lua_isstring(L, -2)){
  38. pokeName = lua_tostring(L, -2);
  39. lua_pushnil(L);
  40. while(lua_next(L, -2) != 0) {
  41. if(lua_isnumber(L, -1) && lua_isstring(L, -2)){
  42. if(lua_tostring(L, -2) == "on"){
  43. pokeStat[pokeName][ICONON] = (int32_t)lua_tonumber(L, -1);
  44. }else if(lua_tostring(L, -2) == "off"){
  45. pokeStat[pokeName][ICONOFF] = (int32_t)lua_tonumber(L, -1);
  46. }else if(lua_tostring(L, -2) == "used"){
  47. pokeStat[pokeName][ICONUSE] = (int32_t)lua_tonumber(L, -1);
  48. }
  49. }
  50. lua_pop(L, 1);
  51. }
  52. }
  53. lua_pop(L, 1);
  54. }
  55. }
  56. lua_pop(L, 1);
  57. std::cout << pokeName << ": " << pokeStat["Bulbasaur"][ICONUSE] << std::endl;
  58. if(L)
  59. lua_close(L);
  60. }
  61.  
  62. Bulbasaur: 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement