Forum

> > CS2D > Scripts > creating script
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch creating script

13 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Re: creating script

Avo
User Off Offline

Zitieren
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 Datei existiert nicht (10850).
2× editiert, zuletzt 10.04.12 14:20:32

alt Re: creating script

Avo
User Off Offline

Zitieren
@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
1× editiert, zuletzt 10.04.12 22:02:03

alt Re: creating script

Seekay
Reviewer Off Offline

Zitieren
Long text >

alt Re: creating script

Apache uwu
User Off Offline

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

alt Re: creating script

Avo
User Off Offline

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

alt Re: creating script

Apache uwu
User Off Offline

Zitieren
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

alt Re: creating script

Spook MQ Hacker
BANNED Off Offline

Zitieren
Hangoooovver : are you kidding me

Hangoooovver Says :
1
and do you know editor?

What are you talking about?
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht