local fh = "" local fho = "" local fhi = "" local fhe = "" local fhb = "" local fha = "" local line = "" local data = "" g_itemPath1 = {} local nonSpace = "aimain" local a = 0 local n = 0 local h = "" local o = "" local r1 = "" local r2 = "" local r3 = "" local g = {} local strSearch = "" local line1 = "" local line2 = "" local line3 = "" local xline = "" local zline = "" local scriptName = "" local i = 0 local plrFlag = "_markers\\player start.fpe" local fpeDirPath = "entitybank\\Barrels\\" local scriptDirPath = "scriptbank\\" local lenPath = 0 local indexOfChar = 0 local indexOfChar1 = 0 local f = "" local counter = 0 local globalvars_startflag = "--{globals_start}" local globalvars_endflag = "--{globals_end}" local globalVarName = "" local index_diff = 0 local c = nil local xlines = {} local line_init = "function update_globalvars_init(e)" local line_init_end = "end --init" local lineFunc = "function update_globalvars_main(e)" local lineFunc_end = "end --main" function all_in_one_init(e) end function all_in_one_main(e) end function getpath(e) fhi = io.open("filename_list.txt","w+") fhi:write(data) fhi:close() fhe = io.open("script_list.txt","w+") fhe:write(data) fhe:close() fha = io.open("globalvars_list.txt","w+") fha:write(data) fha:close() fPath = scriptDirPath .."update_globalvars.lua" fhb = io.open(fPath,"w+") fhb:write(data) fhb:close() for n = 1,g_EntityElementMax,1 do if g_Entity[n] ~= nil then g_itemPath[n] = GetEntityFilePath(n) if g_itemPath[n] ~= plrFlag then meshPath = tostring(g_itemPath[n]) if meshPath ~= "" then lenPath = string.len(meshPath) indexOfChar = string.find(meshPath,"\\", 1) + 1 indexOfChar1 = string.find(meshPath,"\\", indexOfChar) + 1 if indexOfChar1 ~= nil then meshPath = string.sub(meshPath,indexOfChar1,lenPath) strSearch = string.format('%s', meshPath) fho = io.open("filename_list.txt","a+") io.input(fho) if strSearch ~= nil then fho:write(strSearch .."\n") else break end fho:close() end -- indexOfChar1 end --meshPath ~= "" end --g_itemPath[n] ~= end --g_Entity[n] ~= nil end --for end --getpath function passglobals(e) for n = 1,g_EntityElementMax,1 do if g_Entity[n] ~= nil then g_itemPath1[n] = GetEntityFilePath(n) if g_itemPath1[n] ~= plrFlag then counter = g_EntityElementMax - 1 end end end local f = assert(io.open("filename_list.txt", "r")) -- dynamic entities fpe pathfiles list for line1 in f:lines() do if strSearch == nil then return end strSearch = string.format("%s",line1 ) strSearch = fpeDirPath ..strSearch local p = loadfile(strSearch) local h = assert(io.open(strSearch, "r")) -- opening fpe files for search wich script run each one. for line in h:lines() do if line == nil then return end xline = line:match( "^%s*(.-)%s*$" ) if string.find(xline,nonSpace) then lenPath = (string.len(xline)) indexOfChar = string.find(xline,"=") if indexOfChar ~= nil then if xline == nil then return end scriptName = string.sub(xline,indexOfChar+1,lenPath) zline = scriptName:match( "^%s*(.-)%s*$" ) if i <= (counter - 2) and zline ~= "" then i = i + 1 fho = io.open("script_list.txt","a+") io.input(fho) fho:write(zline .."\n") fho:close() break end end --indexOfChar end end --for line h:close() end --for line1 f:close() fx = assert(io.open("script_list.txt", "r")) for line2 in fx:lines() do if line2 == nil then return end if line2 ~= nil then line2 = scriptDirPath ..line2 o = loadfile(line2) r1 = assert(io.open(line2, "r")) data = r1:read'*all' indexOfChar = string.find(data,globalvars_startflag, 1) indexOfChar1 = string.find(data,globalvars_endflag, indexOfChar) end --Prompt(indexOfChar .." - " ..indexOfChar1) if indexOfChar ~= nil and indexOfChar1 ~= nil then start_lenght = string.len(globalvars_startflag) end_lenght = string.len(globalvars_endflag) index_diff = indexOfChar1 - indexOfChar globalVarName = string.sub(data,start_lenght+1,indexOfChar1-1) r2 = assert(io.open("globalvars_list.txt","a+")) io.input(r2) r2:write(globalVarName .."\n") r2:close() end end fx:close() end --passglobals function create_scriptfile(e) fPath = scriptDirPath .."update_globalvars.lua" d = countlines("globalvars_list.txt") r2 = assert(io.open("globalvars_list.txt","r")) io.output(r2) for line in r2:lines() do if line ~= "" then xline = line:match( "^%s*(.-)%s*$" ) if i <= d-2 then i = i + 1 r1 = assert(io.open(fPath,"a+")) io.input(r1) r1:write(xline .."\n") r1:close() end end end if c == nil then copyheader() c = 1 end end --main function countlines(filename) n = 1 for line in io.lines(filename) do print (line) if line ~= "" then n = n + 1 end end return n end function copyheader() r1 = assert(io.open(fPath,"a+")) io.input(r1) r3 = assert(io.open("body file.txt" ,"r")) io.output(r3) data1 = io.read() io.close(r3) r1:write(line_init .."\n") r1:write(line_init_end .."\n") r1:write(lineFunc .."\n") r1:write(data1 .."\n") r1:write(lineFunc_end .."\n") --h = h + 1 r1:close() end --create_scriptfile