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
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
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.
edited 1×, last 08.02.11 01:33:25 pm