Advertisement
MageKing17

lua.cpp.patch

Feb 16th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.26 KB | None | 0 0
  1. Index: code/parse/lua.cpp
  2. ===================================================================
  3. --- code/parse/lua.cpp  (revision 11247)
  4. +++ code/parse/lua.cpp  (working copy)
  5. @@ -11619,6 +11619,39 @@
  6.     return ADE_RETURN_NIL;
  7.  }
  8.  
  9. +ADE_FUNC(getButtonControl, l_Control_Info, "number, string", "Reads the defined button control from lua button control data; if number is -1 it tries to use the string", "boolean", "Whether or not the given control is pressed.")
  10. +{
  11. +   int index;
  12. +   char *buf = NULL;
  13. +   int a, b;
  14. +
  15. +   if(!ade_get_args(L, "i|s", &index, &buf))
  16. +       return ADE_RETURN_NIL;
  17. +
  18. +   if(index != -1) {
  19. +       // Process the number
  20. +       if (index > (4 * 32))
  21. +           return ADE_RETURN_NIL;
  22. +
  23. +       a = index / 32;
  24. +       b = index % 32;
  25. +   } else if (buf != NULL) {
  26. +       int i;
  27. +       for(i=0; i<num_plr_commands; i++) {
  28. +           if(!(strcmp(buf, plr_commands[i].name))) {
  29. +               a = plr_commands[i].var;
  30. +               b = plr_commands[i].def % 32;
  31. +               break;
  32. +           }
  33. +       }
  34. +       if (i == num_plr_commands) {
  35. +           return ADE_RETURN_NIL;
  36. +       }
  37. +   }
  38. +
  39. +   return ade_set_args(L, "b", Player->lua_bi.status[a] & (1<<b));
  40. +}
  41. +
  42.  ADE_FUNC(getButtonControlName, l_Control_Info, "number", "Gives the name of the command corresponding with the given number", "string", "Name of the command")
  43.  {
  44.     int index;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement