click below
click below
Normal Size Small Size show me how
E2 Functions
Wire E2 Functions and what they do (Garry's Mod)
| Function/Usage | Action |
|---|---|
| interval(N) | Runs the E2 code every N ammount of milliseconds (minimum delay is 10 milliseconds) |
| runOnTick(N) | Runs the E2 code every N game tick(s) |
| if (A) {B = C} | Checks if the conditional in the parentheses is true, and if it is, it does the code in the brackets |
| elseif (D) {E = F} | If the if(){} conditional DIRECTLY ABOVE is false, this check if the conditional in the parentheses and if it is true, runs the code in the brackets. |
| else {G = H} | If the if(){} conditional is false, and the optional elseif(){} is false, runs the code in the brackets |
| chatClk() | Returns 1 if someone sends a chat message. (can input a player entity in the parentheses to make it only work with that person's chat) |
| print(S) | prints the string S to the owner's chat |
| conditionals: ==, !=, |, &, >=, <=, >, | is, is not, or, and, greater than or equal to, less than or equal to, greater than, less than |
| abs(N) | Returns the magnitude (absolute value) of N |
| ceil(A,B) | Rounds A up to the optional argument B' decimal postion |
| floor(A,B) | Rounds A down to the optional argument B's decimal position |
| round(A,B) | Rounds A to the optional argument B's decimal position |
| sqrt(N) | Returns the square root of N |
| cbrt(N) | Returns the cube root of N |
| root(A, B) | Returns the B'th root of A |
| exit() | Stops the chip from executing any code after it |
| reset() | Resets the chip, acts like respawning it |
| S:index(N) | Returns Nth letter of the string S (as a string) |
| S:length() | Returns the length of the string S |
| S:upper() | Returns string S in all uppercase |
| S:lower() | Returns string S in all lowercase |
| S:sub(A,B) | Returns a substring of S between points A and B |
| S:explode(A) | Returns an array of strings. (A says where to split the strings) [EX: Text1:explode(" "), this will return each word as a seperate string] |
| hint(S,N) | Displays string S as a hint for N seconds (N is clamped between 0.7 and 7) |
| print(S) | Prints string S to your chat, only visible to you |
| selfDestruct() | Makes the expression delete itself |
| selfDestructAll() | Makes the expression delete itself and all constrained objects |
| entity(N) | Returns the entity associated with the numeric i.d. N (remove N to make the chip return itself) |
| owner() | Gets the owner of the expression |
| E:id() | Returns the numeric i.d. of entity E |
| noentity() | Returns an invalid/nil entity |
| curtime() | Returns the current game time since server start in seconds (can be effected by lag) |
| stoptimer(S) | stops timer S [an stop interval with stoptimer("interval")] |
| clk(S) | Returns 1 if the current execution was caused string S [clk() returns 1 if the execution was caused by interval()] |
| toUnit(S,N) | Converts N from Gmod units to S units |
| fromUnit(S,N) | Converts N from S units to Gmod units |
| convertUnit(A,B,N) | Converts N from A units to B units |
| lastSaid() | Returns what was last said in the chat log [owner():lastSaid() returns what you said last] |
| tickClk() | Returns 1 if the current code execution was caused by runOnTick() |
| realtime() | Returns the current real time since server start. (Will not get affected by lag) |
| map() | Returns the current map |
| hostname() | Returns the name of the server |
| gamemode() | Returns the server's gamemode |
| gravity() | Returns player gravity (in the negative Z direction) |
| propGravity() | Returns prop gravity |
| time(S) | Returns numerical time/date info from the server. Possible arguments: "year", "month", "day", "hour", "min", "sec", "wday" (weekday, Sunday is 1), "yday" (day of the year), and "isdst" (daylight saving flag 0/1) |
| E:getConstraints() | Returns an array with all entities directly or indirectly constrained to E, except E itself |
| E:hasConstraints() | Returns the number of the constraints E has |
| E:hasConstraints(S) | Returns the number of the constraints E has with the given constraint type |
| E:isConstrained() | Returns 1 if E has constraints, 0 if not |
| hideChat(N) | If N isn't 0, hide the chat message that is currently being processed. |
| lastSpoke() | Returns the last player to speak. |
| holoRemainingSpawns() | Returns how many holos you can spawn before you reach the limit |
| holoDelete(N) | Deletes the holo with the index N |