this lua contains lots of usefull functions, thats right!, FUNCTIONS
functions
misc.point_direction
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
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
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
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
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
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
misc.split_text("hello my name is EnderCrypt")
> table: {"hello","my","name","is","EnderCrypt"}
> table: {"hello","my","name","is","EnderCrypt"}
misc.isNearPlayers
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
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
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
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
misc.calcDamage(id,dmg)
processes dmg by players (id) armor
processes dmg by players (id) armor
example
(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
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
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
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
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...
edited 4×, last 22.12.13 10:29:29 pm
Approved by Yates
Download
4 kb, 394 Downloads