GoRap Wiki
Advertisement
Stub Эта статья не переведена до конца. Пожалуйста помогите нам доперевести ее.
Спасибо!

Особенности[]

Wire Expression 2[]

Уникальный чип, функцию которого может задать сам игрок с помощью собственного языка программирования.

Синтаксис[]

Синтаксис Expression 2 сильно изменился со времен прошлого Expression Chip, придется изучить немного больше команд, но это сделает ваши постройки намного более функциональными. Помните что как правило существует несколько способов написания кода, и задача может быть решена несколькими путями.

В условных операторах Expression 2 числа принимаются за "ложь", если они равны 0, в ином случае они принимаются за "истину". Функции, которые по сути возвращают "истину" или "ложь", на деле возвращают 1 и 0 соответственно.

Синтаксис Пример Упрощенный Описание
# #это комментарий Все, что находится за знаком # считается комментарием и не будет учитываться при обработке кода (оно будет проигнорировано при запуске чипа)
#[коментарий]# #[Это многострочный

comment]#

Все, что находится между знаками #[ и ]# считается комментарием и не будет учитываться при обработке кода (оно будет проигнорировано при запуске чипа)
if () {} if (A) {B=C} if (A) {D=B} Если значение (выражение) между круглыми скобками - "истина" то выполняются операции внутри фигурных скобок.
else {} else {A=B} Должен следовать за if () {} или elseif () {}. Если предыдущее условие было ложным, то выполняются операции в фигурных скобках.

Оператор не обязателен.

elseif () {} elseif (A) {B = C} Должен следовать за if () {} или elseif () {}. Если предыдущее условие было ложным и условие в круглых скобках истинно, то выполняются операции в фигурных скобках.

Оператор не обязателен.

~ if(~Time & Time == 0) {DO stuff} Изменялось ли значение на входе между выполнениями?
$ Opitch = Pitch + ($Pitch *3) Возвращает разницу между выполнениями в виде числа. (Работает только с переменными типа number, vector2, vector, vector4, angle)
++ if(Count == 2 {Count++} Count = Count + 1 Прибавляет 1 к заданной переменной.
-- if(Count == 3){Count--} Count = Count - 1 Вычитает 1 из заданной переменной.
+= if(Count == 4){Count += 2} Count = Count + 2 Прибавляет число после += к заданной переменной.
-= if(Count == 5) {Count -= 2} Count = Count - 2 Вычитает число после -= из заданной переменной.
( ? : ) D = (A ? B : C) Если A истина то возвращает B иначе C. Замечание: конструкция A ?: B аналогична конструкции A ? A : B
I if (A I B) {C = 1} Если A или B истина C=1.
& if (A & B) {C = 1} Если A и B истина C=1.
! if (!A) {B = 1} Должно предшествовать число. Возвращает 1 если A ложно (эквивалентно "A == 0").
Должно предшествовать число.
-> ->Input or ->Output Если вы используете его на входе, он возвращает 1, когда вход подсоединяется к чему либо. Если вы используете его на выходе, он возвращает количество входов присоединённых на выход.
#ifdef #ifdef entity():setAlpha(number) Проверяет может ли данная функция выполняться на сервере.
#else #else entity():setModel(string) Должно предшествовать #ifdef. Если данная функция не может использоваться на сервере запустится код после #else...
#endif #endif Должно предшествовать #ifdef или #else .Закрывает выражение #ifdef.

Переменные[]

В E2, все входы, выходы и переменные должны быть объявлены с заглавной буквы:

Синтаксис Описание
@persist variable Это не будет работать потому, что переменная "variable" не будет прочитана как переменная, так как она объявлена со строчной буквы, а в Expression 2 переменные нужно обозначать с заглавной буквы.
@persist Variable Это будет работать, так как переменная "Variable" начинается с заглавной буквы.

Выражение @trigger[]

Выражение @trigger может выборочно разрешать и запрещать входам вызывать выполнение кода.Возможные значения: all/none, или список разрешенных входов.

Синтаксис Описание
@trigger all Всё по старому, изменение значения на входах всегда вызывает выполнение кода
@trigger none Изменение значения на входах никогда не вызывает выполнение кода, его вызывает только таймер, и.т.п. функции
@trigger Time Button Выполнение кода вызывается только при изменении значений на входах Time и Button

Выражение @model[]

Выражение @model устанавливает модель чипа при его первом создании.

Пример: @model models/bull/gates/processor.mdl

[]

Циклы[]

Синтаксис Пример Описание
while () {} while (A) {B++} Любые инструкции в фигурных скобках будет повторяться, пока условие в круглых скобках истинно. Если условие ложно, инструкции будут пропущены и E2 будет продолжаться с конца цикла. Заметим, что условие проверяется только в самом начале каждого цикла.
for () {} for (I = A, B[, C]) {} Добавляет значение C переменной для каждой итерации, пока она равна значению B. Если шаг C не указан, то он будет установлен на единицу. Обратите внимание, что А и В вычисляются только один раз - если они рассчитываются из переменных, что цикл устанавливает новые значения, это не изменит число итераций.
foreach () {} foreach(K,V:type=Table) {} Проверяет  каждый элемент указанного типа в таблице. Назначает ключ к К и значение V. Элементы, которые не имеют определенного типа будут пропущены. Элементы могут быть добавлены, удалены или изменены, однако добавляемые элементы не будут обрабатываться в текущем цикле. Только цикл по строке индексов при использовании таблицы.
continue if (A) {continue} Может быть использовано только в while/for/foreach цикле. Эта команда позволяет перейти к следующей итерации (немедленно вернуться к началу цикла), пропуская следующие инструкции.
break if (A) {break} Может быть использовано только в while/for/foreach цикле. Эта команда позволяет немедленно выйти из цикла, пропуская следующие инструкции.

Производительность[]

Были проведены некоторые тесты в игре:

~3.000.000/сек арифметических операций (+-*/) на числах, 2000 операций, 200 выполнений за 0.13сек

~850.000/сек арифметических операций (+-*/) на векторах, 2000 операций, 100 выполнений за 0.23сек

Горячие Клавиши Редактора[]

Ctrl-Пробел Проверить (и переместить курсор на ошибку)
Ctrl-S Сохранить
Ctrl-Z Отменить
Ctrl-Y Вернуть
Ctrl-X Вырезать
Ctrl-C Копировать
Ctrl-V Вставить
Ctrl-A Выделить Всё
Ctrl-Up Прокрутить Вверх
Ctrl-Down Прокрутить Вниз
Ctrl-Left Прокрутить Влево
Ctrl-Right Прокрутить Вправо

Консольные команды[]

Команда Описание
wire_expression2_model <model> Вручную меняет модель чипа
wire_expression2_reload Перезагружает все расширения для E2, полезно для отладки своих расширений. Помните, что клиентские файлы в мультиплеере берутся из кэша g-mod.
wire_expression2_debug 0/1 Включает режим отладки, который может быть полезен для разработчиков. Необходимо ввести "wire_expression2_reload" после изменения, чтобы сработало.
wire_expression2_extension_enable <extension> Включить определенное расширение
wire_expression2_extension_disable <extension> Выключить определенное расширение
wire_expression2_unlimited 0/1 Включить/выключить ограничения по производительности
wire_holograms_modelany 0/1 Позволяет брать любую модель для голограммы (0-выключить,1-включить)

Типы[]

Expression2 использует несколько типов данных. По понятным причинам, тут только верхушка всего айсберга.

Сокращение Типы
N Number(Числа)
V2 / V / V4 2D / 3D / 4D Vector(Векторы)
A Angle(Углы)
S String(Строки)
E Entity(Объекты)
R Array(Массивы)
T Table(Таблицы)
RD Ranger Data(Рейнджеры)
B Bone(Кости)
M2 / M / M4 2x2 / 3x3 / 4x4 Matrix(Матрицы)
XWL Wirelink
C Комплексные числа
Q Кватернионы

Числа[]

Описание[]

Производит операции над числами

Команды[]

Функция Возвращает Описание
N + N N Сложение
N - N N Вычитание
N * N N Умножение
N / N N Деление
N ^ N N Возведение в степень (2 ^ 3 = 8)
N % N N Остаток от деления арумента 1 на аргумент 2. Примечание "-1 % 3 = 2"
mod(N, N) N Остаток от деления арумента 1 на аргумент 2. Примечание "mod(-1, 3) = -1"
sqrt(N) N Возвращает квадратный корень числа
cbrt(N) N Возвращает кубический корень числа
root(N, N) N Возвращает корень первого числа
e() N Возвращает число Эйлера
exp(N) N Возводит число Эйлера в степень аргумента (можно и e()^N, однако так быстрее)
ln(N) N Возвращает логарифм числа N по основанию e (число Эйлера)
log2(N) N Возвращает логарифм числа N по основанию 2 (двоичный)
log10(N) N Возвращает логарифм числа N по основанию 10(десятичный)
log(N,N) N Возвращает логарифм первого аргумента по основанию второго
abs(N) N Возвращает модуль числа
ceil(N) N Округляет аргумент до ближайшего большего целого числа [ceil(5.5) = 6]
ceil(N,N) N Округляет аргумент с десятичной точностью до второго аргумента [ceil(5.05) = 5.1]
floor(N) N Округляет аргумент до ближайшего меньшего целого числа [floor(5.5) =5]
floor(N,N) N Округляет аргумент с десятичной точностью до второго аргумента [floor(5.14) = 5.1]
round(N) N Округление [round(5.5) = 6; round(5.4) = 5]
round(N,N) N Округление с десятичной точностью до второго аргумента
int(N) N Возвращает целую часть числа (как floor)
frac(N) N Возвращает дробную часть числа (как floor)
clamp(N,N,N) N Если Arg1 <= Arg2 (минимальное) возвращает Arg2; если Arg1 >= Arg3 (максимальное) возвращает Arg3; иначе возвращает Arg1.
inrange(N,N2,N3) N Возвращает 1 если N находится в интервале [N2; N3], иначе 0.
sign(N) N Возвращает знак числа (-1,0,1) [sign(N) = N / abs(N) ]
min(N,N) N Возвращает значение минимального аргумента
min(N,N,N) N Возвращает значение минимального аргумента
min(N,N,N,N) N Возвращает значение минимального аргумента
max(N,N) N Возвращает значение максимального аргумента
max(N,N,N) N Возвращает значение максимального аргумента
max(N,N,N,N) N Возвращает значение максимального аргумента
random() N Возвращает случайное число с плавающей точкой между 0 и 1 [0 <х <1]
random(N) N Возвращает случайное число с плавающей точкой между 0 и указанным значением [0 <= X <]
random(N,N) N Возвращает случайное число с плавающей точкой в указанном интервале [A < х < B]
randint(N) N Возвращает случайное целое число между 1 и указанным значением [1 <= x <= a ]
randint(N,N) N Возвращает случайное целое число в указанном интервале [a <= x <= b ]
pi() N Возвращает постоянную ПИ
toRad(N) N Переводит градусную меру угла в радианную
toDeg(N) N Переводит радианную меру угла в градусную
sin(N) N Возвращает синус числа N (из градусной меры)
cos(N) N Возвращает косинус числа N (из градусной меры)
tan(N) N Возвращает тангенс числа N (из градусной меры)
asin(N) N Возвращает арксинус числа N (из градусной меры)
acos(N) N Возвращает арккосинус числа N (из градусной меры)
atan(N) N Возвращает арктангенс числа N (из градусной меры)
sinh(N) N Возвращает гиперболический синус N (из градусной меры)
cosh(N) N Возвращает гиперболический косинус числа N (из градусной меры)
tanh(N) N Возвращает гиперболический тангенс числа N (из градусной меры)
sinr(N) N Возвращает синус числа N (из радианной меры)
cosr(N) N Возвращает косинус числа N (из радианной меры)
tanr(N) N Возвращает тангенс числа N (из радианной меры)
asinr(N) N Возвращает арксинус числа N (из радианной меры)
acosr(N) N Возвращает арккосинус числа N (из радианной меры)
atanr(N) N Возвращает арктангенс числа N (из радианной меры)
atanr(N,N) N Возвращает арктангенс аргументов (ARG1 / ARG2), в радианах. Эта функция учитывает положительные / отрицательные аргументы, и аргументы близкие к 0
sinhr(N) N Возвращает гиперболический синус числа N (из радианной меры)
coshr(N) N Возвращает гиперболический косинус числа N (из радианной меры)
tanhr(N) N Возвращает гиперболический тангенс числа N (из радианной меры)
A = B N Присваивание (присвоить переменной A число B)
A++ N Увеличить на 1 (добавить к A единицу, упрощенно "A += 1")
A-- N Уменьшить на 1 (вычисть из A единицу, упрощенно "A -= 1")
A += B N Увеличить на число (увеличить A на B, упрощенно "A = (A + B)")
A -= B N Уменьшить на число (уменьшить A на B, упрощенно "A = (A - B)")
A /= B N Делит A на B
A %= B N Присваивает A остаток деления A на B
A ^= B N Возводит A в степень B
A == B N A равно B?
A != B N А не равно В?
A > B N А больше В?
A < B N А меньше В?
A >= B N А больше или равно В?
A <= B N А меньше или равно В?

Строки[]

Описание[]

Строки позволяют вам работать с текстом в E2. Необходимо для роты текстовых экранов.

Пример работы[]

Команды[]

Создает строку из помещенной в кавычки, например,"text goes here" Доступны операторы равенства (==) и неравенства, также как и конкатенации(+), для объединения строк и чисел в любом порядке. Операция конкатенации возвращает строку. Первый символ строки имеет номер 1. Отрицательные индексы отсчитываются от конца строки, в которой последний символ -1. Положительные индексы привязаны к длине строки.

Функция Возвращает Описание
S:index(N) S Возвращает N-нный символ из строки
S:length() N Возвращает длину строки
S:upper() S Делает все буквы у строки большими
S:lower() S Делает все буквы у строки маленькими
S:sub(N,N) S Возвращает подстроку, начиная с первого аргумента и заканчивая вторым
S:left(N) S Возвращает первые N символов строки
S:right(N) S Возвращает последние N символов строки
S:find(S) N Возвращает 1 если в строке найдена подстрока S, или 0 если не найдена
S:find(S, N) N Возвращает 1 если в строке найдена подстрока S начиная с Nого символа, или 0 если не найдена
S:explode(S) R Разбивает строку через разделитель S и записывает результат в массив. Подробнее string.Explode
S:repeat(N) S Повторяет N раз, возвращает S
trim(S) S Убирает пробелы в начале и в конце строки
S:trimLeft() S Убирает пробелы в начале строки
S:trimRight() S Убирает пробелы в конце строки
S:replace(1S,2S) S В строке S, находит все 1S, и заменяет их на 2S
S:reverse() S Возвращает перевернутую строку S
S:toNumber() N Переводит строку в числа
toString(N) S Переводит число N в строку. (Числа могут быть преобразованы в строку без этой функции)
toChar(N) S Возвращает ASCII-код из N, при условии что там помещен один знак.
toByte(S) N Возвращает ASCII-код от первого знака в начале строки.
toByte(S,N) N Возвращает ASCII-код знака из S, на позиции N
S:match(S2,N) R Запускает функцию string.match(S, S2, N) garrysmod и возвращает в виде массива.
S:match(S2) R Запускает функцию string.match(S, S2) garrysmod и возвращает в виде массива.
S:matchFirst(S2,N) S Запускает функцию string.match(S, S2, N) garrysmod и первое совпадение или пустую строку в случае ошибки.
S:matchFirst(S2) S Запускает функцию string.match(S, S2) garrysmod и первое совпадение или пустую строку в случае ошибки.

Entity[]

Описание[]

Эти функции позволяют получать информацию и манипулировать объектами (такими как игроки или пропы), находящимися в игровом мире. Entity объекта можно получить несколькими способами: используя Target finder, Entity marker или специальными командами в самом E2.

Since the expression collects the data directly from the entity, it is much faster to handle calculations from within the E2 than having a beacon-sensor send its information to the gate.

A valid entity will return true in an if-statement. This is helpful for preventing LUA errors resulting from using entity commands on entities which have been destroyed.

Примеры работы[]

Команды[]

Только операторы для объектов равны и не равны. Кроме того, объект будет возвращать <span style="color:rgb(0,0,0);font-

Функция  Возвращает Описание      |     Увеличить   
entity(N) E Возвращает объект, числовой идентификатор объекта "ID"
owner() E Действие будет происходить с владельцем ( owner ) чипа. ( так же, как entity():owner() )
E:id() N Возвращает числовой идентификатор объекта "ID"
noentity() E Возвращает пустой ентити

"Всё равно, что корень из минус одного в линейной алгебре "sqrt(-1)" - не сложить, не поделить"

E:type() S Возвращает тип объекта "E"
E:model() S Возвращает модель объекта "E"
E:owner() E Возвращает владельца объекта "E"
E:name() S Возвращает имя объекта "E"
E:steamID() S Возвращает Steam ID игрока (на данный момент с ошибками)
E:pos() V Возвращает позицию объекта "E"
E:eye() V Возвращает позицию взгляда игрока или же направление объекта в переднюю сторону
E:eyeTrace() RD Равносильно "rangerOffset(999999, E:shootPos(), E:eye())", но быстрее (требует меньше операций)
E:shootPos() V Возвращает позицию выстрела игрока, точка, точно в которой находится камера игрока
E:aimEntity() E Возвращает объект на который смотрит игрок
E:aimBone() B Возвращает кость на которую смотрит игрок
E:aimPos() V Возвращает позицию взгляда игрока (не сторону,в отличие от "E:eye()" )

Равносильно "rangerOffset(999999, E:shootPos(), E:eye()):pos()"

E:aimNormal() V Возвращает нормальный вектор направления прицела игрока
E:frags() N Возвращает количество убийств игрока
E:team() N Возвращает  номер команды игрока
teamName(N) S Возвращает имя команды связанной с номером
E:forward() V Возвращает переднее направление объекта
E:right() V Возвращает правое направление объекта
E:up() V Возвращает верхнее направление объекта
E:vel() V Возвращает вектор скорости объекта
E:velL() V Возвращает локальный вектор скорости объекта
E:boxCenter() V Возвращает координату середины ограничивающей рамки объекта в пространстве самого объекта
E:boxCenterW() V Возвращает координату середины ограничивающей рамки объекта в пространстве мира

Равносильно: "E:pos() + E:boxCenter():rotate(E:angles())"

E:boxMax() V Возвращает максимальную высоту ограничивающей рамки объекта(самый высокий угол)
E:boxMin() V Возвращает минимальную высоту ограничивающей рамки объекта(самый низкий угол)
E:boxSize() V Возвращает вектор размера ограничивающей рамки объекта(длинна,ширина,высота)
E:toWorld(V) V Преобразует, локальный объекту Е, вектор V в систему координат мира.

Равносильно: "E:pos() + V:rotate(E:angles())"

E:toLocal(V) V Преобразует вектор V из пространства мира в пространство объекта Е

Равносильно: "V:rotate(-E:angles()) - E:pos()"

E:toWorld(A) A Преобразует, локальный объекту Е, угол в угол в пространстве мира
E:toLocal(A) A Преобразует угол из пространства мира в локальный угол объекта Е
E:angVel() A Возвращает угловую скорость объекта Е
E:angVelVector() V Returns rotation axis, velocity and direction given as the vector's direction, magnitude and sense
E:angles() A Возвращает углы наклона объекта в пространстве мира
E:radius() N Возвращает размер объекта (хоть и не точно, но это полезно)
E:height() N Возвращает высоту игрока или NPC
E:bearing(V) N Gets the bearing from the entity to the vector
E:elevation(V) N Gets the elevation from the entity to the vector
E:direction(V) A Gets the elevation and bearing from the entity to the vector
E:health() N Возвращает здоровье объекта
E:armor() N Возвращает броню обьекта
E:mass() N Возвращает массу объекта

Хочу заметить, что масса в source измеряется в килограммах.

E:timeConnected() N Возвращает время в течении которого игрок находится на сервере
E:massCenter() V Возвращает центр масс объекта в пространстве координат мира
E:massCenterL() V Возвращает центр масс объекта в пространстве координат объекта (локальный вектор)

Равносильно: "E:toLocal(E:massCenter())"

Равносильно: "E:massCenter():rotate(-E:angles()) - E:pos()"

E:setMass(N) Устанавливает массу объекта

(работает в промежутке [0.001; 50,000])

Хочу заметить, что масса в source измеряется в килограммах.

E:inertia() V Получает основные компоненты тензора инерции сущности в форме ( Ixx, Iyy, Izz )
E:applyForce(V) К объекту применяется сила, заданная вектором V

Хочу заметить, что модуль(длинна) этого вектора будет равен силе, которая измеряется в ньютонах

E:applyOffsetForce(V1,V2) Аналогично "applyForce", только сила V1 применяется не в центре масс, а в указанном векторе V2
E:applyAngForce(A) К объекту применяется крутящий момент
E:applyTorque(V) Applies torque according to the given vector, representing the torque axis, magnitude and direction
E:isPlayer() N Является ли этот объект игроком?
E:isOnFire() N Этот объект горит?
E:isWeapon() N Этот объект оружие?
E:isNPC() N Этот объект NPC?
E:isFrozen() N Этот объект заморожен?
E:isVehicle() N Этот объект транспорт?
E:inVehicle() N Этот объект(игрок) в транспорте?
E:isWorld() N Этот объект - объект мира?
E:isOnGround() N Опирается ли объект на что-то?(работает только на игроков и NPC)
E:isUnderWater() N Этот объект под водой?
E:isPlayerHolding() N Этот объект держит игрок?
E:isAlive() N Этот объект(игрок или NPC) жив?
E:isCrouch() N Игрок присел?
E:inNoclip() N Игрок в режиме хождения сквозь стены?
E:keyAttack1() N Нажимает ли игрок кнопку "огонь"?
E:keyAttack2() N Нажимает ли игрок кнопку "альтернативный огонь?
E:keyUse() N Нажимает ли игрок кнопку "использовать"? 
E:hintDriver(S,N) N Displays a hint popup to the driver of vehicle E, with message S for N seconds (N being clamped between 0.7 and 7). Returns 1 if the hint has been sent.
E:printDriver(S) N Пишет S в чат водителя машины E. Возвращает 1, если текст был написан, 0, если нет.
E:driver() E Возвращает объект игрока, сидящего в транспорте E
E:passenger() E Возвращает пассажира машины, если он там один, в одноместных вернёт водителя.
E:lockPod(N) Значение 1 разрешает садиться в транспорт E, значение 0 запрещает садиться в транспорт E
E:ejectPod() Выгоняет игрока из транспорта
E:killPod() Убивает игрока в транспорте
E:weapon() E Возвращает объект оружия, которое сейчас держит игрок
E:clip1() N Возвращает количество патронов у игрока
E:clip2() N Возвращает количество альтернативных патронов
E:primaryAmmoType() S Возвращает тип патронов 
E:secondaryAmmoType() S Возвращает тип альтернативных патронов
E:ammoCount(S) N Returns the amount of stored ammo of type S on player E, excluding current clip
E:removeTrails() Убирает хвосты/трейлы с объекта
E:setTrails(N,N,N,S,V,N) Задает объекту трейл, значения:

"объект привязки:(ширина начала, ширина конца, длинна, материал, цвет, прозрачнось"

E:lookupAttachment(string attachmentName) N Returns entity's attachment ID associated with attachmentName
E:attachmentPos(attachmentID) V Returns entity's attachment position associated with attachmentID
E:attachmentAng(attachmentID) A Returns entity's attachment angle associated with attachmentID
E:attachmentPos(string attachmentName) V Same as E:attachmentPos(E:lookupAttachment(attachmentName))

E:attachmentAng(string attachmentName) || A|| Same as E:attachmentAng(E:lookupAttachment(attachmentName))

Векторы[]

Описание[]

Vectors are now properly implemented in the Expression 2, which means that they are as easy to work with as numbers. For those that know what vectors are, and how to use them, this is a great tool for creating many things.

2D and 4D vectors are also supported by E2. These include all the standard functions of 3D vectors listed here. If you're doing 2D vector operations, you can now do things much more efficiently. 4D vectors work in conjunction with matrices, and can be used as homogeneous representations of 3D vectors.

Operational functions can be used between numbers and vectors, e.g. N*V. Note that operations cannot be performed between two vectors of different size, for example multiplication between a 2D and a 3D vector.

Related Examples[]

Команды[]

Functions specific to 2D vectors

Команда Возвращает Описание
vec2(N,N) V2 Создает двухмерный вектор
vec2() V2 Создает двухмерный вектор

Равносильно: "vec2(0,0)" или "vec2(0)"

Хочу заметить, что выражение "vec2( N , N )" полностью идентично выражению "vec2( N )"

vec2(V) V2 Конвертирует 3D вектор в 2D (z опускается)
vec2(V4) V2 Конвертирует 4D вектор в 2D (z и w опускаются)
V2:cross(V2) N Gets the 2D vector cross product/wedge product
shift(V2) V2 Swaps the vector's x,y components
V2:rotate(N) V2 Поворачивает вектор на заданный аргумент N (из градусной меры)
V2:toAngle() N Преобразует вектор в угол (в промежутке от -180 до 180)
V:dehomogenized() V2 Converts a 2D homogeneous vector (x,y,w) into a 2D cartesian vector

3D Vector Commands[]

Functions specific to 3D vectors

Function Returns Description
vec(N,N,N) V Создаёт трёхмерный вектор
vec() V Создаёт трёхмерный вектор

Равносильно: "vec(0,0,0)"

vec(V2) V Преобразует двухмерный вектор в трёхмерный, при этом координате "Z" задаётся значение "0"

Равносильно: "vec(V2:x(),V2:y(),0)"

vec(V2,N) V Преобразует двухмерный вектор в трёхмерный, при этом координате "Z" задаётся значение NРавносильно: "vec(V2:x(),V2:y(),N)"
vec(V4) V Преобразует четырёхмерный вектор в трёхмерный, пот этом координата w опускается

Равносильно: "vec(V4:x(),V4:y(),V4:z())"

vec(A) V Преобразует углы в вектор

Равносильно: "vec(A:pitch(),A:yaw(),A:roll())"

V:cross(V) V Gets the 3D vector cross product
shiftL(V) V Shifts the vector's components left: shiftL( x,y,z ) = ( y,z,x )
shiftR(V) V Shifts the vector's components right: shiftR( x,y,z ) = ( z,x,y )
V:rotate(A) V Вращает вектор по углам А
V:rotate(N,N,N) V Вращает вектор по углам ang(N,N,N)
V:toAngle() A Преобразует вектор в углы, которые указывают направление в система отсчета мира
V4:dehomogenized() V Converts a 3D homogeneous vector (x,y,z,w) into a 3D cartesian vector
V:isInWorld() N Returns 1 if the position vector is within the world, 0 if not

4D Vector Commands[]

Functions specific to 4D vectors. From a mathematics standpoint these are treated as 4D Cartesian vectors, where the 4th component is referred to as "w".

Function Returns Description
vec4(N,N,N,N) V4 Makes a 4D vector
vec4() V4 Same as vec4(0,0,0,0)
vec4(V2) V4 Converts a 2D vector into a 4D vector (the z and w components are set to 0)
vec4(V2,N,N) V4 Converts a 2D vector into a 4D vector (the z and w components are set to the second and third arguments)
vec4(V2,V2) V4 Creates a 4D vector from two 2D vectors
vec4(V) V4 Converts a 3D vector into a 4D vector (the w component is set to 0)
vec4(V,N) V4 Converts a 3D vector into a 4D vector (the w component is set to the second argument)
shiftL(V4) V4 Shifts the vector's components left: shiftL( x,y,z,w ) = ( y,z,w,x )
shiftR(V4) V4 Shifts the vector's components right: shiftR( x,y,z,w ) = ( w,x,y,z )

Common Vector Commands[]

Functions that apply to 2D and 3D vectors. They are written here in terms of 3D vectors, but apply to 2D and 4D vectors in the same way, also returning 2D or 4D vectors where applicable.

Function Returns Description
ceil(V) V Округляет XYZ к ближайшему числу
ceil(V,N) V Rounds XYZ up to argument 2's decimal precision
floor(V) V Rounds XYZ down to the nearest integer
floor(V,N) V Rounds XYZ down to argument 2's decimal precision
round(V) V Rounds XYZ to the nearest integer
round(V,N) V Rounds XYZ to argument 2's decimal precision
mod(V,N) V Returns the remainder after XYZ have been divided by argument 2
mod(V,V) V Returns the remainder after the components of vector 1 have been divided by the components of vector 2
clamp(V,V,V) V Clamps vector 1's XYZ between the XYZ of vector 2(min) and vector 3(max)
clamp(V,N,N) V Clamps vector 1's length between argument 2(min) and argument 3(max)
min(V,V) V Returns the vector with the smallest length
max(V,V) V Returns the vector with the greatest length
mix(V,V,N) V Combines vector 1's XYZ with vector 2's XYZ by a proportion given by argument 3 (between 0 and 1)
positive(V) V Returns a vector containing the positive value of each vector component, equivalent to abs(N)
V:length() N Gets the length of the vector
V:length2() N Gets the squared length of the vector
V:distance(V) N Gets the distance between vectors
V:distance2(V) N Gets the squared distance between vectors
V:normalized() V Gets the normalized vector
V:dot(V) N Gets the vector dot (scalar) product
V:x() N Выводит из вектора x координату
V:y() N Выводит из вектора y координату
V:z() N Выводит из вектора z координату
V:w() N Выводит из вектора w координату
V:setX(N) V Returns a copy of the vector with X replaced (use as Vec = Vec:setX(...))
V:setY(N) V Returns a copy of the vector with Y replaced (use as Vec = Vec:setY(...))
V:setZ(N) V Returns a copy of the vector with Z replaced (use as Vec = Vec:setZ(...))
V:setW(N) V Returns a copy of the vector with W replaced (use as Vec = Vec:setW(...))
V:toString() S Gets the vector nicely formatted as a string "[X,Y,Z]"

Matrix[]

Developed by: Jimlad

Description[]

2x2, 3x3 and 4x4 matrices are now supported in Expression 2. These are for more advanced manipulations involving vectors and numbers. As with vectors, for those with the relevant knowledge these can be very useful tools.

Basic operations supported:

  • Matrix addition and subtraction
  • Multiplication by scalars, vectors and matrices
  • Division by a scalar
  • Exponentiation (only integers between -1 and 2)
  • Delta of a matrix (returns a matrix)

NOTES:

Similarly to vectors, 3x3 matrix commands are referred to using "matrix", whereas 2x2 and 4x4 matrix commands use "matrix2" and "matrix4"

The "set" and "swap" functions are like the 3D vector "set" functions; they do not affect the original matrix.

Remember that operations will only work on vectors/matrices of a similar size. You cannot, for example, multiply a 3x3 matrix by a 2D vector. Also, all vectors are treated as column vectors for the purposes of matrices, so M*V will return a vector but V*M is undefined.

2x2 Matrix Commands[]

Functions specific to 2x2 matrices

Function Returns Description
identity2() M2 Creates a 2x2 identity matrix
matrix2() M2 Creates a 2x2 zero matrix
matrix2(N,N,N,N) M2 Creates a matrix with values in order (i.j) of: (1,1), (1,2), (2,1), (2,2)
matrix2(V2,V2) M2 Creates a matrix with vectors by columns
matrix2(M) M2 Converts a 3x3 matrix into a 2x2 matrix - all (i,3) and (3,j) are omitted
matrix2(M4) M2 Converts a 4x4 matrix into a 2x2 matrix - all (i,3), (i,4), (3,j) and (4,j) are omitted
M2:swapRows() M2 Swaps rows
M2:swapColumns() M2 Swaps columns
M2:setRow(N,N,N) M2 Sets the values of a row. The first argument given specifies the row(j), the following arguments are the values 1j, 2j
M2:setRow(N,V2) M2 Sets the values of a row. The first argument given specifies the row, the vector contains the values to set
M2:setColumn(N,N,N) M2 Sets the values of a column. The first argument given specifies the column(i), the following arguments are the values i1, i2
M2:setColumn(N,V2) M2 Sets the values of a column. The first argument given specifies the column, the vector contains the values to set

3x3 Matrix Commands[]

Functions specific to 3x3 matrices

Function Returns Description
identity() M Creates a 3x3 identity matrix
matrix() M Creates a 3x3 zero matrix
matrix(N1,N2... N9) M Creates a matrix with 9 values in the following order (i.j): (1,1), (1,2), (1,3), (2,1) etc.
matrix(V,V,V) M Creates a matrix with vectors by columns
matrix(M2) M Converts a 2x2 matrix into a 3x3 matrix - all (i,3) and (3,j) are filled with 0's
matrix(M4) M Converts a 4x4 matrix into a 3x3 matrix - all (i,4) and (4,j) are omitted
M:swapRows(N,N) M Swaps the two rows specified
M:swapColumns(N,N) M Swaps the two columns specified
M:setRow(N,N,N,N) M Sets the values of a row. The first argument given specifies the row(j), the following arguments are the values 1j, 2j, 3j
M:setRow(N,V) M Sets the values of a row. The first argument given specifies the row, the vector contains the values to set
M:setColumn(N,N,N,N) M Sets the values of a column. The first argument given specifies the column(i), the following arguments are the values i1, i2, i3
M:setColumn(N,V) M Sets the values of a column. The first argument given specifies the column, the vector contains the values to set
M:setDiagonal(N,N,N) M Sets the elements of the leading diagonal
M:setDiagonal(V) M Sets the elements of the leading diagonal from the components of a vector
matrix(E) M Creates a reference frame matrix from an entity's local direction vectors by columns in the order ( x, y, z )
matrix(A) M Returns a 3x3 reference frame matrix as described by the angle A. Multiplying by this matrix will be the same as rotating by the given angle.
M:x() V Returns the local x direction vector from a 3x3 coordinate reference frame matrix ( same as M:column(1) )
M:y() V Returns the local y direction vector from a 3x3 coordinate reference frame matrix ( same as M:column(2) )
M:z() V Returns the local z direction vector from a 3x3 coordinate reference frame matrix ( same as M:column(3) )
mRotation(V,N) M Creates a 3x3 rotation matrix, where the vector is the axis of rotation, and the number is the angle (anti-clockwise) in degrees. Example*: to rotate a vector (7,8,9) by 50 degrees about the axis (1,1,0), you would write V = mRotation(vec(1,1,0), 50) * vec(7,8,9)

* If you want to create a rotation matrix about the axes (1,0,0), (0,1,0) or (0,0,1), either use the V:rotate function, or construct a standard rotation matrix.

4x4 Matrix Commands[]

Functions specific to 4x4 matrices

Function Returns Description
identity4() M4 Creates a 4x4 identity matrix
matrix4() M4 Creates a 4x4 zero matrix
matrix4(N1,N2... N16) M4 Creates a matrix with 16 values in the following order (i.j): (1,1), (1,2), (1,3), (1,4), (2,1) etc.
matrix4(V4,V4,V4,V4) M4 Creates a matrix with vectors by columns
matrix4(M2) M4 Converts a 2x2 matrix into a 4x4 matrix - all (i,3), (i,4), (3,j) and (4,j) are filled with 0's
matrix4(M2,M2,M2,M2) M4 Constructs a 4x4 matrix from four 2x2 matrices
matrix4(M) M4 Converts a 3x3 matrix into a 4x4 matrix - all (i,4) and (4,j) are filled with 0's
M4:swapRows(N,N) M4 Swaps the two rows specified
M4:swapColumns(N,N) M4 Swaps the two columns specified
M4:setRow(N,N,N,N,N) M4 Sets the values of a row. The first argument given specifies the row(j), the following arguments are the values 1j, 2j, 3j, 4j
M4:setRow(N,V4) M4 Sets the values of a row. The first argument given specifies the row, the vector contains the values to set
M4:setColumn(N,N,N,N,N) M4 Sets the values of a column. The first argument given specifies the column(i), the following arguments are the values i1, i2, i3, i4
M4:setColumn(N,V4) M4 Sets the values of a column. The first argument given specifies the column, the vector contains the values to set
M4:setDiagonal(N,N,N,N) M4 Sets the elements of the leading diagonal
M4:setDiagonal(V4) M4 Sets the elements of the leading diagonal from the components of a vector
matrix4(E) M4 Creates a 4x4 reference frame matrix from an entity's local direction vectors by columns in the order (x, y, z, pos), with the bottom row (0,0,0,1)
matrix4(A) M4 Returns a 4x4 reference frame matrix as described by the angle A. Multiplying by this matrix will be the same as rotating by the given angle.
matrix4(A,V) M4 Returns a 4x4 reference frame matrix as described by the angle A and the position V. Multiplying by this matrix will be the same as rotating by the given angle and offsetting by the given vector.
M4:x() V Returns the local x direction vector from a 4x4 coordinate reference frame matrix ( same as M:column(1) )
M4:y() V Returns the local y direction vector from a 4x4 coordinate reference frame matrix ( same as M:column(2) )
M4:z() V Returns the local z direction vector from a 4x4 coordinate reference frame matrix ( same as M:column(3) )
M4:pos() V Returns the position vector from a 4x4 coordinate reference frame matrix ( same as M:column(4) )
inverseA(M4) M4 Finds the matrix inverse of a standard 4x4 affine transformation matrix ( the type created by matrix4(E) ). This should only be used on matrices with a particular format, where the top left 3x3 specifies rotation, the rightmost 3-column specifies translation, and the bottom row is (0,0,0,1)

Стандартные команды для матриц[]

Функции, которые работают для матриц 2x2, 3x3 and 4x4. В данном случае написано для матриц 3*3, но применимы для матриц 2х2 и 4х4.

Операции возвращают вектора/матрицы того же размера. Например, функция row() возвращает 2D вектор.

Функция Возвращает Описание
M:row(N) V Возвращает строку, как вектор
M:column(N) V Возвращает столбец, как вектор
M:element(N,N) N Возвращает элемент с индексами(i,j)
M:setElement(N,N,N) M Устанавливает значение элемента. Первые 2 аргумента - индексы (i,j), третий элемент - значение, которое надо вставить.
M:swapElements(N,N,N,N) M Меняет 2 элемента местами ( i1, j1, i2, j2 )
diagonal(M) V Returns a vector comprising the elements along the leading diagonal
trace(M) N Returns the trace of a matrix
det(M) N Returns the determinant of a matrix (Does not work for 4x4 matrices)
transpose(M) M Returns the transpose of a matrix
adj(M) M Returns the adjugate of a matrix (Does not work for 4x4 matrices)

NOTE: To get the inverse of a matrix, simply raise the matrix to the power of -1. Use this sparingly as it can be computationally expensive! Remember that if your matrix is orthogonal (e.g. rotation matrices), the inverse is equal to the transpose, so use the transpose instead if you can. Inverse is not available for 4x4 matrices. Instead, see usage of the inverseA(M4) function.

Angle[]

Description[]

Like 3 different directions can be expressed as a Vector, the angles of Pitch, Yaw and Roll can be expressed as an angle Vector. This in the least has the advantage that when performing functions which use angles, such as vector rotation or creating vectors from angles, you don't have to write the Pitch, Yaw and Roll components, only the Angle.

Commands[]

Function Returns Description
ang(N,N,N) A Makes an angle
ang() A Same as ang(0,0,0)
ang(V) A Changes a vector variable into an angle variable
ceil(A) A Rounds PYR up to the nearest integer
ceil(A,N) A Rounds PYR up to argument 2's decimal precision
floor(A) A Rounds PYR down to the nearest integer
floor(A,N) A Rounds PYR down to argument 2's decimal precision
round(A) A Rounds PYR to the nearest integer
round(A,N) A Rounds PYR to argument 2's decimal precision
mod(A,N) A Returns the remainder after PYR have been divided by argument 2
mod(A,A) A Returns the remainder after the components of angle 1 have been divided by the components of angle 2
clamp(A,A,A) A Clamps angle 1's PYR between the PYR of angle 2(min) and angle 3(max)
clamp(A,N,N) A Clamps angle 1's PYR between argument 2(min) and argument 3(max)
mix(A,A,N) A Combines angle 1's PYR with angle 2's PYR by a proportion given by argument 3 (between 0 and 1)
shiftL(A) A Shifts the angle's components left: shiftL( p,y,r ) = ( y,r,p )
shiftR(A) A Shifts the angle's components right: shiftR( p,y,r ) = ( r,p,y )
angnorm(A) A Gets the normalized angle of an angle
angnorm(N) N Gets the normalized angle of a number
A:pitch() N Gets the pitch of the angle
A:yaw() N Gets the yaw of the angle
A:roll() N Gets the roll of the angle
A:setPitch(N) A Returns a copy of the angle with Pitch replaced (use as Ang = Ang:setPitch(...))
A:setYaw(N) A Returns a copy of the angle with Yaw replaced (use as Ang = Ang:setYaw(...))
A:setRoll(N) A Returns a copy of the angle with Roll replaced (use as Ang = Ang:setRoll(...))
A:toString() S Gets the angle nicely formatted as a string "[P,Y,R]"
A:toVector() V Removed in r1340. Use vec(A) instead.
A:forward() V Gets the forward vector of the angle.
A:right() V Gets the right vector of the angle.
A:up() V Gets the up vector of the angle.

Table[]

Description[]

Tables are a way to create dynamic variables, store large numbers of data points and so on. It may be thought of as a list of data, where each bit of data is addressed with an index string. This is a string which is unique to each element of a datatype (a number element and a vector element may have identical indices without problems, but two number elements cannot). Tables can contain any datatype except table and array.

Assigning one table variable to equal another will make them both refer to the same table. If you want to make a new copy of a table which will thereafter be set and retrieved from independently of the original table, you must use clone().

Related Examples[]

Commands[]

In the interest of brevity, some commands which have many variants are shown as a pattern. <type> may be substituted with the capitalized name of any supported datatype, and * is the corresponding datatype symbol. For instance, R:push<type>(*) can mean R:pushNumber(N), or R:pushString(S).

Function Returns Description
table() T Creates an empty table
T:clone() T Creates an independent copy of a table
T:count() N Returns the number of used indexes in the table
invert(R) T Returns a lookup table for R. Usage: Index = T:number(toString(Value))
Don't overuse this function, as it can become expensive for arrays with > 20 entries!
invert(T) T Returns a lookup table for T. Usage: Key = T:string(toString(Value))
Don't overuse this function, as it can become expensive for tables with > 10 entries!
T:<type>(S) N Retrieves the requested datatype element from the indexed string. Returns the default value for the datatype if the index is nil.
T:set<type>(S,*) Saves the value as a table element with the specified index string

Array[]

Thanks to: Erkle

Description[]

Same as table, but with much less memory footprint and is numerically indexed instead. It is similar to E1's packet support. Arrays can contain any datatype except table and array.

Related Examples[]

Commands[]

In the interest of brevity, some commands which have many variants are shown as a pattern. <type> may be substituted with the capitalized name of any supported datatype, and * is the corresponding datatype symbol. For instance, R:push<type>(*) can mean R:pushNumber(N), or R:pushString(S).

Function Returns Description
array() R Creates an empty array
R:clone() R Creates an independant copy of an array
R:count() N Returns the number of used indexes in the array
R:sum() N Adds all numbers in the array together and returns result
R:concat() S Combines all strings and returns result
R:concat(S) S Combines all strings with specified string in between and returns result
R:average() N Gives the average of all numbers in array
R:min() N Returns the smallest number in array
R:minIndex() N Returns the index of the smallest number in array
R:max() N Returns the largest number in array
R:maxIndex() N Returns the index of the largest number in array
R:<type>(N) * Retrieves the array element indexed with the number. Returns the default value for the datatype if the element is nil.
R:set<type>(N,*) Saves the datatype as an array element with the specified index number
R:push<type>(*) Saves the data at the end of the array
R:pop<type>() * Deletes and returns the last entry in the array. Be sure not to use popNumber() on a vector or similar, as the data may be lost
R:pop() Deletes the last entry in the array
R:unshift<type>(*) Adds the data to the beginning of the array. Will move all other entries up one address
R:shift<type>() * Deletes and returns the first element of the array, moving other entries down one address to compensate.
R:shift() Удаляет первый элемент массива; all other entries will move down one address
R:insert<type>(N,*) * Inserts the data into the specified index; all entries after this index will move up to compensate
R:remove<type>(N) * Deletes and returns the specified entry, moving subsequent entries down to compensate
R:remove(N) Deletes the specified entry, moving subsequent entries down to compensate

Bone[]

Developed by: TomyLobo

Описание[]

Это расширение добавляет в Е2 поддержку энтити-костей. Костью может быть любая часть теля любого регдолла (голова, левая рука, правая нога, и т. д.).
Вы можете получит позицию костей, ориентацию, скорость, очень похоже на обычные пропы (хотя некоторых вещей не хватает).

Функции массивов и таблиц для костей так же предостовляются.

Связанные примеры[]

Команды[]

Функция Возвращает Описание
E:bone(N) B Возвращает N-ую кость энтити Е
E:bones() R Возвращает массивом все кости содержащиеся в энтити Е. Первый элемент этого массива имеет индекс 0!
E:boneCount() N Возвращает количество костей энтити Е.
nobone() B Возвращает недействительную(?) кость.
E:aimBone() B Возвращает ту кость, на которую смотрит игрок.
B:entity() E Возващает ту энтити, к которой принадлежит кость В.
B:index() N Возвращает индекс кости в своей энтити. Возвращает -1 если кость не действительна(?) или имеет место ошибка.
B:pos() V Возвращает позицию кости В
B:forward() V Возвращает вектор описывающий направление кости вперёд.
B:right() V Возвращает вектор описывающий направление кости вправо.
B:up() V Возвращает вектор описывающий направление кости вверх.
B:vel() V Возвращает вектор скорости кости В.
B:velL() V Возвращает вектор скорости кости В в локальной системе координат.
B:toWorld(V) V Трансформирует вектор из локальной системы координат кости в систему координат мира.
B:toLocal(V) V Трансформирует вектор из системы координат мира в локальную систему координат кости.
B:angVel() A Возвращает угловую скорость кости В.
B:angles() A Возвращает pitch, yaw и roll кости В.
B:bearing(V) N Returns the bearing (yaw) from B to V
B:elevation(V) N Returns the elevation (pitch) from B to V
B:mass() N Returns B's mass
B:massCenter() V Returns B's Center of Mass
B:massCenterL() V Returns B's Center of Mass in local coordinates
B:setMass(N) Sets B's mass (between 0.001 and 50,000)
B:inertia() V Gets the principal components of B's inertia tensor in the form vec(Ixx, Iyy, Izz)
B:applyForce(V) Applies force to B according to V's direction and magnitude
B:applyOffsetForce(V,V2) Applies force to B according to V from the location of V2
B:applyAngForce(A) Applies torque to B according to A
B:isFrozen() N Returns 1 if B is frozen, 0 otherwise

Wirelink[]

Description[]

Wirelinks are an alternative to normal wires that offer a number of advantages. Any number of inputs or outputs on a component can be manipulated with one Wirelink, and you can also use it to retrieve the entity of a wirelinked component. Since all Wirelinks are capable of two-way communication, wirelinks are not clear-cut inputs or outputs. As such, to avoid ambiguity wirelinks which the expression should be able to manipulate are always declared in the @inputs of the expression. To connect this input to another component, you must use the Wirelink tool on the component to create a new output on it of the type Wirelink, then wire the input to the output as normal.

Wirelink is not yet officially supported

Related Examples[]

Commands[]

Equal and Not Equal operators are available. XWL here means the Wirelink input.

Function Returns Description
XWL:isHiSpeed() N Returns true if the linked component is high-speed capable.
XWL:entity() E Returns the entity of the linked component.
XWL:hasInput(S) N Returns true if the linked component has an input of the specified name.
XWL:hasOutput(S) N Returns true if the linked component has an output of the specified name.
XWL:setNumber(S,N) Sets the component's input of the specified name equal to the number.
XWL:number(S) N Retrieves the component's output of the specified name.
XWL:setVector(S,V) Sets the component's input of the specified name equal to the vector.
XWL:vector(S) V Retrieves the component's output of the specified name.
XWL:setString(S,S) Sets the component's input of the specified name equal to the string.
XWL:string(S) S Retrieves the component's output of the specified name.
XWL:setXyz(V) Sets the X/Y/Z to the corresponding values in the vector.
XWL:xyz() V Retrieves the X/Y/Z as the corresponding values in the vector.
XWL:setEntity(S,E) Sets the component's input of the specified name equal to the entity.
XWL:entity(S) E Retrieves the component's output of the specified name.
XWL:writeCell(N,N) N Writes the second argument to the memory cell specified by the first argument. Returns true if successful.
XWL:readCell(N) N Returns contents of the specified memory cell.
XWL:writeString(S,N,N) A helper function for using the Wired Console Screen. The string will be written to the screen in white text on black background. The number arguments specify the starting position - X/Horizontal (0-29 recommended) and Y/vertical (0-17).
XWL:writeString(S,N,N,N) As above, with an extra argument for the text colour. This is in the form of a 3-digit RGB code. 0 is black, while 999 is white, 900 is pure red and so on.
XWL:writeString(S,N,N,N,N) As above, with an extra argument for background colour. 3-digit RGB again.
XWL:writeString(S,N,N,N,N,N) As above, with an extra argument for flashing text. 0 or 1 is recommended.


Complex[]

Developed by: Fizyk

Description[]

Complex numbers are an extension of real numbers to include roots of negative numbers as well.

Related Examples[]

Commands[]

Function Returns Description
comp() C Returns complex zero
comp(N) C Converts a real number to complex (returns complex number with real part N and imaginary part 0)
comp(N,N2) C Returns N+N2*i
i() C Returns the imaginary unit i
i(N) C Returns <n>*i
abs(C) C Returns the absolute value of C
arg(C) C Returns the argument of C
conj(C) C Returns the conjugate of C
real(C) N Returns the real part of C
imag(C) N Returns the imaginary part of C
exp(C) C Raises Euler's constant e to the power of C
log(C) C Calculates the natural logarithm of C
log(C,C2) C Calculates the logarithm of C2 to a complex base C
log(N,C) C Calculates the logarithm of C to a real base N
log2(C) C Calculates the logarithm of C to base 2
log10(C) C Calculates the logarithm of C to base 10
sqrt(C) C Calculates the square root of C
csqrt(N) C Calculates the complex square root of the real number N
C:pow(C2) C Raises C to the power C2
sin(C) C Calculates the sine of C
cos(C) C Calculates the cosine of C
sinh(C) C Calculates the hyperbolic sine of C
cosh(C) C Calculates the hyperbolic cosine of C
toString(C) S Formats C as a string.

Quaternion[]

Developed by: Fizyk

Description[]

Quaternions are an extension of complex numbers. Instead of a+bi, they are of form a+bi+cj+dk, where a, b, c, d are real numbers, and i, j, k are imaginary units. The imaginary units can be used as a basis in a 3D space, allowing quaternions to represent rotations.
Like on real and complex numbers, on quaternions you can perform addition, subtraction, multiplication and division. Operations that take a quaternion and a real/complex number are also supported (N+Q, Q*C, etc.). Beware: quaternion multiplication isn't commutative!
Note: Because multiplication isn't commutative with quaternions, there are two ways of dividing them. Q1/Q2 is the same as Q1*inv(Q2), the second way is inv(Q2)*Q1.
The extension also supports multiplying quaternions by vectors for the purpose of rotations. If you want to rotate vector V using quaternion Q, use this code:
V2 = vec(Q*V*inv(Q))

A short guide on quaternions can be found here: [1]

Commands[]

Function Returns Description
quat() Q Creates a zero quaternion
quat(N) Q Creates a quaternion with real part equal to N
quat(C) Q Creates a quaternion with real and "i" parts equal to C
quat(V) Q Converts a vector to a quaternion (returns V.x*i + V.y*j + V.z*k)
quat(N,N2,N3,N4) Q Returns N+N2i+N3j+N4k
quat(A) Q Converts A to a quaternion
quat(V,V2) Q Creates a quaternion given forward (V) and up (V2) vectors
quat(E) Q Converts angle of E to a quaternion
qi() Q Returns quaternion i
qi(N) Q Returns quaternion N*i
qj() Q Returns j
qj(N) Q Returns N*j
qk() Q Returns k
qk(N) Q Returns N*k
abs(Q) N Returns absolute value of Q
conj(Q) Q Returns the conjugate of Q
inv(Q) Q Returns the inverse of Q
Q:real() N Returns the real component of the quaternion
Q:i() N Returns the i component of the quaternion
Q:j() N Returns the j component of the quaternion
Q:k() N Returns the k component of the quaternion
exp(Q) Q Raises Euler's constant e to the power Q
log(Q) Q Calculates natural logarithm of Q
qMod(Q) Q Changes quaternion Q so that the represented rotation is by an angle between 0 and 180 degrees (by coder0xff)
slerp(Q,Q2,N) Q Performs spherical linear interpolation between Q and Q2. Returns Q for N=0, Q2 for N=1
Q:forward() V Returns vector pointing forward for Q
Q:right() V Returns vector pointing right for Q
Q:up() V Returns vector pointing up for Q
qRotation(V,N) Q Returns quaternion for rotation about axis V by angle N
qRotation(V) Q Construct a quaternion from the rotation vector V. Vector direction is axis of rotation, magnitude is angle in degress (by coder0xff)
rotationAngle(Q) N Returns the angle of rotation in degrees (by coder0xff)
rotationAxis(Q) V Returns the axis of rotation (by coder0xff)
rotationVector(Q) V Returns the rotation vector - rotation axis where magnitude is the angle of rotation in degress (by coder0xff)
vec(Q) V Converts Q to a vector by dropping the real component
matrix(Q) M Converts Q to a transformation matrix
Q:toAngle() A Returns angle represented by Q
toString(Q) S Formats Q as a string.

Базовые команды[]

Core[]

Описание[]

...

Команды[]

Команда Тип возврата Описание
first() N Выдает 1 если Е2 был установлен или перезапущен
duped() N Выдает 1 если Е2 был скопирован
inputClk() N Returns 1 if the expression was triggered by an input
reset() Reset the expression itself as if it was just spawned, stops execution
exit() Останавливает работу чипа

Self-Aware[]

Описание[]

With entity() you can use Entity-Support to get all the data from the expression-entity. With concmd() you can execute console Команды. hint() allows you to display strings quickly on your screen.

Also, the chip has the ability to thrust itself. Beware of the interval you're choosing for your contraption, because of the time response. (The thrust lasts for 10ms)

Related Examples[]

Команды[]

Function Returns Описание
entity() E Получает entity чипа
concmd(S) N Takes a string and executes it in console. Returns 1 if it succeeded and 0 if it failed.
The client must enable this in the console with "wire_expression2_concmd 1".
hint(S,N) Отображает подсказку S на N секунд (N being clamped between 0.7 and 7)
print(S) Отображает S в чате
printTable(T) Prints a table like the lua function PrintTable does, except to the chat area.
printTable(R) Prints an array like the lua function PrintTable does, except to the chat area.
applyForce(V) Applies force according to the vector given (Forces independently on each axis unlike a vector thruster)
applyOffsetForce(V,V) Applies force to the expression according to the first vector from the location of the second
selfDestruct() Уничтожает чип
selfDestructAll() Уничтожает чип и все с ним склеено
changed(*)

Checks if the value or variable was changed. Accepts any type except table and array.
It detects changes by checking whether it was called with a different parameter at the same point in the last execution.
Multiple calls to changed() in the _same_ execution are independent of each other.

Проверяет, было изменено значение или переменная. Принимает любой тип, кроме таблиц и массива. Он обнаруживает изменения, проверяя, был ли он вызван с в другой точке.Повторные вызовы changed() в том же исполнении являются независимыми друг от друга.

Timer[]

Описание[]

Timer functions are a way to trigger the expression to be run at a given time. Most interesting is the interval(N) function, that lets the expression be run continuously without needing triggering from inputs.

Команды[]

Function Returns Описание
runOnTick(N) If set to 1, the expression will execute once every game tick
tickClk() N Returns 1 if the current execution was caused by "runOnTick"
curtime() N Returns the current time since server-start in seconds
interval(N) Causes the expression to execute every N milliseconds (minimum delay is 10 milliseconds)
timer(S,N) Sets a one-time timer with entered name and delay in milliseconds
stoptimer(S) Stops a timer, can stop interval with stoptimer("interval")
clk() N Returns 1 if the current execution was caused by the interval
clk(S) N Returns 1 if the current execution was caused by the inserted name

Unit Conversion[]

Описание[]

All conversions are precise so it is recommended to round the result if it is going to be displayed (round()).

Related Examples[]

Команды[]

Function Returns Описание
toUnit(S,N) N Converts default garrysmod units to specified units
fromUnit(S,N) N Converts specified units to default garrysmod units
convertUnit(S,S,N) N Converts between two units

Units[]

Length Описание
mm миллиметры
cm сантиметры
dm дециметры
m метры
km километры
in дюймы (default)
ft футы
yd ярды
mi мили
nmi морская миля
Speed Описание
m/s метров в секунду
km/h километров в час
in/s дюймов в секунду
mi/h миль в час
mph miles per hour (more commonly used than mi/h)
knots knots (correct term for nautical miles per hour)
mach mach (times speed of sound)
mm/x millimeters per time unit
cm/x centimeters per time unit
dm/x decimeters per time unit
m/x meters per time unit
km/x kilometers per time unit
in/x inches per time unit
ft/x feet per time unit
yd/x yards per time unit
mi/x miles per time unit
nmi/x nautical miles per time unit
substitute x for s (per second), m (per minute) or h (per hour)
Weight Описание
g грамм
kg килограмм
t тон
oz ounces
lb pounds

Информация[]

Developed by: Beer

Описание[]

The following functions allow you to get various information about the server, such as the current map name, gamemode, etc.

Команды[]

Функции Возвращает Описание
map() S Возвращает текущее название карты
hostname() S Возвращает название сервера
isLan() N Returns 1 if lan mode is enabled
gamemode() S Возвращает название текущего gamemode
gravity() N Возвращает гравитацию
ping() N Returns the latency (Player:ping() для индивидуального игрока)
isSinglePlayer() N Возвращает 1,если в одиночной игре, а 0, если в сетевой игре
isDedicated() N Returns 1 if server is dedicated, 0 if listen
numPlayers() N Возвращает текущее число игроков на сервере
maxPlayers() N Возвращает максимальное число игроков на сервере
maxOfType(S) N Returns the maximum allowed of a certain type of entity, i.e. maxOfType("wire_thrusters"). Returns 0 if you enter an invalid parameter.
playerDamage() N Возвращает 1, если ПВП урон включен на этом сервере
convar(S) S Give a console command such as "name" and it returns the set value
convarnum(S) N Give a console command such as "sbox_godmode" and it returns the set value
time(S) N 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)
  • TIP: To get a list of all possible parameters for maxOfType(), open the console and type "find sbox_max". If you need "sbox_maxragdolls", you can simply pass "ragdolls" in the function.

Constraint[]

Developed by: ZeikJT

Описание[]

The following functions get information about entities based on constraints

Команды[]

Function Returns Описание
E:getConstraints() R Returns an array with all entities constrained to E.
E:hasConstraints() N Returns the number of the constraints E has
E:hasConstraints(S) N Returns the number of the constraints E has with the given constraint type (see the types list below)
E:isConstrained() N Returns 1 if E has constraints, 0 if not
E:isWeldedTo() E Returns the first entity E was welded to
E:isWeldedTo(N) E Возвращает Nth entity E was welded to
E:isConstrainedTo() E Returns the first entity E was constrained to
E:isConstrainedTo(N) E Returns the Nth entity E was constrained to
E:isConstrainedTo(S) E Returns the first entity E was constrained to with the given constraint type (see the types list below)
E:isConstrainedTo(S, N) E Returns the Nth entity E was constrained to with the given constraint type (see the types list below)
E:parent() E Returns the entity E is parented to.
E:parentBone() B Returns the bone E is parented to.


Constraint Types
AdvBallsocket
Axis
Ballsocket
Elastic
Hydraulic
Keepupright
Motor
Muscle
NoCollide
Pulley
Rope
Slider
Weld
Winch

Chat[]

Developed by: ZeikJT & Gwahir

