Change lua config startup overwrite
This commit is contained in:
@@ -21,5 +21,6 @@ setglobal('manhattan_gen', "origin")
|
|||||||
setglobal('rochester_gen', "origin")
|
setglobal('rochester_gen', "origin")
|
||||||
setglobal('toledo_gen', "origin")
|
setglobal('toledo_gen', "origin")
|
||||||
|
|
||||||
-- This Config File has currently no effect, because it has no integration
|
-- This Config File effecting Character Animation References, Planet & Station Enviorments and Mission Cutscenes
|
||||||
-- Idea is to combine it with dofile to thn scripts
|
-- 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
|
-- Dynamic Enviroments and Characters
|
||||||
|
|
||||||
local char_gen = "trent"
|
-- Function to modify the config.lua file
|
||||||
local fileChar = io.open(".\\REM\\Avatars\\characters.cfg", "w")
|
|
||||||
if fileChar then
|
function modifyLuaConfig(filePath)
|
||||||
fileChar:write(char_gen)
|
-- Read the file
|
||||||
fileChar:close()
|
local file, err = io.open(filePath, "r")
|
||||||
print("Setting Character to " .. char_gen)
|
if not file then
|
||||||
else
|
print("Error opening file: ".. err)
|
||||||
print("Error while opening characters.cfg")
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 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
|
||||||
|
|
||||||
|
-- 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
|
end
|
||||||
|
|
||||||
local gcs_state = "off"
|
-- Execute modify function
|
||||||
local fileGCS = io.open(".\\REM\\LUA\\DYNAMIC\\gcs_state.cfg", "w")
|
modifyLuaConfig(".\\REM\\LUA\\DYNAMIC\\config.lua")
|
||||||
if fileGCS then
|
|
||||||
fileGCS:write(gcs_state)
|
|
||||||
fileGCS:close()
|
|
||||||
print("Setting gcs_state to " .. gcs_state)
|
|
||||||
else
|
|
||||||
print("Error while opening gcs_state.cfg")
|
|
||||||
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")
|
|
||||||
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
|
|
||||||
Reference in New Issue
Block a user