Forum

> > CS2D > Scripts > Tabbed lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English Tabbed lua

6 replies
To the start Previous 1 Next To the start

old Tabbed lua

limonata
User Off Offline

Quote
Hi guys I sent a lua to an user in unreal software and he said me "put tabs" I couldnt understand then he sent me this.

"Tabbed" script:
1
2
3
4
5
6
addhook('say', 'ss')
function ss(id, text)
     if text == "Hello" then
          msg("hello")
     end
end

"Untabbed" script:
1
2
3
4
5
6
addhook('say', 'ss')
function ss(id, text)
if text == "Hello" then
msg("hello")
end
end

Now I want to learn will you use any program while you are making lua? If you are, then is program puts tabs automatically? or You are put with your hand ? And please tell me How I can convert any lua to tabbed.
Thanks.

old Re: Tabbed lua

Starkkz
Moderator Off Offline

Quote
I use Notepad++, but as far as I know it doesn't put automatically tabs. Anyway you can use the key that is at the left side of the "Q", it will make tabs.

Just make sure that you will put them after conditionals and functions.
1
2
3
4
5
6
7
8
function hereIsMyFunction()
	-- here comes the first tab
	if (my conditional) then
		-- the second tab
	end
	
	-- reduce to the first tab again
end

old Re: Tabbed lua

limonata
User Off Offline

Quote
hm Okay thanks for your reply. I use notepad too but it doesnt show mistake with red line or what else. When I trying the lua I see mistakes in console. But I want see before I work lua.

old Re: Tabbed lua

Starkkz
Moderator Off Offline

Quote
Well, it is because if you don't put tabs it won't throw you an error. Tabs are optional, but they can help you to find out what are the bugs on your script.

old Re: Tabbed lua

SD
User Off Offline

Quote
Tabbing your code won't help you to find errors, it will just make it readable for others. Unless you're writing in Python, of course. That way you must use proper indentation. So next time you're writing a script you're gonna upload somewhere (or send someone), it's always a very good idea to use correct or at least readable indentation.

old Re: Tabbed lua

FlammerD
User Off Offline

Quote
user SD has written
Tabbing your code won't help you to find errors, it will just make it readable for others.

old Re: Tabbed lua

ohaz
User Off Offline

Quote
user SD has written
Tabbing your code won't help you to find errors, it will just make it readable for others.
Not completely right. It might help you find errors when you're missing an "end" for example.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview