I’m trying to edit some LUA files that I got from a gamemode just for fun but I find it really hard to get a nice structure on the code since all of it is just moshed together in a big mess.
Is there any way to structure the code in the LUA files easily?
If you’re talking about how you should whitespace your code, this is how I do it. If you’re going to structure already existing code, you need to probably use search & replace.
[lua]
function SomeFunction(args, stuff, moar)
if(stuff == true) then
print(args, stuff, moar);
else
print(“Too bad”);
end
Hey, thanks for the reply!
I’m very new with this, I just want to add some things to the code of a gamemode but I can’t really find a pattern in the code since it’s just messed up. I’m trying to edit the init.lua file but the code is really long in a very few rows, I want to get the code easier to read somehow.
Can I ask what program are you using when you’re editing code etc? I just use the notepad lol, I guess you’re using something else xD As I said, I’m a big newbie to this.
Whenever someone asks me about coding ethics, I always tell them the ten commandments of Lua scripting that I follow:
1.) For every function, thoust must end it.
2.) For every if-statement, thoust must end it.
3.) For every do-statement, thoust must end it.
4.) Thoust shall tab everything inside a function.
5.) Thoust shall tab everything inside an if-statement.
6.) Thoust shall tab everything inside a do-statement.
7.) Thoust shall leave a blank spot between function blocks
8.) Thoust shall block code of a similar intent
9.) Thoust shall keep simple statements in a single line (if not Var then Var = Value end)
10.) Thoust shall always optimize
Don’t use any kind of NP++ plugin that shows you the functions, I have never have. You don’t really need to… or maybe I’ve just been coding Lua for GMod for so long that I know everything off by heart… oh how sad.