Proxy
Alters a value based on a mathematical expression.
For the sake of simplicity, the easy setup section has been ignored. However, anyone may edit this page to describe it.
Location
This part can be found under:
- :poseparameter: Modifier > Proxy
You can easily find it by clicking on the sign and typing proxy.
Usage & Examples
Basic proxy
- Add a Proxy part to an existing part
- Enter the name of the value with you want changed into variable name or click the button to browse available part parameters
Download: proxy_basic.txt
Proxy targets
Proxies can affect parts that are not directly connected to them. Enter the name of the part into target-part or select it with the button.
Download: proxy_target.txt
Button Controlled Proxy - Simple Switch
Simple proxy switch. Press R and T to change size.
Download: proxy_button.txt
Button Controlled Proxy - Feedback + Command
The command() proxy can be changed at any time by using console commands, it can be used together with feedback() to affect the previous proxy value. Below you'll find a simple example that lets you change the scale of a model using buttons (Hold F to scale up and R to scale down.)
Download: proxy_button_feedback.txt
Affect children
Affect children sets the proxy to affect all of its children instead of the parent. This also disables the target part field.
Multiple axes
Each proxy can use up to 3 expressions, one for each axis (X, Y, Z). These expressions need to be separated with a comma , Setting a value as nil or null will ignore the given axis.
Expression set to time(), null, 2+2 will set the X axis to time(), ignore the Y axis and set the Z axis to 4.
Download: proxy_axis.txt
Functions and Operations
The following is a list of operations/functions available to use in the expression
Operation | Operator | Example |
---|---|---|
Multiplication | * | time()*2 |
Division | / | time()/2 |
Addition | + | time()+2 |
Subtraction | - | time()-2 |
Parentheses | () | 3*(time()+2) |
Exponent | ^ | time()^2 |
Modulus | % | time()%2 |
To use, enter an input value or expression between the parenthesis. Remember to respect the number of arguments in the function, since not all functions have one argument. clamp(x, min, max) for example has three arguments.
Function | Explanation |
---|---|
abs(x) | Returns the absolute value of a given number. x — a number |
sgn(x) | Returns the sign of the given number (-1 for values below 0, 0 for 0 and 1 for values above 0). x — a number |
ceil(x) | Rounds a number up. x — a number |
floor(x) | Rounds a number down. x — a number |
min(numbers) | Returns the smallest value of all arguments. numbers — numbers to get the smallest from, separated with a comma (,) |
max(numbers) | Returns the largest value of all arguments. numbers - numbers to get the largest from, separated with a comma (,) |
clamp(x, min, max) | Clamps a number between a minimum and maximum value. x - the input value/function min - the minimum value that the function can return max - the maximum value that the function can return |
PI | This is NOT a function, it's a variable containing the mathematical constant pi. |
log(x, base) | With one argument, returns the natural logarithm of x (to base e). With two arguments, returns the logarithm of x to the given base. x - a number base - the logarithmic base, optional |
log10(x) | Returns the base-10 logarithm of x. This is usually more accurate than log(x, 10). x — a number |
sqrt(x) | Returns the square root of the number. x - a number |
rand(m, n) | When called without arguments returns a random float between 0 and 1. When called with one argument (m) returns an integer between 1 and m. When called with both arguments (m and n) returns an integer between m and n. m - lower limit (two arguments) or upper limit (one argument) n - upper limit |
randx(min, max) | Returns a random float between min and max. min - the minimum value max - the maximum value |
rad(x) | Returns the value converted to radians. x - the angle measured in degrees |
deg(x) | Returns the value converted to degrees. x - the angle measured in radians |
sin(x) | Returns the sine of a given angle. x - angle in radians |
asin(sin) | Returns the arc sine (an angle in radians, between -PI/2 and PI/2, which has the given sine value). NaN if the argument is out of range. sin - sine value in range of -1 to 1 |
sinh(x) | Returns the hyperbolic sine of the given angle. x - angle in radians |
cos(x) | Returns the cosine of a given angle. x - angle in radians |
acos(cos) | Returns the arc cosine (an angle in radians, between 0 and PI, which has the given cosine value). NaN if the argument is out of range. cos - cosine value in range of -1 to 1 |
cosh(x) | Returns the hyperbolic cosine of the given angle. x - angle in radians |
tan(x) | Returns the tangent of a given angle. x - angle in radians |
atan(tan) | Returns the arc tangent (an angle in radians, between -pi/2 and pi/2, which has the given tangent value). tan - a tangent value |
atan2(y, x) | Returns the 2-argument arc tangent (the angle of the line from (0, 0) to (x, y) in radians, between -PI and PI). y - Y coordinate x - X coordinate |
tanh(x) | Returns the hyperbolic tangent of the given angle. x - angle in radians |
Miscellaneous Functions
Remember to include the parentheses for each function even if there is nothing between them. Most of these are nullary functions (without arguments) but they are nevertheless Lua functions that need to be written with proper syntax to be interpreted as such.
Function | Explanation |
---|---|
aim_length() | Returns the distance between a model and the point it is aiming at (aim direction is defined by the red arrow). Maximum distance is 16000. |
aim_length_fraction() | Same as above but outputs a fraction calculated from distance/16000. |
ambient_light_r() | Returns the RED color value of the ambient color of the map. |
ambient_light_g() | Returns the GREEN color value of the ambient color of the map. |
ambient_light_b() | Returns the BLUE color value of the ambient color of the map. |
command() | Can be controlled by the pac_proxy <name> <value> console command. <name> is name of the proxy part you want to affect <value> is the value you want to set it to. |
eye_angle_distance() | Returns the normalized distance between the object and the view angle. Looking directly at the object equals 0.5, looking away from the object lowers the value. There is no negative values so an object that is directly behind your view angle also equals 0.5. |
eye_position_distance() | Returns the distance between the object and the view position. |
feedback() | Returns the proxy's previous value. |
feedback_x() or feedback_y() or feedback_z() | Returns the proxy's previous value on a given axis. |
framenumber() or fnumber() | Returns the number of frames rendered since the game was launched. |
frametime() or ftime() | Returns the time in seconds it took to render the last frame. Equal to FrameTime |
hsv_to_color(h, s, v) | Converts HSV formatted color into RGB formatted color. Returns red, green, blue. h - color hue, from 0 to 360 s - color saturation, optional, from 0 to 1, default is 1 v - color value, optional, from 0 to 1, default is 1 |
lerp(f, start, end) | Linear interpolation from one value to another. f - the fraction for finding the result start - the starting number, the result will be equal to this when f is 0 end - the ending number, the result will be equal to this when f is 1 |
light_amount_r() | Returns the RED color value of the light amount at the current position of the object. |
light_amount_g() | Returns the GREEN color value of the light amount at the current position of the object. |
light_amount_b() | Returns the BLUE color value of the light amount at the current position of the object. |
light_value() | Returns the light value in 0 to 1 range. |
owner_armor() | Returns the amount of player's armor. |
owner_eye_angle_pitch() | Returns the pitch value of the owner's eye angle in the -0.0056179768 (looking down) to 1.0056179768 (looking up) range. This is limited to 0-1 (89°) for players. |
owner_eye_angle_yaw() | Returns the yaw value of the owner's eye angle in the -2 to 2 range. Multiply by 90 to match object's yaw to owner's yaw. |
owner_eye_angle_roll() | Returns the roll value of the owner's eye angle in the -2 to 2 range. Multiply by 90 to match object's roll to owner's roll. |
owner_fov() | Returns the owner's field of view value. |
owner_health() | Returns the owner's health value. |
owner_max_health() | Returns the owner's maximum health value. |
owner_position() | Returns the owner's X,Y,Z position. |
owner_scale_x() or owner_scale_y() or owner_scale_z() | Returns the owner's scale on a given axis. |
visible() | Outputs whether the part is visible within a radius | radius | x |
time() | Outputs a time value that is not synced/affected by the game ( equal to RealTime ) | x | |
synced_time() | Outputs a time value that is synced to the game ( equal to CurTime ) | x | |
systime() or stime() | Returns a highly accurate time in seconds since the start up | ||
frametime() or ftime() | Returns the CurTime-based time in seconds it took to render the last frame. Equal to FrameTime | ||
framenumber() or fnumber() | Returns the number of frames rendered since the game was launched. | ||
random() | Quickly outputs random numbers between 0 and 1 | x | |
timeex() | Outputs a time value that begins to count the seconds when the proxy is shown | x | |
eye_position_distance() | Outputs the distance between the part and eye position | x | |
eye_angle_distance() | Outputs the distance between the part and eye angle | x |
owner_velocity_length() | Outputs the velocity of the owner, in any direction | x | |
owner_velocity_forward() | Outputs the velocity of the owner, either forwards or backwards | x | |
owner_velocity_right() | Outputs the velocity of the owner, either right or left | x | |
owner_velocity_up() | Outputs the velocity of the owner, either up or down | x | |
owner_velocity_length_increase() | Outputs the velocity of the owner, in any direction ( additive ) | x | |
owner_velocity_forward_increase() | Outputs the velocity of the owner, either forwards or backwards ( additive ) | x | |
owner_velocity_right_increase() | Outputs the velocity of the owner, either right or left ( additive ) | x | |
owner_velocity_up_increase() | Outputs the velocity of the owner, either up or down ( additive ) | x | |
parent_velocity_length() | Outputs the velocity of the parent part, in any direction | x | |
parent_velocity_forward() | Outputs the velocity of the parent part, either forwards or backwards | x | |
parent_velocity_right() | Outputs the velocity of the parent part, either right or left | x | |
parent_velocity_up() | Outputs the velocity of the parent part, either up or down | x | |
voice_volume() | Outputs a number between 0 and 1 based on the owner's voice chat microphone input | x | |
owner_health() | Outputs how much health the owner has | x | |
owner_armor() | Outputs how much armor the owner has | x | |
player_color_r() | Outputs the red value of the owner's player color ( between 0 and 1 ) | x | |
player_color_g() | Outputs the green value of the owner's player color ( between 0 and 1 ) | y | |
player_color_b() | Outputs the blue value of the owner's player color ( between 0 and 1 ) | z | |
weapon_color_r() | Outputs the red value of the owner's weapon color ( between 0 and 1 ) | x | |
weapon_color_g() | Outputs the green value of the owner's weapon color ( between 0 and 1 ) | y | |
weapon_color_b() | Outputs the blue value of the owner's weapon color ( between 0 and 1 ) | z |
Remember that all of the functions above can be mixed together, you can use one function as input for another, add functions together, etc.
Expression Examples
Clamp (Min/Max Value)
Example: clamp(5 + timeex(), 5, 10)
When shown, the proxy starts at 5 and moves up over time thanks to timeex(), clamp(input, min, max) is used to limit the output so the value never goes above 10.
Rainbow Color
Example: hsv_to_color(timeex() * 50)
Here timeex() is used as the (h)ue input for hsv_to_color(h, s, v) which changes the color over time. Multiplying the timeex() by 50 speeds up the color transition.
Download: hsv.txt
Properties
easy setup | |
---|---|
input | Select a miscellaneous function |
function | Select a math function to act on the miscellaneous function ( none = use misc. function directly ) |
axis | (??) |
min | Sets the minimum value that the function may be ( if a sine or cosine ) |
max | Sets the maximum value that the function may be ( if a sine or cosine ) |
offset | Sets the horizontal offset ( adding/removing the input before applying the function, ie. sin(time()-2) ) |
input multiplier | Multiplies the input before applying the function, ie. sin(time()*2)) |
input divider | Divides the input before applying the function, ie. sin(time()/2)) |
pow | Raises the entire expression up by an exponential power, ie. sin(time())^2 |
behavior | |
additive | Determines whether to output normally ( disabled ) or add each output to the previous output ( enabled ) |
player angles | (??) |
zero eye pitch | (??) |
reset velocities on hide | Determines whether to treat velocity functions normally ( disabled ) or set them to 0 upon hiding/unhiding ( enabled ) |
velocity roughness | Sets how quickly velocity functions change their value |
generic | |
variable name | The name of the value you'd like the proxy to alter |
root owner | (??) |
target part name | Name of a part to be affected by the proxy ( leave empty to affect the parent or child of the proxy ) |
affect children | Determines whether to affect a target part or parent ( disabled ) or affect all of the proxy's children ( enabled ) |
expression | A mathematical expression to alter the value ( overrides easy setup ) |
name | The name of the proxy ( not altering this will allow the proxy to display its output ) |
hide | Determines whether to render the proxy or ignore/hide it |
is disturbing | Determines whether to hide the proxy for players who have pac_hide_disturbing set to 1 |
orientation | |
parent name | The name of the proxy's parent part ( the proxy will move under said part if you decide to change this ) |
Contributing authors: