Forum

> > CS2D > General > Lua scripting tutorial
ForenübersichtCS2D-ÜbersichtGeneral-ÜbersichtEinloggen, um zu antworten

Englisch Lua scripting tutorial

51 Antworten
Seite
Zum Anfang Vorherige 1 2 3 Nächste Zum Anfang

alt Lua scripting tutorial

ohaz
User Off Offline

Zitieren
I'm currently creating a little lua scripting tutorial, you could say a crash course.
You can see the current development status here and I would be happy if you would give me suggestions (or just try to learn it with this tutorial). Like I said, it's currently under development, so I'm at the moment at if-queries and while-loops.
Have fun learning lua

alt Re: Lua scripting tutorial

kikinep
User Off Offline

Zitieren
thx so much i be waiting for this too long thx really thx

@Edit:
heeeelp when i put this in my script:
1
2
3
4
5
6
7
----------------------
-- Join Player --
----------------------
addhook("say","adm.Join.say")
function adm.Join.say(id)
  msg("Player"..player(id,"name").."joined")
end

in the console say:
1
LUA ERROR: sys/lua/server.lua:337: attempt to index field 'Join' (a nil value)

plz help me!!!
1× editiert, zuletzt 22.06.09 19:11:50

alt Re: Lua scripting tutorial

horus
User Off Offline

Zitieren
How many projects are you running? You've got this and USCN running at the same time? xP
Still, I'm going to read some of it, since Lua hates me. No suggestions from me because I am to Lua as a child is to advanced calculus.

EDIT: Disregard that no suggestions part. How about a fully fleshed-out Lua script as an example that incorporates every part of the tutorial? [loaded with comments, naturally]

alt Re: Lua scripting tutorial

KimKat
GAME BANNED Off Offline

Zitieren
Well pretty nice tutorial... although there is one thing missing in my honest opinion. Pictures that show result of code, and thingies.

alt Re: Lua scripting tutorial

Flacko
User Off Offline

Zitieren
Sometimes I feel like it's very hard to teach how to program.
I liked your comparison of the boxes and variables, reminds me when I was 11 and it costed me like hell to figure out how to use them.
Goodluck with your tutorial

alt Re: Lua scripting tutorial

ohaz
User Off Offline

Zitieren
kikinep hat geschrieben
1
2
3
4
5
6
7
----------------------
-- Join Player --
----------------------
addhook("say","adm.Join.say")
function adm.Join.say(id)
  msg("Player"..player(id,"name").."joined")
end

in the console say:
1
LUA ERROR: sys/lua/server.lua:337: attempt to index field 'Join' (a nil value)

First thing: Why do you use "say" in addhook if you want to message a player who's joining?
second thing: I don't really see the problem, but I think it has to do with the dots in your function name. In Lua dots mean something like "sub"-variables.
Try out the following thing:
1
2
3
4
5
6
7
----------------------
-- Join Player --
----------------------
addhook("join","adm_Join_say") --use Join here, as you want the script to be started when someone joins
function adm_Join_say(id)
  msg("Player "..player(id,"name").." joined")
end

Zitat
How many projects are you running? You've got this and USCN running at the same time? xP
I'm running even more projects... there's a little bash site for the chat, and so on, and so on
Zitat
How about a fully fleshed-out Lua script as an example that incorporates every part of the tutorial?
Nice idea... I'm thinking about it
Zitat
Pictures that show result of code, and thingies.
You're talking about ingame pictures, or screenshots of the script?
Zitat
I liked your comparison of the boxes and variables, reminds me when I was 11 and it costed me like hell to figure out how to use them.
Yes, it's my personal favourite part of the tutorial

alt Re: Lua scripting tutorial

KimKat
GAME BANNED Off Offline

Zitieren
Your choice TheKilledDeath. You could do both, if you like. Nothing is better than a powerful and effective tutorial... and we live in the future (not to put to much work on you or anything). But I'd love some screenshots.

@horus: Stop being a wiseguy!
I ment that I wanted screenshots inside of the tutorial (like result of code and stuff), not just a plain text page.
1× editiert, zuletzt 25.06.09 20:30:06

alt Re: Lua scripting tutorial

horus
User Off Offline

Zitieren
Screenshots? Just click the link and you're there. xP
Could you find a different way to distinguish code from text? Because the bold doesn't [in my opinion] really stand out that much.

EDIT: Loving it so far! ^-^
There is, however, a little problem that many may find insignificant, but I think it's very significant indeed: the grammar. I know it isn't some essay for college, but this still annoys me a bit. There are several misuses of commas, which kind of throws me off while reading. Find an editor for it so it can be easier to read for people who can't understand something if there is a single grammar error.

EDITEDIT: Oh noes! I've found spelling errors!
They're really small ones, so I don't think anyone will notice. Anyone except me, of course.
2× editiert, zuletzt 22.06.09 22:51:14

alt Re: Lua scripting tutorial

ohaz
User Off Offline

Zitieren
Yes, I'm sorry for the mistakes, I'll read through it again and hope that I'll find some of them...
Zitat
if you could code the AMX way to, that would be useful.
Well... I never read any AMX code, so I don't really know how the AMX way is. But perhaps I'll add a section for it. But the primary aim of this tutorial is to show people how to script at all, not how to script in AMX way. Well, but let's see
Zitat
Because the bold doesn't [in my opinion] really stand out that much.
Yes, I thought so too, but I haven't found a better idea so far... but now as I think about it... I'll do it with tables!

alt Re: Lua scripting tutorial

Lee
Moderator Off Offline

Zitieren
Zitat
Well... I never read any AMX code, so I don't really know how the AMX way is. But perhaps I'll add a section for it. But the primary aim of this tutorial is to show people how to script at all, not how to script in AMX way. Well, but let's see


I've found that my amx2d is targeted at a lost audience, therefore I've stopped support of it, there's nothing really to learn of amx2d since it's just a collection of tools to help write cs2d-lua code for begginers. I can help you write a part of the tutorial for my amx mod. Also, if you need, I can also create the webdesign for the tutorial.

alt Re: Lua scripting tutorial

ohaz
User Off Offline

Zitieren
Would be a pleasure to work together with you
About the webdesign. The tutorial is currently just a *.html file, nothing more. So the only real way to make a design is with css and frames?

alt Re: Lua scripting tutorial

wups
User Off Offline

Zitieren
This is in the tutorial
1
2
3
4
addhook("say", "exerciseJoin") --of course the "exerciseJoin" doesn't need to have the same name at your script, the important thing is that you take the same name in the next line
function exerciseJoin(id)
   msg("Player "..player(id, "name").." joined")
end

Should it not be "join" instead of "say" in the hook?

alt Re: Lua scripting tutorial

wups
User Off Offline

Zitieren
I like the site, but it can be better.
And the colours remind me too much of futaba. :p

You should change colour on the background of the codebox.
So its easier to look at it. Then all other looks ok.


The only thing that mess up for the eyes is this
Zitat
addhook("say","tutorialsay")
text text text text text text
function tutorialsay(player, text)
text text text text text text
msg("Player "..player(player, "name").." said: "..text)
text text text text text text


Anything to work at?
Should looks better for the eye when reading
Zitat
addhook("say","tutorialsay")
text text text text text text

function tutorialsay(player, text)
text text text text text text

msg("Player "..player(player, "name").." said: "..text)
text text text text text text



TDK look at this codebox method:
http://www.sendspace.com/file/glorwk
2× editiert, zuletzt 23.06.09 09:59:26

alt Re: Lua scripting tutorial

Night Till Death
User Off Offline

Zitieren
TheKillerDeath cant you just make a video? i dont understand nothing! im russian for peat sake and i can only understand normal english word! plz make a video!

alt Re: Lua scripting tutorial

sonnenschein
User Off Offline

Zitieren
NTD hat geschrieben
yeah and if you can in russian plz!

maybe try to use google translator xDDD
i know its not best option, but try

BTW Nice tutorial TheKilledDeath
Zum Anfang Vorherige 1 2 3 Nächste Zum Anfang
Einloggen, um zu antwortenGeneral-ÜbersichtCS2D-ÜbersichtForenübersicht