![us](img/ulogosmall.gif)
![us](img/ulogosmall.gif)
this lua contains lots of usefull functions, thats right!, FUNCTIONS
![](img/smiles/ugly.gif)
functions ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.point_direction ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.point_direction(x1,y1,x2,y2)
returns the direction from x1,y1 towards x2,y2
returns the direction from x1,y1 towards x2,y2
misc.lengthdir_x ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.lengthdir_x(dir,length)
this one is more difficult to explain..., ill have to give you an example
this one is more difficult to explain..., ill have to give you an example
example ![>](img/i_plus.png)
![>](img/i_plus.png)
addhook("attack","example_attack")
function example_attack(id)
rotation = player(id,"rot")
x = player(id,"x") + misc.lengthdir_x(rotation,5)
y = player(id,"y") + misc.lengthdir_y(rotation,5)
parse("setpos "..id.." "..x.." "..y)
end
function example_attack(id)
rotation = player(id,"rot")
x = player(id,"x") + misc.lengthdir_x(rotation,5)
y = player(id,"y") + misc.lengthdir_y(rotation,5)
parse("setpos "..id.." "..x.." "..y)
end
misc.lengthdir_y ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.lengthdir_y(dir,length)
this one is more difficult to explain..., ill have to give you an example
this one is more difficult to explain..., ill have to give you an example
example ![>](img/i_plus.png)
![>](img/i_plus.png)
addhook("attack","example_attack")
function example_attack(id)
rotation = player(id,"rot")
x = player(id,"x") + misc.lengthdir_x(rotation,5)
y = player(id,"y") + misc.lengthdir_y(rotation,5)
parse("setpos "..id.." "..x.." "..y)
end
function example_attack(id)
rotation = player(id,"rot")
x = player(id,"x") + misc.lengthdir_x(rotation,5)
y = player(id,"y") + misc.lengthdir_y(rotation,5)
parse("setpos "..id.." "..x.." "..y)
end
misc.split_text ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.split_text(text)
splits a string at every space, and puts it into a table
splits a string at every space, and puts it into a table
example ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.split_text("hello my name is EnderCrypt")
> table: {"hello","my","name","is","EnderCrypt"}
> table: {"hello","my","name","is","EnderCrypt"}
misc.isNearPlayers ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.isNearPlayers(x,y,dist)
checks if theres any players near x,y, with dist, as max distance away, checks using a rectangular hitbox, good for collision checking with players, returns id of player near, or 0 if nobody
checks if theres any players near x,y, with dist, as max distance away, checks using a rectangular hitbox, good for collision checking with players, returns id of player near, or 0 if nobody
misc.round ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.round(num,[base])
rounds of num, to the nearest integer, if base is specifid, keeps as many decimals
rounds of num, to the nearest integer, if base is specifid, keeps as many decimals
misc.debugImage ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.debugImage(x,y,r,g,b,t)
good for debuging x,y locations, places a dot on the desired x, y, with color r, g, b, and optinal t , timer (1000 = 1 second), 1 second is default (all players have this GFX)
good for debuging x,y locations, places a dot on the desired x, y, with color r, g, b, and optinal t , timer (1000 = 1 second), 1 second is default (all players have this GFX)
Spoiler ![>](img/i_plus.png)
![>](img/i_plus.png)
im not gonna explain
misc.hudText(id,pid,text,x,y,align)
misc.hudTextFade(id,pid,duration,alpha)
misc.hudTextColor(id,pid,duration,r,g,b)
misc.explosion(x,y,size,dmg,src)
it should be self explainatory...
misc.hudText(id,pid,text,x,y,align)
misc.hudTextFade(id,pid,duration,alpha)
misc.hudTextColor(id,pid,duration,r,g,b)
misc.explosion(x,y,size,dmg,src)
it should be self explainatory...
misc.calcDamage ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.calcDamage(id,dmg)
processes dmg by players (id) armor
processes dmg by players (id) armor
example ![>](img/i_plus.png)
![>](img/i_plus.png)
(assuming player 1 has heavy armor)
misc.calcDamage(1,100)
> 25 (heavy armour would remove 75% dmg)
misc.calcDamage(1,100)
> 25 (heavy armour would remove 75% dmg)
misc.colorTextPercent ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.colorTextPercent(percent)
returns a color value, from red to green, (0 to 100)
returns a color value, from red to green, (0 to 100)
example ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.colorTextPercent(0)
> ©255000000 (string)
misc.colorTextPercent(50)
> ©128128000 (string)
misc.colorTextPercent(100)
> ©000255000 (string)
> ©255000000 (string)
misc.colorTextPercent(50)
> ©128128000 (string)
misc.colorTextPercent(100)
> ©000255000 (string)
misc.eval ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.eval(text) (equivalent to javascript eval)
evaluates a string (or table, every index is a line)
evaluates a string (or table, every index is a line)
misc.addServerTransfer ![>](img/i_plus.png)
![>](img/i_plus.png)
misc.addServerTransfer(image)
adds image, or sfx, to servertransfer.lst
important: this function is disabled by default, to enable it, uncomment it
important2: by enabling it, servertransfer.lst WILL be cleared every time a servers starts
important3: sense CS2D reads servertransfer.lst BEFORE starting lua, you may need to start you server twice
adds image, or sfx, to servertransfer.lst
important: this function is disabled by default, to enable it, uncomment it
important2: by enabling it, servertransfer.lst WILL be cleared every time a servers starts
important3: sense CS2D reads servertransfer.lst BEFORE starting lua, you may need to start you server twice
and a few more...
4× editiert, zuletzt 22.12.13 22:29:29
Zugelassen von Yates
Download
4 kb, 378 Downloads