Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PopnSys(t1, t2) --starting function, t1 for ini parent aka [], t2 for = values like Command=diffuse,1,1,1,1;
- local song = GAMESTATE:GetCurrentSong();
- local RFU = RageFileUtil.CreateRageFile(); -- we are using rage to load the ini files
- local FFU = RageFileUtil.CreateRageFile();
- local CIE = RageFileUtil.CreateRageFile();
- if song then
- local songDir = song:GetSongDir(); -- geting song directory :P
- local a;
- -- MAIN CODE: PopnSys Character Loader - Jousway
- if CIE:Open(songDir.."Character/Character.ini","1") then -- check if simfile has ini
- RFU:Open(songDir.."Character/Character.ini","1"); -- load actual ini
- a = "true";
- else
- RFU:Open(THEME:GetPathO("","Character/Character.ini"),"1");
- a = "false";
- end;
- -- we need these!!
- local ReadChar = {};
- local TempChar;
- local i = 1;
- local v, v2, v3, v4, v5, v6; -- I know, its a lot -.-"
- FFU:Open(THEME:GetPathO("","Character/Character.ini"),"1"); -- opening fallback charcter.ini from Other folder in theme
- --ini gets loaded as a giant string
- for c in string.gmatch(RFU:Read(),"(.-)%\n") do --change string in to lines and put them in table
- v = string.match(c, "%[%a+%]"); -- Find ini [], Example [Win]
- if v then -- check if [] exists
- TempChar = v; -- define [] as a temp local
- else
- v2 = string.match(c, "(.+=.+)"); -- check if = exist, Example Command=diffuse,1,1,1,1
- if v2 then -- check if = exists
- ReadChar[i] = TempChar..v2; -- make table with combine [] and = depending on [], Example [Win] Command=diffuse,1,1,1,1
- i = i + 1;
- end;
- end;
- end;
- for c2=1,#ReadChar do -- for every ReadChar value do
- v3 = string.match(ReadChar[c2], "%[(.+)%].+"); -- define the v3 as the [] from ReadChar
- if v3 == t1 then -- Check if [] is value defined by t1 from PopnSys( "Win", "Command")
- v4 = string.match(ReadChar[c2], "%[.+%](.+)="); -- grab the value before the = and define it
- if v4 == t2 then -- check if value before the = is Command
- v5 = string.match(ReadChar[c2], "%[.+%].+=(.+).");
- v6 = string.match(FFU:Read(), "%["..t1.."%].-"..t2.."=(.-).%\n");--use fallback character.ini
- if v5 then -- check if there is a value after the =
- if a == "true" and CIE:Open(songDir.."Character/"..v5,"1") then
- PopnSysOutput = v5.."/"..a; -- puts out the value after the =
- else
- PopnSysOutput = v6.."/false"; -- puts out the value after the = from fallback
- end;
- else
- PopnSysOutput = v6.."/false"; -- same as above
- end;
- end;
- end;
- end;
- RFU:destroy(); -- destroying RFU file opening because else sm will crash because to many openned files
- FFU:destroy(); -- same as RFU
- else
- PopnSysOutput = ""; -- in case of no song for ScreenSelectMusic
- end;
- return PopnSysOutput; -- output the code
- end;
- function PopnLoad(t1, t2)
- local song = GAMESTATE:GetCurrentSong();
- if song then
- local songDir = song:GetSongDir();
- local FileCheck = RageFileUtil.CreateRageFile();
- if string.match(PopnSys(t1,t2), ".-/(.+)") == "true" then
- if FileCheck:Open(songDir.."Character/"..string.match(PopnSys(t1,t2), "(.-)/.+"),"1") then
- PopnLoadOutput = songDir.."Character/"..string.match(PopnSys(t1,t2), "(.-)/.+");
- else
- PopnLoadOutput = THEME:GetPathO("","Character/"..string.match(PopnSys(t1,t2), "(.-)/.+"));
- end;
- else
- PopnLoadOutput = THEME:GetPathO("","Character/"..string.match(PopnSys(t1,t2), "(.-)/.+"));
- end;
- end;
- return PopnLoadOutput;
- end;
- function PopnVal(t1, t2)
- local song = GAMESTATE:GetCurrentSong();
- if song then
- PopnValOutput = string.match(PopnSys(t1,t2), "(.-)/.+");
- else
- PopnValOutput = "";
- end;
- return PopnValOutput;
- end;
- function PopnCom(t1, t2, self)
- local song = GAMESTATE:GetCurrentSong();
- if song then
- for c in string.gmatch(PopnSys(t1,t2), "(.-);*") do
- Com = string.match(c, "(.-),.+");
- Do = string.match(c, ".-,(.-);");
- self:addcommand(tostring(Com),tostring(Do));
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement