Hey, i just want little help that is really important for me.
I'd like to ask one question about lua:
How do you know how many ends you put in your lua ?
Please help,
Thanks. Admin/mod comment
lua questions should go to the scripting forum... moved Tabbing, it really helps a lot. You count them
But it is best to tab everything to you can see if you have too many ends or if you have an if/function/for statement that has no end. Hmm.. I do it like that:
1
2
3
function lol() --first I write this
end -- then I write the end and just after that I move to the next code-block, in this case: UP
Lol, I do that too
Helps to promote well-kept/visible code Thanks DannyDeth,Pikachu xD.
it helped me :). DC Admin Offline
each if, each function and each loop-type (for/while/repeat) needs exactly one end to be ended.
if you know other programming languages like c(++), java(script), php, etc.: it's like the bracket stuff { }. Lua doesn't have these brackets and therefore it needs "end".
if/function/for/while/repeat is the opening bracket, end is the closing bracket. Thanks DC,
But i only use (If,Function)
i never used (for,while,repeat)
How can you not use For and While loops ( repeat isn't that commonly used, I get that. )? They are another very neccisary piece of code one should use. DC has written
each if, each function and each loop-type (for/while/repeat) needs exactly one end to be ended.
if you know other programming languages like c(++), java(script), php, etc.: it's like the bracket stuff { }. Lua doesn't have these brackets and therefore it needs "end".
if/function/for/while/repeat is the opening bracket, end is the closing bracket.
and what about programing language from Pascal? If you get Notepad++ you can see if you are lacking any ends or if you need more! SQ Moderator Offline
Steam Friends ADMIN has written
and what about programing language from Pascal?
It is slightly different.
In Pascal, each Begin requires End
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function NewDay() : Integer;
	var i : Integer;
		TempApples : InitArray;
	begin
		TempApples := Apples;
		for i := 1 to ApplesCount do
			begin
				if IsInArray(i) and TempApples[i] then
					begin
						Apples[i + 1] := true;
						Apples[i - 1] := true;
					end;
			end;
	end;