Forum

> > CS2D > Scripts > creating script
Forums overviewCS2D overview Scripts overviewLog in to reply

English creating script

13 replies
To the start Previous 1 Next To the start

old Re: creating script

Avo
User Off Offline

Quote
You must know what are trying to do

• Read this: http://cs2d.com/tut/tkdlua/luatut.html
• Then download some easy scripts from the File Archive
• You should know that if you haven't programmed yet, it will be hard to learn. Be patient

One year ago when I started to script in lua (CS2D scripts), I have been creating script like this:
1
2
3
4
addhook("minute","info")
function info()
	msg("It's my own CS2D script!")
end

or:

1
2
3
4
5
6
7
8
addhook("say","weapon")
function iweapon(id,txt)
	if txt=="!help" then
		parse("equip "..id.." 69")
		parse("equip "..id.." 3")
		parse("equip "..id.." 41")
	end
end

Now I make scripts like my file cs2d [Bolt]Fun Zombie Mode or file File does not exist (10850).
edited 2×, last 10.04.12 02:20:32 pm

old Re: creating script

Avo
User Off Offline

Quote
@user Hangoooovver:
1
2
3
4
addhook("minute","info")
function info()
     msg("It's my own CS2D script!")
end
Shows every minute message "It's my won CS2D script!" to all players.

1
2
3
4
5
6
7
8
addhook("say","weapon")
function iweapon(id,txt)
     if txt=="!help" then
          parse("equip "..id.." 69")
          parse("equip "..id.." 3")
          parse("equip "..id.." 41")
     end
end
Equips player who say "!help" with items: 69 (machete),3 (deagle) and 41 (tactical shield)


If you ask what is it code:
CS2D execute code from lua scripts
edited 1×, last 10.04.12 10:02:03 pm

old Re: creating script

Seekay
Reviewer Off Offline

Quote
Long text >

old Re: creating script

Apache uwu
User Off Offline

Quote
Generally when I learn a new language I search for:

String Concatenation >

Variable Declaration >

Lexical Conventions >

Scopes >

IF Statement >

FOR Loop >


It also wouldn't hurt to read all the packaged lua function classes such as math, os, io, etc.

To really use lua, you need to understand how cs2d uses it as well with hooks. I'd say cs2d's addhook is similar to actionscript and javascripts "add listener".

old Re: creating script

Avo
User Off Offline

Quote
Write your script in notepad
Then save as *.lua
It's easiest way. You can also download lua editor, but I use notepad.

old Re: creating script

Apache uwu
User Off Offline

Quote
I have extensions shown which allows me to create .lua files without going through the process with notepad.

My Computer -> Tools -> View -> Hide Extensions For Known File Types -> Uncheck -> OK

old Re: creating script

Spook MQ Hacker
BANNED Off Offline

Quote
Hangoooovver : are you kidding me

Hangoooovver Says :
1
and do you know editor?

What are you talking about?
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview