Forum

> > CS2D > General > Lua Scripts for CS2D
ForenübersichtCS2D-ÜbersichtGeneral-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts for CS2D

134 Antworten
Seite
Zum Anfang Vorherige 1 2 3 4 5 6 7 Nächste Zum Anfang

Umfrage Umfrage

What do you think about Lua support in CS2D?

Nur registrierte Benutzer können abstimmen
Awesome!
85,88% (225)
Sounds good.
7,25% (19)
Bad idea. I hate Lua!
3,44% (9)
I have no idea.
3,44% (9)
262 Stimmen abgegeben

alt geschlossen Umfrage Lua Scripts for CS2D

DC
Admin Off Offline

Zitieren
The next version of CS2D will support Lua scripting!
Lua is a very powerful and fast script language which is used in many games (like garry's mod or crysis).

You will be able to use Lua scripts for maps and on your server. Clients will not be able to write Lua scripts due to security reasons.

The whole system works with hooks/events (comparable with Stranded II scripting).

For example you can write a function hook_say in your Lua script. CS2D will always call this function when someone on your server says something. It also will automatically pass all information about this event as parameters to your Lua function.
For hook_say it's the ID of the player who says something and of course the actual message.

here is a Lua script example which is already working:
1
2
3
4
5
6
7
8
9
10
11
function hook_say(p,t)
	badwords = {"hitler","fuck","bitch","cunt","ass"};
	t=string.lower(t);
	for i = 1,#badwords,1 do
		if (string.find(t,badwords[i])~=nil) then
			parse("sv_msg \""..player(p,"name").." said a bad word ("..badwords[i]..")!\"");
			parse("kick "..p);
			break;
		end
	end
end
this script sends the message "XXX said a bad word (YYY)" and kicks the player who says one of the words in the badwords-table.

the command "parse" is used to execute normal cs2d commands within your lua script.

"player" is used to get information of a player with a certain id. in this case it gets the "name" of the player who said something. It can also be used to get infos like ip, ping, health, armor, position, team, look, weapons etc.

Lua scripting will make it possible to create own game mode mods and customizations for servers and very dynamic and interactive maps.
1× editiert, zuletzt 08.02.11 13:33:25

alt Re: Lua Scripts for CS2D

Thomazz
User Off Offline

Zitieren
so u can make ur own mod like Zombie Mod, which is already included, and other players can download it ?!

oh and why not writing in German ForumSection ?

alt Re: Lua Scripts for CS2D

PixelHunter
User Off Offline

Zitieren
This lua will includes:?
-weapon modifications
-variables, drawing varibles
-message to a specified player
-changing player stats like armor and health (pernamently to the round)
-and so on

alt Re: Lua Scripts for CS2D

Dyingwish
User Off Offline

Zitieren
i think lua scripts will make the complete game modable.
but you can script hacks or aimbots with it , this will be a problem.

alt Re: Lua Scripts for CS2D

Lee
Moderator Off Offline

Zitieren
sweet, did you use that wrapper from blitz or did you write your own wrapper?

Zitat
but you can script hacks or aimbots with it , this will be a problem.


Lua is only available on the server side, it's not a client side modification, and if I remember correctly, there are custom scoping of the lua hooks so it can't access all parts of the system, meaning there are some limitations to what you can and can't do with the script. (Apparently, the only accessor method currently exposed to the lua runtime is the parse function)

----------------

And one more thing, is there any chance that you can expose a few more accessor methods because imo only exposing the parse command to the runtime is pretty limited.

alt Re: Lua Scripts for CS2D

sonnenschein
User Off Offline

Zitieren
does this mean that I'm gonna need to learn how to script? i don't even know how to make simple command in Qbasic

*EDIT*
If i can't ask someone to make me a script, or its too hard, where can i learn Lua scripting

Dyingwish hat geschrieben
i think lua scripts will make the complete game modable.
but you can script hacks or aimbots with it , this will be a problem.

No, just server side, that means: no entering in servers that have hacking script. (but i think DC will add anti hack solution)

alt Re: Lua Scripts for CS2D

DC
Admin Off Offline

Zitieren
@Thomazz: No. You will not download anything. It is on the server and stays on the server.

@PixelHunter: You can't add new weapons or something like that. But you could extend the behaviour. For example you could add that a weapon teleports a player or pushs him (the whole thing is restricted to serverside stuff). Lua contains variables, tables (arrays), functions and much more.

@Dyingwish: It will neither make the game completely modable nor make script hacks etc. possible because it is serverside only! scripts just do not run clientside.

@leegao: I used the existing wrapper. It works pretty well and is very fast. This is just an example and of course it will be extended.

After defining all your hook functions you have to call updatehooks() in your Lua script. This will initialize the hooks (it sets flags in CS2D for hooks which are defined in your scripts. so CS2D will only try to run hook functions which are actually defined in your Lua scripts).
There are also hooks which are executed every second, every minute or even every frame, hooks for killing, joining, buying, building, using, spraying etc.

@LinuxGuy
Google for Lua tutorials. There are lots of tutorials online and there are also a lot of books you could read
1× editiert, zuletzt 21.02.09 23:45:03

alt Re: Lua Scripts for CS2D

chuico123
User Off Offline

Zitieren
OMG!!! (ô_Ô) <(:awesome!:) aaaaaaa!!!

as i have read until now i can just imagine how CS2D will be in the future!! this will make CS2D a lot more dynamic!!

any examples of what we could make? any ideas?

and about the hack thing that guy have said, as it is only serverside, if he hacks, speedhack for example, everyone in the server will be running fast! but only in that server

alt Re: Lua Scripts for CS2D

Lee
Moderator Off Offline

Zitieren
LinuxGuy hat geschrieben
If i can't ask someone to make me a script, or its too hard, where can i learn Lua scripting


The official documentation is on the lua homepage, the language is actually relatively easy to learn, straightforward and takes after what you would expect out of a structural language.

Zitat
After defining all your hook functions you have to call updatehooks() in your Lua script. This will initialize the hooks (it sets flags in CS2D for hooks which are defined in your scripts. so CS2D will only try to run hook functions which are actually defined in your Lua scripts).
There are also hooks which are executed every second, every minute or even every frame, hooks for killing, joining, buying, building, using, spraying etc.


Hmm, just for curiosity's sake, are there any variables that will be exposed to the lua runtime on a global scale and how detailed are the event connectors between lua and the actual game? (I know you've already mentioned position and command parsing, but will there be things like entity creation, variable manipulation, or things that are a bit more dynamic?)

