Advertisement
Jousway

GetKey n GetKey2

Sep 21st, 2016
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. local function GetKey2(Button,Gametype,Player)
  2.     if FILEMAN:DoesFileExist("Save/Keymaps.ini") then
  3.         local keyini = IniFile.ReadFile("Save/Keymaps.ini");
  4.         str = string.match(keyini[Gametype][Player.."_"..Button], "Key_(.-):.");
  5.         if str then
  6.             return str;
  7.         else
  8.             return Button;
  9.         end;
  10.     else
  11.         return Button;
  12.     end;
  13. end;
  14.  
  15. local function GetKey(Button,Gametype,Player)
  16.     if FILEMAN:DoesFileExist("Save/Keymaps.ini") then
  17.         local keyini = RageFileUtil.CreateRageFile();
  18.         keyini:Open("Save/Keymaps.ini",1);
  19.         keyread = keyini:Read();
  20.         keyini:Close();
  21.         local ReadChar = {};
  22.         local TempChar;
  23.         local i = 1;
  24.         local v, v2, v3, v4, v5; -- I'm sorry :< -Jousway
  25.         for c in string.gmatch(keyread,"(.-)%\n") do --change string in to lines and put them in table
  26.             v = string.match(c, "%[%a+%]"); -- Find ini [], Example [dance]
  27.             if v then -- check if [] exists
  28.                 TempChar = v; -- define [] as a temp local
  29.             else
  30.             v2 = string.match(c, "(.+=.+)"); -- check if = exist, Example Command=diffuse,1,1,1,1
  31.                 if v2 then -- check if = exists
  32.                     ReadChar[i] =  TempChar..v2; -- make table with combine [] and = depending on [], Example [dance] 1_Left=Key_W
  33.                     i = i + 1;
  34.                 end;
  35.             end;
  36.         end;
  37.         for c2=1,#ReadChar do -- for every ReadChar value do
  38.             v3 = string.match(ReadChar[c2], "%[(.+)%].+"); -- define the v3 as the [] from ReadChar
  39.             if v3 == Gametype then -- Check if [] is dance
  40.                 v4 = string.match(ReadChar[c2], "%[.+%](.+)="); -- grab the value before the = and define it
  41.                 if v4 == Player.."_"..Button then -- check if value before the = is Button
  42.                     v5 = string.match(ReadChar[c2], "%[.+%].+=Key_(.-):.");
  43.                     if v5 then
  44.                         return v5;
  45.                     else
  46.                         return Button;
  47.                     end;
  48.                 end;
  49.             end;
  50.         end;
  51.     else
  52.         return Button;
  53.     end;
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement