Hi S4Real
this is a script I was going to use to set the graphic setting in game, but Lee implemented it into the engine so I didn't bother. You can get the general idea from it, it can read a text file change what you need to and then write it back to the file. Hope its of use???
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Door Prompts 'Closed' can be opened with entity collected specified by 'USE KEY'
-- state to ensure user must release E key before can open/close again
keypress = 0
lowapplied = 0
inzone = 0
tContents = {}
local readfile = io.open("C:\\Program Files\\The Game Creators\\FPS Creator Reloaded\\visuals.ini", "r")
local writefile = io.open("C:\\Program Files\\The Game Creators\\FPS Creator Reloaded\\visuals.ini", "w")
sContent = readfile:read( "*all" )
function myentity_init(e)
-- must define myentityID in global.lua file for reference everywhere
myentityID = e;
end
function lowsetting_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist > 100 and lowapplied == 1 then
inzone = 1
end
if PlayerDist < 100 and keypress == 0 then
Prompt("Press E to apply LOW settings");
if g_KeyPressE == 1 then
for line in readfile:lines() do
table.insert (tContents,line)
end
readfile:close()
table.remove (tContents, 1)
table.insert (tContents, 1, "visuals.shaderlevels.terrain=4")
table.remove (tContents, 2)
table.insert (tContents, 2, "visuals.shaderlevels.entities=3")
table.remove (tContents, 3)
table.insert (tContents, 3, "visuals.shaderlevels.vegetation=3")
writefile:write(sContent)
writefile:close()
Prompt("LOW settings applied");
--Prompt(tContents[1]);
lowapplied = 1
keypress = 1
end
end
if PlayerDist < 100 and inzone == 1 then
Prompt("LOW settings have already been applied");
end
end
All programmers are playwrights and all computers are lousy actors.