Changes:
- The path for all files the program uses can be changed.
Posted 31 July 2015 - 05:10 PM
Posted 01 January 2016 - 03:33 AM
Edited by moomoomoo309, 01 January 2016 - 03:39 AM.
Posted 30 May 2016 - 03:25 AM
Edited by moomoomoo309, 30 May 2016 - 12:13 PM.
Posted 01 June 2016 - 12:17 AM
Edited by moomoomoo309, 01 June 2016 - 12:17 AM.
Posted 01 June 2016 - 01:31 PM
Posted 25 July 2016 - 03:01 AM
local function splitStr(str,char) --#Converts str into a table given char as a delimiter. local tbl={} local findChar=str:find(char) local findChar2 if findChar then table.insert(tbl,str:sub(1,findChar-1)) repeat findChar2=str:find(char,findChar+#char) if findChar2~=nil then table.insert(tbl,str:sub(findChar+1,findChar2-1)) findChar=findChar2 end until findChar2==nil table.insert(tbl,str:sub(findChar+#char)) else return {str} end return tbl end local function exportVar(varName,filePath,silent,printFct) printFct=type(printFct)=="function" and printFct or print local shortVarName=varName:sub(1,(varName:find"%." or (#varName+1))-1) local var=rawget(_G,shortVarName) or rawget(_ENV,shortVarName) --#Check locals and globals if var~=nil then --#It's allowed to be false, so an explicit nil check is needed. local outString="" if type(var)=="table" and varName:find"%." then local fields=splitStr(varName,"%.") for i=2,#fields do var=var[tonumber(fields[i]) or fields[i]] end end outString=type(var)=="table" and textutils.serialize(var) or type(var)=="function" and string.dump(var) or tostring(var) local success,errMessage=pcall( --#Try to write it to a file, and catch any errors if necessary. function() if type(filePath)=="string" and #filePath>0 then local f=fs.open(filePath,"w") f.write(outString) f.close() else error(("File path \"%s\" not a valid path!"):format(tostring(filePath))) end end ) if not silent then if not success then printFct(("Error writing to file! Error message: \"%s\""):format(errMessage)) else printFct(("Variable \"%s\" written to file at %svars/%s"):format(varname,ConfigFolder,varName)) end end return outString elseif not silent then printFct(("The variable \"%s\" doesn't exist or is nil."):format(varName)) end end
Edited by moomoomoo3O9, 31 July 2016 - 09:37 PM.
Posted 04 April 2017 - 04:12 PM
Posted 17 May 2017 - 08:17 PM
Edited by moomoomoo3O9, 17 May 2017 - 08:18 PM.
Posted 04 July 2018 - 01:50 PM
Posted 04 July 2018 - 08:13 PM
bradster2214, on 04 July 2018 - 01:50 PM, said:
Edited by moomoomoo3O9, 06 July 2018 - 10:18 PM.
0 members, 1 guests, 0 anonymous users