Anyways, awsome add, can't wait to try it out.

alt Re: Lua Scripts for CS2D

DC
Admin Off Offline

Zitieren
I'm currently still planning and testing it so I can't tell much about that in detail.

Probably the next version will only allow pretty simple hooking which means just adding functionality without changing the existing and hard coded behaviors.

I'll try to give Lua access (read only) to all relevant game variables (which are pretty much).
just as example the values of a player which are currently available in Lua:
Zitat
name, ip, port, usgn, ping, idle, bot, team, look, x, y, rot, tilex, tiley, health, armor, money, score, deaths, teamkills, hostagekills, teambuildingkills, weaponid, weapontype, nightvision, defusekit, bomb, flag, reloading, process, sprayname, spraycolor, votekick, votemap, favteam

in fact you have to use a function to get these values. they are not available as normal Lua variables because it could be fatal for some values to change them in the wrong moment etc. But of course there will be also a lot of commands to change important values. Like changing the position of a player.

Most commands will be regular CS2D commands which can be used in Lua with parse. This has the advantage that you can use them in your Lua scripts and in the old school cs2d scripts for binds etc.

All commands to get values will be pure Lua commands since cs2d script does not even support variables.

alt Re: Lua Scripts for CS2D

-Skull_
User Off Offline

Zitieren
ermm..dc after u added the lua script will it become 6mb or something example:Now i download cs2d only 5mb after you added the lua script it become 6mb

alt Re: Lua Scripts for CS2D

DC
Admin Off Offline

Zitieren
lol... no, Lua is pretty small. The size of the exe file will grow just some kb. You will probably not even notice it.

alt Re: Lua Scripts for CS2D

chuico123
User Off Offline

Zitieren
CS2D is getting each time cooler and cooler, its awesome how CS2D inproves itself at each release

just for some curiosity, will the server be able to make single player maps? and if it is online, make all the players join a single team and then co-operate, just like in Left 4 Dead, where u can play multiplayer, but still in a campaign whit objectives that are not team based, in my mind the idea is perfect, but i cant explain it correctly in words, if you didnt understand please tell me

alt Re: Lua Scripts for CS2D

DC
Admin Off Offline

Zitieren
Well I don't really want comment that. It's too early to say something about it. Adding a singleplayer mode/campaign and a coop mode is an option but I'm not sure if it's going to happen.

alt Re: Lua Scripts for CS2D

chuico123
User Off Offline

Zitieren
-Skull_ hat geschrieben
how can i edit those script?


wait until it releases it! probably there will be a "readme" file for further explanation about the scripting and also for help

EDIT: if it is possbile please make it! im sure it will be a great success! single-player mode is very expected, then is just up to us to make the maps and the scripting

ok now im going to prepare myself and im going to learn some Lua scripting

alt Re: Lua Scripts for CS2D

mrc1
COMMUNITY BANNED Off Offline

Zitieren
well, its possible to separate for example,
for fun gaming and professional playing...?
i dont understand it very well, or its just
to make mods?

alt Re: Lua Scripts for CS2D

Matsu-Kiri
User Off Offline

Zitieren
how hard can it be to make a campaign map is in cs2d now? just play offline with bots and make like, if u blow up this box u win or watever, simple
Zum Anfang Vorherige 1 2 3 4 5 6 7 Nächste Zum Anfang
Einloggen, um zu antwortenGeneral-ÜbersichtCS2D-ÜbersichtForenübersicht