Forum

> > CS2D > Scripts > lua: how many ends
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch lua: how many ends

11 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

verschoben lua: how many ends

Homam
User Off Offline

Zitieren
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 Kommentar

lua questions should go to the scripting forum... moved

alt Re: lua: how many ends

DannyDeth
User Off Offline

Zitieren
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.

alt Re: lua: how many ends

Yasday
User Off Offline

Zitieren
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

alt Re: lua: how many ends

DC
Admin Off Offline

Zitieren
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.

alt Re: lua: how many ends

DannyDeth
User Off Offline

Zitieren

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.

alt Re: lua: how many ends

Jezis
User Off Offline

Zitieren
DC hat geschrieben
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?

alt Re: lua: how many ends

Arne
User Off Offline

Zitieren
If you get Notepad++ you can see if you are lacking any ends or if you need more!

alt Re: lua: how many ends

SQ
Moderator Off Offline

Zitieren
Steam Friends ADMIN hat geschrieben
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;
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht