• possible to write to the init.lua?
    9 replies, posted
Hey, I was wondering if it was possible to make an addon able to write to the init.lua file for a gamemode, in this case TTT.
What are you trying to do?
I thought you could only write to txt files in lua.
That's a really bad idea. So, you want an "addon" to be able to write to an init.lua file? Anyone else seeing a problem with this? You can't do it anyways. You can only do .txt files. Here's a quote from the Wiki. "You can only read/write text data. Binary data is not mutable inside Garry's Mod using the File library." "Your filenames MUST end in .txt" Nice try.
-snip- testing somethin
I do see why this could be a bad thing, which is why I figured they wouldn't allow it. I was trying to make an ingame check-box be able to change the convar in the init.lua so that you wouldn't have to change it every time the map switched. edit: Geez, I got such a negative response. I'm no hacker, just a mediocre addon writer. double edit: is there another way to get around my problem?
[QUOTE=CallMePyro;42581782]I do see why this could be a bad thing, which is why I figured they wouldn't allow it. I was trying to make an ingame check-box be able to change the convar in the init.lua so that you wouldn't have to change it every time the map switched. edit: Geez, I got such a negative response. I'm no hacker, just a mediocre addon writer. double edit: is there another way to get around my problem?[/QUOTE] [lua]RunConsoleCommand( "cvar", value )[/lua] On server.
but again, that would just change it to whatever variable I defined in the "RunConsoleCommand" parameters. I'm adding my own ConVar, and I'd like the toggle button I have be actually useful, instead of being forced to change it in the init.lua if you don't want to toggle it manually every map switch.
[lua]CreateConVar("convar", "1", {FCVAR_ARCHIVE})[/lua] It saves the values, on map switch, game exit and whatever.
[QUOTE=arcaneex;42582122][lua]CreateConVar("convar", "1", {FCVAR_ARCHIVE})[/lua] It saves the values, on map switch, game exit and whatever.[/QUOTE] Thank you very much!
Sorry, you need to Log In to post a reply to this thread.