Change lua config startup overwrite
This commit is contained in:
@@ -21,5 +21,6 @@ setglobal('manhattan_gen', "origin")
|
||||
setglobal('rochester_gen', "origin")
|
||||
setglobal('toledo_gen', "origin")
|
||||
|
||||
-- This Config File has currently no effect, because it has no integration
|
||||
-- Idea is to combine it with dofile to thn scripts
|
||||
-- This Config File effecting Character Animation References, Planet & Station Enviorments and Mission Cutscenes
|
||||
-- Files in DATA\SCRIPTS GCS,BASES and EXTRAS using these defined globals
|
||||
-- Included with dofile('..\\EXE\\REM\\Lua\\DYNAMIC\\config.lua') in .thn scripts
|
||||
@@ -26,72 +26,78 @@ rem.ConfigureWeaponFire({
|
||||
|
||||
-- Dynamic Enviroments and Characters
|
||||
|
||||
local char_gen = "trent"
|
||||
local fileChar = io.open(".\\REM\\Avatars\\characters.cfg", "w")
|
||||
if fileChar then
|
||||
fileChar:write(char_gen)
|
||||
fileChar:close()
|
||||
print("Setting Character to " .. char_gen)
|
||||
else
|
||||
print("Error while opening characters.cfg")
|
||||
-- Function to modify the config.lua file
|
||||
|
||||
function modifyLuaConfig(filePath)
|
||||
-- Read the file
|
||||
local file, err = io.open(filePath, "r")
|
||||
if not file then
|
||||
print("Error opening file: ".. err)
|
||||
return
|
||||
end
|
||||
|
||||
local gcs_state = "off"
|
||||
local fileGCS = io.open(".\\REM\\LUA\\DYNAMIC\\gcs_state.cfg", "w")
|
||||
if fileGCS then
|
||||
fileGCS:write(gcs_state)
|
||||
fileGCS:close()
|
||||
print("Setting gcs_state to " .. gcs_state)
|
||||
else
|
||||
print("Error while opening gcs_state.cfg")
|
||||
-- Read all lines from the file into a table
|
||||
local lines = {}
|
||||
for line in file:lines() do
|
||||
table.insert(lines, line)
|
||||
end
|
||||
file:close()
|
||||
|
||||
-- Get the current day and month
|
||||
local currentDay = os.date("%d")
|
||||
local currentMonth = os.date("%B")
|
||||
|
||||
-- Modify the lines as needed
|
||||
for i, line in ipairs(lines) do
|
||||
|
||||
-- Change day_gen to the current day
|
||||
if line:find("setglobal%('day_gen',") then
|
||||
lines[i] = "setglobal('day_gen', \"".. currentDay.. "\")"
|
||||
|
||||
-- Change months_gen to the current month
|
||||
elseif line:find("setglobal%('months_gen',") then
|
||||
lines[i] = "setglobal('months_gen', \"".. currentMonth.. "\")"
|
||||
|
||||
-- Change gcs_state to "off"
|
||||
elseif line:find("setglobal%('gcs_state',") then
|
||||
lines[i] = "setglobal('gcs_state', \"off\")"
|
||||
|
||||
-- Change char_gen to "trent"
|
||||
elseif line:find("setglobal%('char_gen',") then
|
||||
lines[i] = "setglobal('char_gen', \"trent\")"
|
||||
|
||||
-- Change gcs_voice to "trent"
|
||||
elseif line:find("setglobal%('gcs_voice',") then
|
||||
lines[i] = "setglobal('gcs_voice', \"trent\")"
|
||||
|
||||
-- Change anm_gen to "stand"
|
||||
elseif line:find("setglobal%('anm_gen',") then
|
||||
lines[i] = "setglobal('anm_gen', \"stand\")"
|
||||
|
||||
-- Change manhattan_gen, rochester_gen, toledo_gen to "origin"
|
||||
|
||||
elseif line:find("setglobal%('manhattan_gen',") then
|
||||
lines[i] = "setglobal('manhattan_gen', \"origin\")"
|
||||
elseif line:find("setglobal%('rochester_gen',") then
|
||||
lines[i] = "setglobal('rochester_gen', \"origin\")"
|
||||
elseif line:find("setglobal%('toledo_gen',") then
|
||||
lines[i] = "setglobal('toledo_gen', \"origin\")"
|
||||
end
|
||||
end
|
||||
|
||||
local months_gen = os.date("%B")
|
||||
local fileMonths = io.open(".\\REM\\LUA\\DYNAMIC\\months.cfg", "w")
|
||||
if fileMonths then
|
||||
fileMonths:write(months_gen)
|
||||
fileMonths:close()
|
||||
print("Setting Month to " .. months_gen)
|
||||
else
|
||||
print("Error while opening months.cfg")
|
||||
-- Write the modified lines back to the file
|
||||
file, err = io.open(filePath, "w")
|
||||
if not file then
|
||||
print("Error writing to file: ".. err)
|
||||
return
|
||||
end
|
||||
for _, line in ipairs(lines) do
|
||||
file:write(line.. "\n")
|
||||
end
|
||||
file:close()
|
||||
|
||||
print("File modified successfully.")
|
||||
end
|
||||
|
||||
local day_gen = os.date("%d")
|
||||
local fileDay = io.open(".\\REM\\LUA\\DYNAMIC\\day.cfg", "w")
|
||||
if fileDay then
|
||||
fileDay:write(day_gen)
|
||||
fileDay:close()
|
||||
print("Setting Day to " .. day_gen)
|
||||
else
|
||||
print("Error while opening day.cfg")
|
||||
end
|
||||
|
||||
local manhattan_gen = "origin"
|
||||
local fileManhattan = io.open(".\\REM\\LUA\\DYNAMIC\\manhattan.cfg", "w")
|
||||
if fileManhattan then
|
||||
fileManhattan:write(manhattan_gen)
|
||||
fileManhattan:close()
|
||||
print("Setting Manhattan Scene to " .. manhattan_gen)
|
||||
else
|
||||
print("Error while opening manhattan.cfg")
|
||||
end
|
||||
|
||||
local toledo_gen = "origin"
|
||||
local fileToledo = io.open(".\\REM\\LUA\\DYNAMIC\\toledo.cfg", "w")
|
||||
if fileToledo then
|
||||
fileToledo:write(toledo_gen)
|
||||
fileToledo:close()
|
||||
print("Setting Toledo Scene to " .. toledo_gen)
|
||||
else
|
||||
print("Error while opening toledo.cfg")
|
||||
end
|
||||
|
||||
local rochester_gen = "origin"
|
||||
local fileRochester = io.open(".\\REM\\LUA\\DYNAMIC\\rochester.cfg", "w")
|
||||
if fileRochester then
|
||||
fileRochester:write(rochester_gen)
|
||||
fileRochester:close()
|
||||
print("Setting Rochester Scene to " .. rochester_gen)
|
||||
else
|
||||
print("Error while opening rochester.cfg")
|
||||
end
|
||||
-- Execute modify function
|
||||
modifyLuaConfig(".\\REM\\LUA\\DYNAMIC\\config.lua")
|
||||
Reference in New Issue
Block a user