Описание[]

The following functions are for reading the chat log. This is similar to the text receiver.

Related Examples[]

Команды[]

Function Returns Описание
runOnChat(N) 1 will cause the chip to run on chat events, 0 stops the chip from running on chat events, only needs to be called once (not every execution)
chatClk() N Returns 1 if the chip is being executed because of a chat event, 0 otherwise.
chatClk(E) N Returns 1 if the chip is being executed because of a chat event by the given player, 0 otherwise.
hideChat(N) If N != 0, hide the chat message that is currently being processed.
lastSaid() S Returns what the last message was in the chat log
lastSaidWhen() N Returns the time the last message was said
E:lastSaid() S Returns what the given player last said
E:lastSaidWhen() N Returns when the given player last said something
lastSpoke() E Returns the entity of the last player to speak

Color[]

Developed by: Jimlad

Описание[]

These Команды allow E2 to find the color of an entity and change it. Changing color only works on entities you own.

Uses RGBA (Red, Green, Blue, Alpha) values, although when only RGB is specified, alpha will not be changed.

Note that color values have a range of 0 - 255, where (0,0,0,255) is black, and (255,255,255,255) is white.

Alpha is equivalent to opacity, where 0 is completely transparent and 255 is completely opaque.

Команды[]

Function Returns Описание
E:getColor() V Returns the color of an entity as a vector (R,G,B)
E:getColor4() V4 Returns the color of an entity as a 4D vector (R,G,B,A)
E:getAlpha() N Returns the alpha of an entity
E:getMaterial() S Returns the material of an entity
E:setColor(N,N,N) Changes the RGB color of an entity (leaves alpha alone)
E:setColor(N,N,N,N) Changes the RGBA color of an entity
E:setColor(V) Changes the RGB color of an entity (leaves alpha alone), using a vector with values (R,G,B)
E:setColor(V,N) Changes the RGBA color of an entity, using a vector with values (R,G,B). The additional argument sets alpha
E:setColor(V4) Changes the RGBA color of an entity, using a 4D vector with values (R,G,B,A)
E:setAlpha(N) Changes the alpha of an entity
E:setMaterial(S) Sets the material of an entity. E:setMaterial("") to reset material

|}

Advanced extensions[]

Entity Discovery[]

Developed by: Gwahir, TomyLobo

Description[]

Use these to find and filter entities. The basic find functions will return how many entities were found but the actual entities are stored on the chip until they are accessed using find(), findResult(N), or findClosest(V)

There is a white list and a black list as well as functions for on the spot filtering and sorting White and black lists are always in effect and will be used automatically when you request a new list of entities. Control of the lists is achieved through the find[Exclude, Allow, Include, Disallow][Player, Prop, Model, Class] functions Exclude/Allow add/remove items from the black list while Include/Disallow do the same for the white list If the same object is covered by both the white list and the black list, the black list takes priority

In the case of names, classes and models, partial strings are acceptable.

Discovering entities is not cheap so suggested usage is to find what you're looking for an hold onto it in order to limit the number of queries you run. To prevent overuse of these features, two console variables have been included, wire_exp2_entFindRate and wire_exp2_playerFindRate. These are delays that control how often you can perform find queries, the ent variable is per chip, the player variable is for all chip owned by a specific player

Related Examples[]

Commands[]

Function Returns Description
findUpdateRate() N Returns the minimum delay between entity find events on a chip
findPlayerUpdateRate() N Returns the minimum delay between entity find events per player
findCanQuery() N Returns 1 if find functions can be used, 0 otherwise.
findInSphere(V,N) N Finds entities in a sphere around V with a radius of N, returns the number found after filtering
findInCone(V,V,N,A) N Like findInSphere but with a cone, arguments are for position, direction, length, and degrees (currently bugged, because the underlying function is bugged)
findInBox(V,V) N Like findInSphere but with a globally aligned box, the arguments are the diagonal corners of the box
findByName(S) N Find all entities with the given name
findByModel(S) N Find all entities with the given model
findByClass(S) N Find all entities with the given class
findPlayerByName(S) E Returns the player with the given name, this is an exception to the rule
findExcludeEntities(R) Exclude all entities from R from future finds
findExcludeEntity(E) Exclude E from future finds
findExcludePlayer(E) Exclude this player from future finds (put it on the entity blacklist)
findExcludePlayer(S) Exclude this player from future finds (put it on the entity blacklist)
findExcludePlayerProps(E) Exclude entities owned by this player from future finds
findExcludePlayerProps(S) Exclude entities owned by this player from future finds
findExcludeModel(S) Exclude entities with this model (or partial model name) from future finds
findExcludeClass(S) Exclude entities with this class (or partial class name) from future finds
findAllowEntities(R) Remove all entities from R from the blacklist
findAllowEntity(E) Remove E from the blacklist
findAllowPlayer(E) Remove this player from the entity blacklist
findAllowPlayer(S) Remove this player from the entity blacklist
findAllowPlayerProps(E) Remove entities owned by this player from the blacklist
findAllowPlayerProps(S) Remove entities owned by this player from the blacklist
findAllowModel(S) Remove entities with this model (or partial model name) from the blacklist
findAllowClass(S) Remove entities with this class (or partial class name) from the blacklist
findIncludeEntities(R) Include all entities from R in future finds, and remove others not in the whitelist
findIncludeEntity(E) Include E in future finds, and remove others not in the whitelist
findIncludePlayer(E) Include this player in future finds, and remove other entities not in the entity whitelist
findIncludePlayer(S) Include this player in future finds, and remove other entities not in the entity whitelist
findIncludePlayerProps(E) Include entities owned by this player from future finds, and remove others not in the whitelist
findIncludePlayerProps(S) Include entities owned by this player from future finds, and remove others not in the whitelist
findIncludeModel(S) Include entities with this model (or partial model name) in future finds, and remove others not in the whitelist
findIncludeClass(S) Include entities with this class (or partial class name) in future finds, and remove others not in the whitelist
findDisallowEntities(R) Remove all entities from R from the whitelist
findDisallowEntity(E) Remove E from the whitelist
findDisallowPlayer(E) Remove this player from the entity whitelist
findDisallowPlayer(S) Remove this player from the entity whitelist
findDisallowPlayerProps(E) Remove entities owned by this player from the whitelist
findDisallowPlayerProps(S) Remove entities owned by this player from the whitelist
findDisallowModel(S) Remove entities with this model (or partial model name) from the whitelist
findDisallowClass(S) Remove entities with this class (or partial class name) from the whitelist
findClearBlackList() Clear all entries from the entire blacklist
findClearBlackEntityList() Clear all entries from the entity blacklist
findClearBlackPlayerPropList() Clear all entries from the prop owner blacklist
findClearBlackModelList() Clear all entries from the model blacklist
findClearBlackClassList() Clear all entries from the class blacklist
findClearWhiteList() Clear all entries from the entire whitelist
findClearWhiteEntityList() Clear all entries from the player whitelist
findClearWhitePlayerPropList() Clear all entries from the prop owner whitelist
findClearWhiteModelList() Clear all entries from the model whitelist
findClearWhiteClassList() Clear all entries from the class whitelist
findResult(N) E Returns the indexed entity from the previous find event (valid parameters are 1 to the number of entities found)
findClosest(V) E Returns the closest entity to the given point from the previous find event
findToArray() R Formats the query as an array, R:entity(Index) to get a entity, R:string to get a description including the name and entity id.
find() E Equivalent to findResult(1)
findSortByDistance(V) N Sorts the entities from the last find event, index 1 is the closest to point V, returns the number of entities in the list
findClipToClass(S) N Filters the list of entities by removing all entities that are NOT of this class
findClipFromClass(S) N Filters the list of entities by removing all entities that are of this class
findClipToModel(S) N Filters the list of entities by removing all entities that do NOT have this model
findClipFromModel(S) N Filters the list of entities by removing all entities that do have this model
findClipToName(S) N Filters the list of entities by removing all entities that do NOT have this name
findClipFromName(S) N Filters the list of entities by removing all entities that do have this name
findClipToSphere(V,N) N Filters the list of entities by removing all entities NOT within the specified sphere (center, radius)
findClipFromSphere(V,N) N Filters the list of entities by removing all entities within the specified sphere (center, radius)
findClipToRegion(V,V2) N Filters the list of entities by removing all entities NOT on the positive side of the defined plane. (Plane origin, vector perpendicular to the plane) You can define any convex hull using this.

Global Variables[]

Developed by: ZeikJT

Description[]

Global variables are a way to exchange data between two expression chips without the need for any wiring at all.

The global variables will be sorted into groups so that you can avoid two chips overwriting each other's global data. By default a newly spawned chip will default to "default" as the group entry, but you can always change that by using the gSetGroup(s) function.

Remember, all global variables persist until you delete them or you leave the server. They will never automatically reset.

Using tables like this does isn't exactly a memory free deal, when using this on servers try to keep the amount of stored global variable at any one time down to a minimum.

As of right now the global group will be reset after every run. Also, try to keep the group setting down to a minimum as it can be costly.

Related Examples[]

Commands[]

Function Returns Description
gSetStr(S) Stores a string into the current group, use with gGetStr(S)
gSetStr(S,S) Stores the second string into the current group under the index specified by the first string
gSetStr(N,S) Stores the string into the current group under the index specified by the number
gSetNum(N) Stores a number into the current group, use with gGetNum(N)
gSetNum(S,N) Stores the number into the current group under the index specified by the string
gSetNum(N,N) Stores the second number into the current group under the index specified by the first number
gGetStr() S Returns the string under the current group stored only by gSetStr(S)
gGetStr(S) S Returns the string under the current group stored in the input string index, use with gSetStr(S,S)
gGetStr(N) S Returns the string under the current group stored in the input number index, use with gSetStr(N,S)
gGetNum() N Returns the number under the current group stored only by gSetNum(N)
gGetNum(S) N Returns the number under the current group stored in the input string index, use with gSetNum(S,N)
gGetNum(N) N Returns the number under the current group stored in the input number index, use with gSetNum(N,N)
gDeleteStr() S Like gGetStr() but deletes the value after retrieval
gDeleteStr(S) S Like gGetStr(S) but deletes the value after retrieval
gDeleteStr(N) S Like gGetStr(N) but deletes the value after retrieval
gDeleteNum() N Like gGetNum() but deletes the value after retrieval
gDeleteNum(S) N Like gGetNum(S) but deletes the value after retrieval
gDeleteNum(N) N Like gGetNum(N) but deletes the value after retrieval
gSetGroup(S) Sets the group that all global write, read, and delete functions will use, default is "default"
gGetGroup() S Returns the name of the current group for the chip
gShare(N) Determines whether or not the group you're in is available only to you or to all players. Defaults to 0. Any value but 0 will set your group to be accessible to all players. Be mindful that there are two groups with every name, one is shared, one is not; values do not transition between the two.
gResetGroup() Returns the current chip's group back to "default"
gDeleteAllStr() Deletes all of the global strings stored under the current group, including the one stored by gSetStr(S)
gDeleteAllNum() Deletes all of the global numbers stored under the current group, including the one stored by gSetNum(N)
gDeleteAll() Deletes all of the global values stored under the current group, including the ones stored by gSetStr(S) and gSetNum(N)

Built-In Ranger[]

Developed by: ZeikJT

Description[]

The built-in ranger is heavily based on Erkle's original ranger. There are however some new functionalities that can be found in the commands below. Keep in mind that if you want to apply an option you must set it pre-ranging.

This also introduces a new Variable type, the RD (defined as :ranger). It holds the data returned after a trace, you will need to use the trace data functions to retrieve useful data. These are to be used after you have done an actual trace.

I will add a simple example to showcase the syntax and functionality.

Related Examples[]

Commands[]

Function Returns Description
Ranger Options To be used before an actual ranger trace
rangerHitWater(N) Default is 0, if any other value is given it will hit water
rangerIgnoreWorld(N) Default is 0, if any other value is given it will ignore world
rangerDefaultZero(N) If given any value other than 0 it will default the distance data to zero when nothing is hit
rangerFilter(E) Feed entities you don't want the trace to hit
rangerFilter(R) Feed an array of entities you don't want the trace to hit
Ranger Tracing Gathers data, if options are declared prior to this they will be used
ranger(N) RD You input max range, it returns ranger data
ranger(N,N,N) RD Same as above with added inputs for X and Y skew
rangerAngle(N,N,N) RD You input the distance, x-angle and y-angle (both in degrees) it returns ranger data
rangerOffset(V,V) RD You input two vector points, it returns ranger data
rangerOffset(N,V,V) RD You input the range, a position vector, and a direction vector and it returns ranger data
Ranger Data Retreval Accesses data stored in an RD container
RD:distance() N Outputs the distance from the rangerdata input, else depends on rangerDefault
RD:position() V Outputs the position of the input ranger data trace IF it hit anything, else returns (0,0,0)
RD:entity() E Returns the entity of the input ranger data trace IF it hit an entity, else returns nil
RD:hit() N Returns 1 if the input ranger data hit anything and 0 if it didn't
RD:hitNormal() V Outputs a normalized vector perpendicular to the surface the ranger is pointed at.

Проигрывание звуков[]

Developed by: ZeikJT

Translated by: Vlad Schmidt from NxRP

Описание[]

Позволяет Expression 2 проигрывать звуки. Вы можете найти список с Half-life 2 звуками тут (here) или использовать GCFScape для прослушивания каждого звука.

Длительность указывается в секундах. Если звук должен быть зациклен, ставьте длительность на 0. Путь к файлу должен содержать слэши '/' и ни одного обратного слэша '\'.

Команды[]

Команда Возвращает Описание
soundPlay(N,N,S) soundPlay(int Index, int Duration, string Path to File)

Проигрывает звук где:

  • Index - индекс(число);
  • Duration - длительность;
  • Path to File - месторасположение звука;
soundPlay(S,N,S) soundPlay(string Index, int Duration, string Path to File)

Проигрывает звук где:

  • Index - индекс(строка);
  • Duration - длительность;
  • Path to File - месторасположение звука;
soundPlay(N,N,S,N) soundPlay(int Index, int Duration, string Path to File, int FadeTime)

FadeTime - указывает время "затухания" звука

soundPlay(S,N,S,N) soundPlay(string Index, int Duration, string Path to File, int FadeTime)

FadeTime - указывает время "затухания" звука

soundStop(N) Останавливает все звуки по индексу(int)
soundStop(N,N) Звук "затухает" (постепенно снижает громкость и выключается) в течении указанного времени. Принимает индекс в виде числа
soundStop(S) Останавливает все звуки по индексу(string)
soundStop(S,N) Звук "затухает" (постепенно снижает громкость и выключается) в течении указанного времени. Принимает индекс в виде строки
soundPitch(N,N) soundPitch(integer Index, integer Pitch) (стандартный Pitch 100)

Изменяет звуковое поле.

soundPitch(S,N) То же самое только берёт индекс в виде строки
soundVolume(N,N) soundVolume(integer Index, integer Volume) (стандартное значение 1)

Устанавливает громкость где:

  • integer Index - индекс(число)
  • integer Volume - громкость(число)
soundVolume(S,N) То же самое только берёт индекс в виде строки
soundPurge() Очищает и останавливает все звуки

NPC control[]

Developed by: Bobsymalone

Description[]

These functions allow you to control NPCs. You can create secondary AI systems responding to wire by telling NPCs how to feel about certain things, where to go, etc. You can also equip them with weapons.

Related Examples[]


Commands[]

Function Returns Description
E:npcStop() Прекращает любое действие НПС
E:npcGoWalk(V) Командует НПС идти на позицию V
E:npcGoRun(V) Командует НПС бежать на позицию V
E:npcFace(V) This will rotate the NPC to face position V. This is purely aesthetic and can't be used to aim their weapon.
E:npcAttack() Командует НПС бить
E:npcShoot() Командует НПС стрелять
E:npcGiveWeapon() Выдает НПС пулемет (SMG)
E:npcGiveWeapon(S) Выдает НПС оружие. Например: E:npcGiveWeapon("pistol"). Другие варианты оружия: "ar2", "crowbar", "357", "shotgun", "crossbow", "rpg", "frag", etc.
E:npcRelationship(E,S,N) Will set the NPC's relationship to the specified entity to the S input, priority N. Priority is any number between 0 and 999. The relationship string can be either "like" "neutral" "hate" or "fear". Same goes for all other relationship functions.
E:npcRelationship(S,S,N) Same as above, but sets relationship to an entire class specified by the first string. Example: "npc_manhack", "prop_physics".
E:npcRelationshipByOwner(E,S,N) N Sets the NPC's relationship to all currently existing NPCs owned by player E. Returns number of entities added to relationships.
E:npcDisp(E) S Returns the NPC's relationship to entity E.

Сигналы[]

Разработал: Gwahir и TomyLobo

Описание[]

Эти функции позволяют удаленно выполнять exp2 чипы , при условии, что чип настроен на получение данного сигнала


Область видимости[]

Сигналы ограничены определенными областями (0 - только вы, 1 - все, 2 - все кроме вас)

Упрощенно, true = все, false = только вы.

Области видимости применяются для указания тех, кто может получить ваш сигнал и чей сигнал вы можете получить.

Область видимости всегда применяется по отношению к владельцу. Так что если игрок A посылает в область видимости 1 и игрок B получает только из области видимости 0, он/она не получит сигнал, но игрок B получит сигнал из областей видимости 1 или 2


Группа[]

Установите группу чипа используя signalSetGroup(S) перед вызовом функций runOnSignal, sendSignal, или signalSetOnRemove

Изначально группа сигнала чипа имеет значение "default".

runOnSignal() будет относится к сигналу в пределах заданной группы, это также относится к посылаемому сигналу

Любой сигнал получаемый чипом будет запускать чип независимо от текущий группы (до тех пор пока он относится сигналу и группе посылаемомого сигнала)


Чип никогда не будет работать, если он посылает сигнал сам себе.

Signals are issued 10ms after the first unissued signal was sent.
There can only ever be one unissued signal/group combination per receiver in each scope.

Пример работы[]

Команды[]

Функция Возвращает Описание
signalSetGroup(S) Устанавливает текущую группу сигнала E-2 к S, используется во время вызова runOnSignal, signalSend, и signalSetOnRemove
signalGetGroup() S Возвращает текущую группу сигнала E-2
runOnSignal(S,N,N2) If N2 == 0 the chip will no longer run on this signal, otherwise it makes this chip execute when signal S is sent by someone in scope N.
signalClk() N Returns 1 if the chip was executed because of any signal, regardless of name, group or scope. Returns 0 otherwise.
signalClk(S) N Returns 1 if the chip was executed because the signal S was sent, regardless of group or scope. Returns 0 otherwise.
signalClk(S,N) N Returns 1 if the chip was executed because the signal S was sent to the scope N, regardless of group. Returns 0 otherwise.
signalClk(S,S2) N Returns 1 if the chip was executed because the signal S2 was sent in the group S, regardless of scope N . Returns 0 otherwise.
signalClk(S,S2,N) N Returns 1 if the chip was executed because the signal S2 was sent in the group S to the scope N. Returns 0 otherwise.
signalName() S Возвращает имя принимаемого сигнала
signalGroup() S Возвращает имя группы принимаемого сигнала
signalSender() E Возвращает entity чипа который отправил сигнал
signalSenderId() N Возвращает entity ID чипа который передал сигнал. Полезно, если entity больше не существует
signalSetOnRemove(S,N) Устанавливает сигнал посылаемый чипом, когда он удаляется
signalClearOnRemove() Убирает сигнал посылаемый чипом, когда он удаляется
signalSend(S,N) Посылает сигнал S в область видимости N. Дополнительные вызовы этой функции с тем же сигналом будут перезаписывать старый вызов пока сигнал выдается
signalSendDirect(S,E) Посылает сигнал S на указанный чип. Множественные вызовы для разных игроков не перекрывают друг друга
signalSendToPlayer(S,E) Посылает сигнал S к чипам , принадлежащим данному игроку. Множественные вызовы для разных игроков не перекрывают друг друга


GLON[]

Разработал: TomyLobo

Описание[]

Это расширение позволяет превратить строку в строку массив или таблицу значений. Неподдерживаемые типы элементов

  • Кости
  • Некоторые типы entity (Vehicle, NPC, Weapon)
  • данные рейнджера (ranger) если рейнджер был направлен на один из типов entity, упомянутых ранее .

Пример работы[]

Команды[]

Функция Возвращает Описание
glonEncode(R) S Декодирует R в строку, используя GLON
glonEncode(T) S Декодирует T в строку, используя

GLON

glonDecode(S) R Декодирует S в массив, используя GLON
glonDecodeTable(S) T Декодирует S в таблицу, используя GLON

3D Голограммы[]

Разработал: IamMcLovin и ZeikJT

Описание[]

Добавляет возможность проецирования 3D объектов. С этими объектами нельзя взаимодействовать как с большинством других пропов; единственный способ управлять ими - использовать эти функции.

При использовании функции holoCreate, имейте в виду, что существует задержка, связанная с созданием голограмм чтобы избежать зависания сервера. Избегайте многократного использования holoCreate. Вы должны использовать функцию HoloCreate только один раз для каждой голограммы в коде, например, используя функцию first(). Используйте остальные функции, например holoPos, чтобы обновлять их в дальнейшем.

Заметьте, что кроме wire_holograms_display_owners, все другие консольные команды могут использовать только администраторы!

Консольные команды[]

Функция Возвращает Описание
wire_holograms_display_owners Показывает лист владельцов галограмм
wire_holograms_remove_all Удаляет все голограммы на карте
wire_holograms_block Введите имя (или часть имени), чтобы запретить игроку создавать голограммы
wire_holograms_unblock Введите имя (или часть имени), чтобы снова позволить игроку создавать голограммы
wire_holograms_block_id Введите Steam ID, чтобы запретить игроку создавать голограммы
wire_holograms_unblock_id Введите Steam ID, чтобы снова позволить игроку создавать голограммы
wire_holograms_max Определяет максимальное количество голограмм которое которое может иметь игрок
wire_holograms_size_max Определяет максимальный размер голограмм в соответствии с функцией holoScale

Пример работы[]

Команды[]

Функция Возвращает Описание
holoCreate(N,V,V,A,V) Index, Position, Scale, Angle, Color (RGB)
Создать голограмму
holoCreate(N,V,V,A) Index, Position, Scale, Angle
Создать голограмму
holoCreate(N,V,V) Index, Position, Scale
Создать голограмму
holoCreate(N,V) Index, Position
Создать голограмму
holoCreate(N) Index
Создать голограмму
holoDelete(N) Index
Удаляет голограмму с указанным индексом
holoScale(N,V) Index, Scale
Размер голограммы
holoScaleUnits(N,V) Index, Scale
Scales a hologram in each direction according to Garry's Mod units, given by a vector
holoPos(N,V) Index, Position
Установить позицию голограммы
holoColor(N,V,N) Index, Color, Alpha
Изменить цвет голограммы
holoColor(N,V) Index, Color
Изменить цвет голограммы
holoAlpha(N,N) Index, Alpha
Меняет параметр Alpha голограммы
holoShadow(N,N) Index, Shadow
Установив это значение в 0 у голограммы отключаються все тени, установка значения в 1 приведёт к их отображению
holoAng(N,A) Index, Angle
Установить позицию вращения голограммы
holoModel(N,S,N) Index, Model, Skin
Установить модель на голограмму
holoModel(N,S) Index, Model
Установить модель на голограмму
holoSkin(N,N) Index, Skin
Смена скина голограммы
holoMaterial(N,S) Index, Material
Смена материала голограммы
holoRenderFX(N,N) Index, Render FX #
Изменяет эффект отображения для голограммы
holoParent(N,N) Index (current Holo), Index (Holo being parented to)
Прикрепляет одну голограмму к другой
holoParent(N,E) Index, Entity
Закрепить голограмму за ентитей
holoUnparent(N) Index
Убирает любые родительские свойства с голограммы
Список моделей
["cone"]
["cube"]
["cylinder"]
["icosphere"]
["icosphere2"]
["icosphere3"]
["prism"]
["pyramid"]
["sphere"]
["sphere2"]
["sphere3"]
["torus"]
["torus2"]
["torus3"]

Примеры[]

Если вы сделаете свой гайд по E2, пожалуйста добавьте его в этот список! Не забывайте про обмен(оставляйте там ссылочку на эту вики)

Смотрите также[]

От автора[]

Я хотел бы выразить благодарность всем кто сделал вклад в Expression 2, так или иначе, делая его тем, чем он сегодня является.

Shandolum, ZeikJT, Jimlad, Beer, Magos Mechanicus, Gwahir, chinoto, pl0x, Turck3, Ph3wl, Hunter234564, Fishface60, GUN, Bobsymalone, TomyLobo, Tolyzor, Jeremydeath, I am McLovin, Fizyk, Divran, Rusketh

И конечно тем, кто использовал его, предоставлял обратную связь или помогал другим знакомиться с ним!

Спасибо! // Syranide

P.S. Простите, если я забыл упомянуть кого-то!|}

Advertisement