Fix all whitespace errors

Now nobody's commit should be flagged by Travis unless it actually
introduces whitespace errors (which we do want to check for).

This doesn't fully sort out indentation everywhere, but does fix all
whitespace that Git doesn't like. You can check the whitespace across
the entire codebase with:

    git diff-tree --check "$(git hash-object -t tree /dev/null)" HEAD
This commit is contained in:
AbigailBuccaneer 2018-02-01 12:37:37 +00:00
parent b218ccb3ab
commit 9ae1f5504f
342 changed files with 1783 additions and 1796 deletions

2
.gitattributes vendored
View File

@ -14,4 +14,4 @@
*.vvd binary
*.wav binary
* text=auto
* text=auto

View File

@ -24,7 +24,7 @@ install:
- luarocks list --outdated --porcelain | awk '{ print $1, $3 }' | xargs --no-run-if-empty -n 2 luarocks install
script:
- git -c core.whitespace=-blank-at-eol,-blank-at-eof,-space-before-tab diff --check $TRAVIS_COMMIT_RANGE
- git diff --check $TRAVIS_COMMIT_RANGE
- git diff --name-only $TRAVIS_COMMIT_RANGE | grep '\.lua$' | grep -v '^lua/entities/gmod_wire_expression2/core/' | xargs --no-run-if-empty luacheck
- luacheck .luacheckrc

View File

@ -62,4 +62,4 @@ Constraints:1A790460{Y:31=N:242;Y:32=N:0;}1926A480{Y:33=T:18FACDC8;Y:35=Y:34;}1B
39:"Weld"
40:"Keepupright"
41:"angularlimit"
Saved:291
Saved:291

View File

@ -1,7 +1,7 @@
//Wired Hello World!
//Connect CPU membus input to console screen
//Connect CPUs CLK input to button (toggle)
//Notice how you can store your
//Notice how you can store your
//subroutines/calls in DATA area
jmp _code;
message:
@ -26,7 +26,7 @@ _code:
call WriteString;
//More about colors:
//Lower 3 digits are foreground,
//Lower 3 digits are foreground,
//and higher 3 digits are background
//Each of 3 digits shows amount of
//RED, GREEN, and BLUE (in order)

View File

@ -10,7 +10,7 @@
void main() {
float i;
udhSetBusAddress(65536);
cscrInitialize(0);
udhQueryDevices();
@ -19,10 +19,10 @@ void main() {
cscrSelect(i);
cscrSetActive(1);
cscrClear();
cscrSetCursor(0,0);
cscrPrintLine("Screen ",930);
cscrPrintNumber(i,930);
cscrPrintNumber(i,930);
}
cscrSelect(0);

View File

@ -37,7 +37,7 @@ float cscrSelectedScreen;
//Update console screen offsets
void cscrUDHQueryFunction() {
float i,n;
n = udhGetDevices(11,MAX_CONSOLE_SCREENS,cscrDevices);
n = udhGetDevices(11,MAX_CONSOLE_SCREENS,cscrDevices);
for (i = 0; i < n; i++) {
cscrOffsets[i] = udhGetDeviceOffset(cscrDevices[i]);
}
@ -83,12 +83,12 @@ void cscrClear() {
}
void cscrSetBackground(float col) {
if (!cscrOffsets[cscrSelectedScreen]) return;
if (!cscrOffsets[cscrSelectedScreen]) return;
*(cscrOffsets[cscrSelectedScreen]+BACKGROUND_COLOR) = col;
}
void cscrSetRotation(float rot) {
*(cscrOffsets[cscrSelectedScreen]+SCREEN_ROTATION) = rot;
*(cscrOffsets[cscrSelectedScreen]+SCREEN_ROTATION) = rot;
}
void cscrSetBrightness(float bright) {
@ -96,7 +96,7 @@ void cscrSetBrightness(float bright) {
}
void cscrLoadImage(char* imgdata) {
if (!cscrOffsets[cscrSelectedScreen]) return;
if (!cscrOffsets[cscrSelectedScreen]) return;
preserve ESI,EDI;
ESI = imgdata;
@ -105,7 +105,7 @@ void cscrLoadImage(char* imgdata) {
}
void cscrPutLine(char* scrptr, float col, char* str) {
if (!cscrOffsets[cscrSelectedScreen]) return;
if (!cscrOffsets[cscrSelectedScreen]) return;
char* curptr = scrptr;
while (*str) {
@ -118,7 +118,7 @@ void cscrPutLine(char* scrptr, float col, char* str) {
}
void cscrPutChar(char* scrptr, float col, char ch) {
if (!cscrOffsets[cscrSelectedScreen]) return;
if (!cscrOffsets[cscrSelectedScreen]) return;
*(cscrOffsets[cscrSelectedScreen]+scrptr*2+0) = ch;
*(cscrOffsets[cscrSelectedScreen]+scrptr*2+1) = col;
@ -146,26 +146,26 @@ void cscrPrintLine(char* str, float col) {
str++;
if (*str == 0) return;
}
*(cscrOffsets[cscrSelectedScreen]+cscrCharacterPointer[cscrSelectedScreen]*2+0) = *str;
*(cscrOffsets[cscrSelectedScreen]+cscrCharacterPointer[cscrSelectedScreen]*2+1) = col;
cscrCharacterPointer[cscrSelectedScreen]++;
if (cscrCharacterPointer[cscrSelectedScreen] >= 30*18) cscrNewLine();
cscrCharacterPointer[cscrSelectedScreen]++;
if (cscrCharacterPointer[cscrSelectedScreen] >= 30*18) cscrNewLine();
str++;
}
}
void cscrPrintNumber(float num, float col) {
if (!cscrOffsets[cscrSelectedScreen]) return;
float ndig,a;
a = num;
ndig = 0;
while (a > 0) {
ndig++;
a /= 10;
fint a;
fint a;
}
max ndig,1;
a = num;
@ -177,19 +177,19 @@ void cscrPrintNumber(float num, float col) {
mov EDX,a;
mod EDX,10;
add EDX,48;
*(cscrOffsets[cscrSelectedScreen]+charPtr*2+0) = EDX;
*(cscrOffsets[cscrSelectedScreen]+charPtr*2+1) = col;
charPtr--;
a /= 10;
fint a;
ndig--;
}
}
void cscrSetCursor(float x, y) {
if (!cscrOffsets[cscrSelectedScreen]) return;
if (!cscrOffsets[cscrSelectedScreen]) return;
cscrCharacterPointer[cscrSelectedScreen] = x+y*30;
}
}

View File

@ -37,7 +37,7 @@ string udhDeviceString17,"Sound emitter";
string udhDeviceString18,"Constant value";
string udhDeviceString19,"Data port";
string udhDeviceString20,"RAM";
udhDeviceName:
udhDeviceName:
db udhDeviceString0, udhDeviceString1, udhDeviceString2;
db udhDeviceString3, udhDeviceString4, udhDeviceString5;
db udhDeviceString6, udhDeviceString7, udhDeviceString8;
@ -63,7 +63,7 @@ void udhQueryDevices() {
//Run the query
udhBusOffset[16] = 32+MAX_UDH_DEVICES;
udhBusOffset[17] = 1;
udhBusOffset[17] = 1;
//Reconfigure all devices
//FIXME: only supports single extended bus right now
@ -95,7 +95,7 @@ float udhGetDeviceOffset(float busIndex) {
char* udhGetDeviceName(float busIndex) {
float deviceType = udhGetDeviceType(busIndex);
if ((deviceType >= 0) && (deviceType <= 20)) {
return udhDeviceName[deviceType];
return udhDeviceName[deviceType];
} else {
return udhDeviceName[1];
}
@ -107,20 +107,20 @@ void udhSetDeviceOffsetSize(float busIndex, char* offst, char* size) {
}
float udhGetNumDevices() {
return MAX_UDH_DEVICES;
return MAX_UDH_DEVICES;
}
float udhGetDevices(float type, float maxCount, char* deviceList) {
float i,devPtr,n;
devPtr = deviceList;
n = 0;
for (i = 0; i < MAX_UDH_DEVICES; i++) {
if ((udhGetDeviceType(i) == type) && (n < maxCount)) {
n++;
*devPtr++ = i;
*devPtr++ = i;
}
}
return n;
}
}

View File

@ -21,7 +21,7 @@ float isalnum(char c) {
preserve eax;
eax = c; max eax,0; min eax,_MAXCHARS;
eax = __ctype_characters[eax];
band eax,_LOWER+_UPPER+_DIGIT;
}
@ -265,8 +265,8 @@ __ctype_characters:
db _PUNCT; //7D }
db _PUNCT; //7E ~
db _CONTROL; //7F (DEL)
db _GRAPH; //80
db _GRAPH; //81
db _GRAPH; //82
db _GRAPH; //83
db _GRAPH; //83

View File

@ -34,7 +34,7 @@ int 1;
#ifdef ZCRT_EXTENDED_MODE
float zcrtInterruptTable[1024];
char* zcrtInterruptEntrypoint;
// Default interrupt handlers
zcrtErrorHandler:
//Execute handler if required

View File

@ -10,7 +10,7 @@
void *memcpy(void *dest, void *src, float n) {
preserve esi,edi;
register float rem;
esi = src;
edi = dest;
rem = n;
@ -64,7 +64,7 @@ void* memset(void *ptr, float c, float n) {
//appends the string src to dest
char* strcat(char *src, *dest) {
register char *srcptr, *destptr;
srcptr = src;
while (*++srcptr) ;
@ -77,7 +77,7 @@ char* strcat(char *src, *dest) {
char* strncat(char *src, *dest, float n) {
register char *srcptr, *destptr;
register float i;
srcptr = src;
srcptr--;
while (*++srcptr) ;
@ -107,7 +107,7 @@ char* strchr(char *str, c) {
char* strrchr(char *str, c) {
register char *strptr, ch;
register char *findptr;
findptr = 0;
strptr = str;
ch = c;
@ -135,7 +135,7 @@ float strcmp(char *src, *dest) {
float strncmp(char *src, *dest, float n) {
register char *srcptr, *destptr;
register float i;
srcptr = src;
destptr = dest;
i = n;
@ -167,7 +167,7 @@ char* strncpy(char *dest, *src, float n) {
destptr = dest;
srcptr = src;
i = n;
while (i-- > 0) {
if (*destptr++ = *srcptr++) continue;
while (i-- > 0) *destptr++ = 0;
@ -183,7 +183,7 @@ char* strncpy(char *dest, *src, float n) {
float strlen(char* str) {
register char* strptr;
register float n;
strptr = str;
n = 0;
while (*strptr++) n++;
@ -207,7 +207,7 @@ float strspn(char *str, *accept) {
//determines the length of the maximal initial substring consisting entirely of characters not in reject
float strcspn(char *str, char *reject) {
register char *s, *p;
for (s=str; *s; s++) {
for (p=reject; *p; p++) {
if (*p == *s) goto done;

View File

@ -21,4 +21,4 @@ if(A > B) {
Vector = vec(A, B, 0)
Vector = Vector + vec(0, 0, A + B)
Vector = Vector:normalized()
Vector = Vector:normalized()

View File

@ -8,10 +8,10 @@ Main();
void Main()
{
glClear( 0, 0, 0 ); // Clear screen
glCoordPipe( GL_CPIPE_N1_1 ); // Set coordinate pipe to [-1 to 1] mode
glCoordPipe( GL_CPIPE_N1_1 ); // Set coordinate pipe to [-1 to 1] mode
glVertexPipe( GL_VPIPE_XYZTRANSFORM ); // Set vertex pipe to xyz transformation
glLightPos( 0, 0, -20 ); // Set the light position
glLightColor( 255, 255, 255, 1 ); // Set the light color
@ -19,7 +19,7 @@ void Main()
0, 0, -5, // Camera pos
0, 0, 0, // Camera target
0, 1, 0 // Camera up
);
);
// Create variable to hold curtime
float time;
@ -31,22 +31,22 @@ void Main()
glTranslate( 0, 0, 0 ); // TRANSLATION X, Y, Z
glScale( 1, 1, 1 ); // SCALE X, Y, Z
glEnable( GL_VERTEX_BUFFER ); // Enable vertex buffer
glEnable( GL_VERTEX_BUFFER ); // Enable vertex buffer
glEnable( GL_VERTEX_ZSORT ); // Enable Z sorting
// Solid 3D polygon
glFillMode( GL_FILL_SOLID ); // Set fillmode as solid
glColor4( 100, 149, 237, 180 ); // Set draw color with alpha
glPoly3D( vertexBuffer, 12 ); // Draw 3D polygon
glPoly3D( vertexBuffer, 12 ); // Draw 3D polygon
glFlush(); // Flush the vertex buffer to the screen
// Wireframe 3D polygon
glLineWidth( 1 ); // Set line width
glFillMode( GL_FILL_WIREFRAME ); // Set fillmode as solid
glColor4( 255, 255, 255, 255 ); // Set draw color with alpha
glPoly3D( vertexBuffer, 12 ); // Draw 3D polygon
glPoly3D( vertexBuffer, 12 ); // Draw 3D polygon
glFlush(); // Flush the vertex buffer to the screen
glExit(); // Exit
}

View File

@ -9,49 +9,49 @@ void Main()
{
glSleep( 40 ); // Sleep for 40 milliseconds (Reduces fps lag)
glClear( 0, 0, 0 ); // Clear screen
glCoordPipe( GL_CPIPE_N1_1 ); // Set coordinate pipe to [-1 to 1] mode
glCoordPipe( GL_CPIPE_N1_1 ); // Set coordinate pipe to [-1 to 1] mode
glVertexPipe( GL_VPIPE_XYZTRANSFORM ); // Set vertex pipe to xyz transformation
glLightPos( 0, 0, -50 ); // Set the light position
glLightColor( 255, 255, 255, 1 ); // Set the light color
glLookAt(
0, 0, -2.25, // Camera pos
0, 0, 0, // Camera target
0, 1, 0 // Camera up
);
);
// Create variable to hold curtime
float time;
timer time;
// Create perspective and matrix transformations
glPerspective( 30, 1, 1, 20 ); // FOV, ASPECT RATIO, ZNEAR, ZFAR
glRotate( 1, 1, 0, time ); // AXIS X, Y, Z, ANGLE W
glTranslate( 0, 0, 0 ); // TRANSLATION X, Y, Z
glScale( 1, 1, 1, 0 ); // SCALE X, Y, Z
glEnable( GL_VERTEX_BUFFER ); // Enable vertex buffer
glEnable( GL_VERTEX_BUFFER ); // Enable vertex buffer
glEnable( GL_VERTEX_ZSORT ); // Enable Z sorting
glEnable( GL_VERTEX_LIGHTING ); // Enable vertex lighting
//glEnable( GL_VERTEX_CULLING ); // Enable face culling
// Solid 3D polygon
glFillMode( GL_FILL_SOLID ); // Set fillmode as solid
glColor4( 100, 149, 237, 180 ); // Set the draw color with alpha
glPoly3D( vertexBuffer, 20 ); // Draw 3D polygon
glFlush(); // Flush the vertex buffer to the screen
glDisable( GL_VERTEX_LIGHTING ); // Enable vertex lighting
// Wireframe 3D polygon
glLineWidth( 1 ); // Set line width of wireframe
glFillMode( GL_FILL_WIREFRAME ); // Set fillmode as wireframe
glColor4( 255, 255, 255, 255 ); // Set the draw color with alpha
glPoly3D( vertexBuffer, 20 ); // Draw 3D polygon
glFlush(); // Flush the vertex buffer to the screen
glExit(); // Exit
}

View File

@ -9,8 +9,8 @@ void Main()
{
glSleep( 40 ); // Sleep for 40 milliseconds (reduces fps lag)
glClear( 100, 149, 237 ); // Clear screen
glCoordPipe( GL_CPIPE_N1_1 ); // Set coordinate pipe to [-1 to 1] mode
glCoordPipe( GL_CPIPE_N1_1 ); // Set coordinate pipe to [-1 to 1] mode
glVertexPipe( GL_VPIPE_XYZTRANSFORM ); // Set vertex pipe to xyz transformation
glLightPos( 0, 0, -50 ); // Set the light position
@ -20,29 +20,29 @@ void Main()
0, 0, -2.8, // Camera pos
0, 0, 0, // Camera target
0, 1, 0 // Camera up
);
);
// Create variable to hold curtime
float time;
timer time;
// Create perspective and matrix transformations
glPerspective( 30, 1, 1, 20 ); // FOV, ASPECT RATIO, ZNEAR, ZFAR
glRotate( 0, 1, 0, time ); // AXIS X, Y, Z, ANGLE W
glTranslate( 0, -0.1, 0, 0 ); // TRANSLATION X, Y, Z
glScale( 1, 1, 1, 0 ); // SCALE X, Y, Z
glEnable( GL_VERTEX_BUFFER ); // Enable vertex buffer
glEnable( GL_VERTEX_BUFFER ); // Enable vertex buffer
glEnable( GL_VERTEX_ZSORT ); // Enable Z sorting
glEnable( GL_VERTEX_LIGHTING ); // Enable vertex lighting
glEnable( GL_VERTEX_CULLING ); // Enable face culling
// Solid 3D polygon
glFillMode( GL_FILL_SOLID ); // Set fillmode as solid
glColor4( 255, 255, 255, 255 ); // Set draw color with alpha
glPoly3D( vertexBuffer, 30 ); // Draw 3D polygon
glPoly3D( vertexBuffer, 30 ); // Draw 3D polygon
glFlush(); // Flush the vertex buffer to the screen
glExit(); // Exit
}
@ -71,7 +71,7 @@ db 0.38,0.01,0; db 0.47,0.25,0; db -0.47,0.25,0;
db -0.47,0.25,0.25; db 0.38,0.01,0.25; db -0.38,0.01,0.25;
db 0.38,0.01,0.25; db -0.47,0.25,0.25; db 0.47,0.25,0.25;
db -0.38,0.01,0; db -0.38,0.01,0.25; db 0.38,0.01,0;
db 0.38,0.01,0; db -0.38,0.01,0.25; db 0.38,0.01,0.25;
db 0.38,0.01,0; db -0.38,0.01,0.25; db 0.38,0.01,0.25;
db -0.47,0.25,0; db 0.47,0.25,0; db -0.47,0.25,0.25;
db -0.47,0.25,0.25; db 0.47,0.25,0; db 0.47,0.25,0.25;
db -1,1,0; db -0.75,1,0; db -1,1,0.25;

View File

@ -9,8 +9,8 @@ void Main()
{
glSleep( 60 ); // Sleep for 60 milliseconds (reduces fps lag)
glClear( 0, 0, 0 ); // Clear screen
glCoordPipe( GL_CPIPE_N1_1 ); // Set coordinate pipe to [-1 to 1] mode
glCoordPipe( GL_CPIPE_N1_1 ); // Set coordinate pipe to [-1 to 1] mode
glVertexPipe( GL_VPIPE_XYZTRANSFORM ); // Set vertex pipe to xyz transformation
glLightPos( -1, -1, -1 ); // Set the light position
@ -20,7 +20,7 @@ void Main()
0, 0, -25, // Camera pos
0, 0, 0, // Camera target
0, 1, 0 // Camera up
);
);
// Loop and draw 4 models
for (i = 0; i < 4; i++)
@ -30,14 +30,14 @@ void Main()
zTranslate *= -16;
mod zTranslate,16;
zTranslate += (i * 16);
// Create perspective and matrix transformations
glPerspective( 8, 1, 0.4, 20 ); // FOV, ASPECT RATIO, ZNEAR, ZFAR
glRotate( 0, 0, 0, 0 ); // AXIS X, Y, Z, ANGLE W
glTranslate( 0, 0, zTranslate ); // TRANSLATION X, Y, Z
glScale( 1.2, 1, 8 ); // SCALE X, Y, Z
glEnable( GL_VERTEX_BUFFER ); // Enable vertex buffer
glEnable( GL_VERTEX_BUFFER ); // Enable vertex buffer
glEnable( GL_VERTEX_ZSORT ); // Enable Z sorting
glEnable( GL_VERTEX_LIGHTING ); // Enable vertex lighting
glEnable( GL_VERTEX_CULLING ); // Enable face culling
@ -47,7 +47,7 @@ void Main()
glColor4( 255, 255, 255, 150 ); // Set the draw color with alpha
glPoly3D( VertexBuffer, 12 ); // Draw 3D polygon
glFlush(); // Send our vertex buffer to screen
// Wireframe 3D polygon
glLineWidth( 1 ); // Set line width of wireframe
glFillMode( GL_FILL_WIREFRAME ); // Set fillmode to wireframe
@ -68,6 +68,6 @@ db -1,1,-1; db -1,1,1; db 1,1,1;
db 1,1,-1; db 1,1,1; db 1,-1,-1;
db 1,-1,-1; db 1,1,1; db 1,-1,1;
db -1,1,-1; db -1,-1,-1; db -1,1,1;
db -1,-1,-1; db -1,-1,1; db -1,1,1;
db -1,-1,-1; db -1,-1,1; db -1,1,1;
db 1,-1,-1; db 1,-1,1; db -1,-1,-1;
db -1,-1,-1; db 1,-1,1; db -1,-1,1;

View File

@ -62,4 +62,4 @@ vector2f textpos,0.1,0.1; // Text position
vector2f d,1.0,1.0; // Movement direction & speed
//
string text,'Bouncing ball!'; // "Bouncing ball!"
//////////////////////////////////
//////////////////////////////////

View File

@ -135,4 +135,4 @@ vector3f vLookAt_Center, 0, 0, 0; //What we look at
vector3f vLookAt_Up, 0, 1, 0; //Where our matt-hat is
color fg_color,255,255,25;
color bg_color,64,32,12;
color bg_color,64,32,12;

View File

@ -81,4 +81,4 @@ db 340,238
db 286,257
db 274,203
db 311,213
//===========================================
//===========================================

View File

@ -88,7 +88,7 @@ dexit;
vec2f hud_pos1,50,20;
string hud_text1,'ROLL %i %tPITCH %i%tHDG %i';
alloc roll;
alloc roll;
alloc pitch;
alloc hdg;

View File

@ -17,27 +17,27 @@ void Main()
{
glVertexMode( 1 ); // Enable vertex mode
glColor( 255, 255, 255 ); // Set draw color
// Set texture as background
glBindTexture( "phoenix_storms/lag_sign" );
glClearTexture();
glBindTexture( 0 ); // Discard texture
glFont( GL_FONT_AKBAR ); // Set font type
glFontSize( 36 ); // Set font size
glWriteString( 2, 2, "LAG-O-METER" ); // Write string to screen
glOffset( lineWidth, 90 ); // Offset the screen coordinates
glColor4( 0, 0, 0, 160 ); // Set draw color with alpha
glRectWH( 0, 0, frameWidth, frameHeight ); // Draw rectangle
glColor( 255, 255, 255 );
glColor( 255, 255, 255 );
glLineWidth( lineWidth ); // Set line width
glORectWH( 0, 0, frameWidth, frameHeight ); // Draw outlined rectangle
glLineWidth( 1 ); // Set line width to 1
// Loop and make a bunch of connected lines
for (i = 0; i < lines; i++)
{
@ -54,9 +54,9 @@ void Main()
y *= frameHeight;
glLine( ox, oy, x, y ); // Draw line on graph
}
glOffset( 0, 0 ); // Set screen offset back to 0,0
glWriteString( 2, 400, "INTENSE LAG DETECTED" );
glExit(); // Exit
}

View File

@ -18,7 +18,7 @@ DrawLoop:
fsin #HSL.R,EAX; mul #HSL.R,127; add #HSL.R,128; add EAX,1.57;// mul EAX,2;
fsin #HSL.G,EAX; mul #HSL.G,127; add #HSL.G,128; add EAX,1.57;// mul EAX,2;
fsin #HSL.B,EAX; mul #HSL.B,127; add #HSL.B,128;
dcolor HSL;
//Looks very nice
@ -26,7 +26,7 @@ DrawLoop:
dline StartPoint2,EndPoint;
dline StartPoint3,EndPoint;
dline StartPoint4,EndPoint;
mul EDX,EBP;
add #Angle,EDX;
loop DrawLoop;

View File

@ -38,7 +38,7 @@
// drotatescale EAX,EBX; mul EBX,2;
dsetwidth 0.8;
call Draw.Background;
call Draw.Background;
dexit;
alloc Time;
@ -48,7 +48,7 @@ Draw.Background:
//Draw all the rectangles
mov EAX,#Background.MinDepth; mov ECX,#Background.ShadeStart;
BackgroundLoop:
mov EDX,#Time; add EDX,EAX;
mov EDX,#Time; add EDX,EAX;
mov EBP,#Time; div EBP,6.28; fcos EBP,EBP;
fsin EDI,EDX; mul EDI,EBP; mul EDI,0.8; sub EDI,1;
@ -59,8 +59,8 @@ Draw.Background:
mov EDX,ECX; fpwr EDX,2;
mov #regZOffset,EAX;
dcolor _rect.color;
dcolor _rect.color;
// Uncomment this for trippy HSL color
// mov ESI,#Time; add ESI,EAX;
// fsin #HSL.R,ESI; mul #HSL.R,127; add #HSL.R,128; add ESI,1.57;// mul EAX,2;

View File

@ -28,7 +28,7 @@ while(1){idle} //Infinatly loop
void main(){ //Main function
dsetbuf_spr; //Use sprite buffer
setColor(255,255,255); //Set the colour to white
rect(0,0,512,512); //Draw a large rectangle
@ -36,58 +36,58 @@ void main(){ //Main function
width = 512; //GPU Width
height = 512; //GPU Height
noise = 5; //How noisy it will be
//Give initial corner values
R1 = random(1);
R2 = random(1);
R3 = random(1);
R4 = random(1);
plasma(0,0,width,height,R1,R2,R3,R4) //Start recursive function
}
void plasma(float x, y, width, height, c1, c2, c3, c4){ //Plasma function
//Setup local variables
float edge1, edge2, edge3, edge4, midPoint;
//Work out the size of the next segments
float newWidth = width / 2;
float newHeight = height / 2;
if((width > gridSize)||(height > gridSize)){ //If it is still bigger than the rectangle size
midPoint = (c1 + c2 + c3 + c4) / 4 + displace(newWidth + newHeight); //Randomly change the midpoint
//Calculate edges by averaging the corners
edge1 = (c1 + c2) / 2;
edge2 = (c2 + c3) / 2;
edge3 = (c3 + c4) / 2;
edge4 = (c4 + c1) / 2;
edge1 = (c1 + c2) / 2;
edge2 = (c2 + c3) / 2;
edge3 = (c3 + c4) / 2;
edge4 = (c4 + c1) / 2;
//Make sure it doesn't displace too far
max midPoint,0;
min midPoint,1;
//Run on the newly calculated segments
plasma(x, y, newWidth, newHeight, c1, edge1, midPoint, edge4);
plasma(x + newWidth, y, newWidth, newHeight, edge1, c2, edge2, midPoint);
plasma(x + newWidth, y + newHeight, newWidth, newHeight, midPoint, edge2, c3, edge3);
plasma(x + newWidth, y, newWidth, newHeight, edge1, c2, edge2, midPoint);
plasma(x + newWidth, y + newHeight, newWidth, newHeight, midPoint, edge2, c3, edge3);
plasma(x, y + newHeight, newWidth, newHeight, edge4, midPoint, edge3, c4);
}else{ //Woo! It's the right size
float c = (c1 + c2 + c3 + c4) / 4; //Average the corners
float grey = c*255; //Multiply the corners by 255 to get a valid color
setColor(grey,grey,grey); //Set the color to your new color based on the "height"
rect(x,y,gridSize,gridSize); //Draw your rectangle
}
}
float displace(float num){ //Displace function, it just works
float m = num / (width + height) * (1/noise);
R1 = random(1);
return (R1-0.5) * m;
float m = num / (width + height) * (1/noise);
R1 = random(1);
return (R1-0.5) * m;
}
float random(float x){ //C version of the ASM rand opcode
@ -100,17 +100,17 @@ void setColor(float r,float g,float b){ //C version of the dcolor opcode
mov #col.r,r;
mov #col.g,g;
mov #col.b,b;
dcolor col;
}
void rect(float x, float y, float width, float height){ //C version of the drectwh opcode
mov #pos.x,x;
mov #pos.y,y;
mov #size.x,width;
mov #size.y,height;
drectwh pos, size;
dswap; //dswap to make it show since we're drawing to the sprite buffer
}
}

View File

@ -9,22 +9,22 @@ void Main()
{
// Enable vertex mode
glVertexMode( 1 );
// Draw to sprite buffer
glSetRenderTarget( GL_BUFFER_BACK );
glClear( 0, 255, 0 );
// Draw to vertex buffer (world)
glSetRenderTarget( GL_BUFFER_VERTEX );
glEnable( GL_VERTEX_TEXTURING );
// Sample from sprite 0
glTextureSize( 256 );
glTexture( 0 );
glClear( 0, 255, 0 );
glRectWH( 128, 128, 256, 256 );
glSetRenderTarget( GL_BUFFER_FRONT );
glExit();
}

View File

@ -15,9 +15,9 @@ float i, j, day;
void Main()
{
dentrypoint 0,DrawThread;
dentrypoint 0,DrawThread;
dentrypoint 4,AsyncThread;
*regHWClear = 0
*regAsyncFreq = 200000;
*regAsyncClk = 1;
@ -31,25 +31,25 @@ void DrawThread()
void AsyncThread()
{
glBegin();
glClear( 35, 35, 35 ); // Clear screen color
glColor( 255, 255, 255 ); // Set draw color
glFont( GL_FONT_ARIAL ); // Set font type
glFontSize( 36 ); // Set font size
glWriteString( 16, 6, 'Simple-Calendar 1.0');
glColor( 120, 120, 120 );
glOffset( 16, 64 ); // Set screen offset
glRectWH( 0, 0, sizex + linewidth, sizey + linewidth); // Draw rectangle
glFont( GL_FONT_TREBUCHET );
glFontSize( 14 );
// Calculate rectangle size
float sx = (sizex / rows) - linewidth;
float sy = (sizey / cols) - linewidth;
// Loop through rows
for (i = 0; i < rows; i++)
{
@ -59,19 +59,17 @@ void AsyncThread()
// Calculate x,y coordinate to draw at
float x = i * (sizex / rows);
float y = j * (sizey / cols);
glColor( 200, 200, 200 ); // Set draw color
glRectWH( x + linewidth, y + linewidth, sx, sy ); // Draw rectangle
glColor( 0, 0, 0 ); // Set draw color
// Write integer to screen
day = i + (j * rows)
glWriteInt( x + linewidth + 2, y + linewidth + 2, day + 1 );
glWriteInt( x + linewidth + 2, y + linewidth + 2, day + 1 );
}
}
glEnd();
}

View File

@ -13,8 +13,8 @@ void Main()
glBindTexture( 'brick/brick_model' );
glColor( 255, 255, 255, 255 );
glRectWH( 128, 128, 256, 256 );
glExit();
glExit();
}
// ZASM version

View File

@ -15,7 +15,7 @@ void Main()
glColor( 255, 255, 255 ); // Set draw color
glCircle( *orig.x, *orig.y, 0.66, 40 ); // Draw circle (x, y, radius, quality)
glColor( 0, 0, 0 );
glCircle( *orig.x, *orig.y, 0.64, 40 );
@ -26,13 +26,13 @@ void Main()
*PosR.x = *cos;
*PosR.x *= 0.65;
*PosR.x += *orig.x;
*PosR.y = *sin;
*PosR.y *= 0.65;
*PosR.y += *orig.y;
*PosX.x = *PosR.x;
glLineWidth( 0.01 ); // Set line width
glFontSize( 24 ); // Set font size
@ -46,10 +46,10 @@ void Main()
glLine( *PosR.x, *PosR.y, *PosX.x, *PosX.y );
*sin *= -1; // Negate
glWriteFmt( -0.95, -0.85, sSin );
glColor( 255, 255, 255 );
glLine( *orig.x, *orig.y, *PosR.x, *PosR.y ); // Draw line
glExit(); // Exit
}

View File

@ -51,4 +51,4 @@ vec2f p3,60,60;
vec2f p4,430,430;
vec2f p5,70,70;
vec2f p6,440,440;
vec2f p6,440,440;

View File

@ -120,4 +120,3 @@ vec2f _a_73,272,440
string _s_74,'Y: %f'
vec2f _a_76,272,456
string _s_77,'Z: %f'

View File

@ -151,13 +151,13 @@ void glTextureOffsetUV( float u, float v ) {
// Frame
void glSleep( float ms ) {
div ms,1000;
timer #GL_CURTIME;
timer #GL_CURTIME;
sub #GL_CURTIME,#GL_TIMESTAMP;
if (*GL_CURTIME <= ms) {
mov #regHWClear,0;
dexit;
}
timer #GL_TIMESTAMP;
timer #GL_TIMESTAMP;
}
void glExit() {
dexit;
@ -360,7 +360,7 @@ float glParamList() {
// 3D graphics
void glPoly3D( float* buffer, float count ) {
if (*GL_MUPDATE == 1) {
mov #GL_MUPDATE,0;
mrotate GL_MROTATEMATRIX,GL_VROTATE;
@ -371,10 +371,10 @@ void glPoly3D( float* buffer, float count ) {
mmul GL_MMODELMATRIX,GL_MSCALEMATRIX;
mmov GL_MMODELVIEWMATRIX,GL_MVIEWMATRIX;
mmul GL_MMODELVIEWMATRIX,GL_MMODELMATRIX;
mload GL_MMODELVIEWMATRIX;
mload GL_MMODELVIEWMATRIX;
mloadproj GL_MPROJECTIONMATRIX;
}
if (*GL_FILLMODE == GL_FILL_SOLID) {
dvxdata_3f buffer,count;
}
@ -420,7 +420,7 @@ void glPerspective( float fov, float asp, float znear, float zfar ) {
mov #GL_MUPDATE,1;
}
void glRotate( float x, float y, float z, float w ) {
mov #GL_VROTATE.x,x; mov #GL_VROTATE.y,y; mov #GL_VROTATE.z,z; mov #GL_VROTATE.w,w;
mov #GL_VROTATE.x,x; mov #GL_VROTATE.y,y; mov #GL_VROTATE.z,z; mov #GL_VROTATE.w,w;
mov #GL_MUPDATE,1;
}
void glTranslate( float x, float y, float z ) {
@ -500,5 +500,3 @@ vec4f GL_VROTATE;
vec4f GL_VTRANSLATE;
vec4f GL_VPERSPECTIVE;
vec4f GL_VSCALE,1,1,1,0;

View File

@ -13,15 +13,15 @@ float __GLT_VERTCNT = 0;
void gltVertex(float x, float y, float z)
{
if ((__GLT_VERTCNT / 3) >= GLT_MAX_TRIANGLES)
return;
return;
float* ptr = __GLT_VERTBUFF;
ptr += (__GLT_VERTCNT * 3);
*ptr = x;
*(++ptr) = y;
*(++ptr) = z;
__GLT_VERTCNT++;
}
@ -44,7 +44,7 @@ void gltQuad(float tlx, float tly, float tlz,
tlx, tly, tlz,
blx, bly, blz
);
gltTriangle(
brx, bry, brz,
trx, try, trz,
@ -55,42 +55,42 @@ void gltQuad(float tlx, float tly, float tlz,
void gltCube(float cex, float cey, float cez, float size)
{
float s2 = size / 2;
gltQuad(
cex - s2, cey + s2, cez - s2,
cex + s2, cey + s2, cez - s2,
cex + s2, cey - s2, cez - s2,
cex - s2, cey - s2, cez - s2
);
gltQuad(
cex + s2, cey + s2, cez + s2,
cex - s2, cey + s2, cez + s2,
cex - s2, cey - s2, cez + s2,
cex + s2, cey - s2, cez + s2
);
gltQuad(
cex - s2, cey + s2, cez + s2,
cex - s2, cey + s2, cez - s2,
cex - s2, cey - s2, cez - s2,
cex - s2, cey - s2, cez + s2
);
gltQuad(
cex + s2, cey + s2, cez - s2,
cex + s2, cey + s2, cez + s2,
cex + s2, cey - s2, cez + s2,
cex + s2, cey - s2, cez - s2
);
gltQuad(
cex - s2, cey + s2, cez + s2,
cex + s2, cey + s2, cez + s2,
cex + s2, cey + s2, cez - s2,
cex - s2, cey + s2, cez - s2
);
gltQuad(
cex - s2, cey - s2, cez - s2,
cex + s2, cey - s2, cez - s2,
@ -108,13 +108,13 @@ void gltFlushBuffer()
{
if (__GLT_VERTCNT <= 3)
return;
float vcnt = __GLT_VERTCNT;
float tcnt = (vcnt / 3) - (vcnt % 3);
if (tcnt > GLT_MAX_TRIANGLES)
tcnt = GLT_MAX_TRIANGLES;
glPoly3D(__GLT_VERTBUFF, tcnt);
glFlush();
}

View File

@ -35,22 +35,22 @@ void main()
fpwr note,(trackA[i]/12);
note /= 100;
chpitch 0,note;
// Track B
note = 2;
fpwr note,(trackB[i]/12);
note /= 100;
chpitch 1,note;
// Bass
note = 2;
fpwr note,(bass[i]/12);
note /= 100;
chpitch 2,note;
// Index
i++; mod i,tracklen;
// Repeat
jmp main;
}
@ -96,9 +96,9 @@ db 87,87,87,87, 87,87,87,87, 87,87,87,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,78,7
// Part 2
db 90,90,90,90, 90,90,90,90, 90,90,90,-1, 90,90,90,90, 90,90,90,90, 90,90,90,-1;
db 90,90,90,90, 90,90,90,90, 90,90,90,-1, 90,90,90,-1, 92,92,-1,-1, -1,-1,90,90;
db 88,88,88,88, 88,88,88,88, 88,88,88,-1, 88,88,88,88, 88,88,88,88, 88,88,88,-1;
db 88,88,88,88, 88,88,88,88, 88,88,88,-1, 88,88,88,-1, 90,90,-1,-1, -1,-1,88,88;
db 87,87,87,87, 87,87,87,87, 87,87,87,-1, 80,80,80,-1, 82,82,82,-1, 88,88,88,-1;
db 88,88,88,88, 88,88,88,88, 88,88,88,-1, 88,88,88,88, 88,88,88,88, 88,88,88,-1;
db 88,88,88,88, 88,88,88,88, 88,88,88,-1, 88,88,88,-1, 90,90,-1,-1, -1,-1,88,88;
db 87,87,87,87, 87,87,87,87, 87,87,87,-1, 80,80,80,-1, 82,82,82,-1, 88,88,88,-1;
db 87,-1,87,-1, 87,87,87,87, 87,-1,82,82, 83,83,83,83, 83,83,83,83, 83,83,83,-1;
db 0; // End string
@ -106,7 +106,7 @@ db 0; // End string
trackB:
// Intro
db 73,73,73,73, 72,72,72,72, 71,71,71,71, 70,70,70,70, 71,71,71,71, 72,72,72,72;
db 73,73,73,73, 72,72,72,72, 71,71,71,71, 70,70,70,70, 71,71,71,71, 72,72,72,72;
db 73,-1,73,-1, 73,73,73,-1, 75,75,75,-1, 76,76,76,76, 76,76,76,-1, -1,-1,-1,-1;
// Part 1
@ -129,7 +129,7 @@ db 82,-1,82,-1, 82,82,82,-1, -1,-1,76,76, 75,75,75,75, 75,75,75,75, 75,75,75,-
db 0; // End string
bass:
bass:
// Intro
db -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1;
@ -154,4 +154,3 @@ db 47,47,47,-1, 66,66,66,-1, 75,75,75,-1, 54,54,54,-1, 66,66,66,-1, 66,66,66,-1;
db 64,-1,64,-1, 64,64,64,-1, -1,-1,58,58, 59,59,59,59, 59,59,59,59, 59,59,59,-1;
db 0; // End string

View File

@ -201,9 +201,9 @@
See the License for the specific language governing permissions and
limitations under the License.
Wiremod was previous licensed under GPL3. If you were one of the few developers
we were unable to contact prior to the switch, and do not wish your
contributions to remain in the project under the Apache2 license,

View File

@ -9,7 +9,7 @@ ENT.AdminOnly = false
ENT.IsWire = true
if CLIENT then
if CLIENT then
local wire_drawoutline = CreateClientConVar("wire_drawoutline", 1, true, false)
function ENT:Initialize()
@ -19,20 +19,20 @@ if CLIENT then
function ENT:Draw()
self:DoNormalDraw()
Wire_Render(self)
if self.GetBeamLength and (not self.GetShowBeam or self:GetShowBeam()) then
if self.GetBeamLength and (not self.GetShowBeam or self:GetShowBeam()) then
-- Every SENT that has GetBeamLength should draw a tracer. Some of them have the GetShowBeam boolean
Wire_DrawTracerBeam( self, 1, self.GetBeamHighlight and self:GetBeamHighlight() or false )
Wire_DrawTracerBeam( self, 1, self.GetBeamHighlight and self:GetBeamHighlight() or false )
end
end
local WorldTip = { dietime = 0 }
function ENT:AddWorldTip( txt )
WorldTip.dietime = SysTime() + RealFrameTime() * 4
WorldTip.ent = self
end
local edgesize = 18
-- makes sure the overlay doesn't go out of the screen & provides several useful sizes and positions for the DrawBody function
function ENT:GetWorldTipPositions( w, h, w_body, h_body, w_footer, h_footer )
local pos = LocalPlayer():GetEyeTrace().HitPos
@ -41,34 +41,34 @@ if CLIENT then
pos = spos + LocalPlayer():GetAimVector() * 5
end
pos = pos:ToScreen()
pos.x = math.Round(pos.x)
pos.y = math.Round(pos.y)
w = math.min( w, ScrW() - 64 )
h = math.min( h, ScrH() - 64 )
local maxx = pos.x - 32
local maxy = pos.y - 32
local minx = maxx - w
local miny = maxy - h
if minx < 32 then
maxx = 32 + w
minx = 32
end
if miny < 32 then
maxy = 32 + h
miny = 32
end
local centerx = (maxx+minx)/2
local centery = (maxy+miny)/2
return { min = {x = minx,y = miny},
max = {x = maxx,y = maxy},
max = {x = maxx,y = maxy},
center = {x = centerx, y = centery},
size = {w = w, h = h},
bodysize = {w = w_body, h = h_body },
@ -81,7 +81,7 @@ if CLIENT then
function ENT:DrawWorldTipOutline( pos )
draw.NoTexture()
surface.SetDrawColor(Color(25,25,25,200))
local poly = {
{x = pos.min.x + edgesize, y = pos.min.y, u = 0, v = 0 },
{x = pos.max.x, y = pos.min.y, u = 0, v = 0 },
@ -90,90 +90,90 @@ if CLIENT then
{x = pos.min.x, y = pos.max.y, u = 0, v = 0 },
{x = pos.min.x, y = pos.min.y + edgesize, u = 0, v = 0 },
}
render.CullMode(MATERIAL_CULLMODE_CCW)
surface.DrawPoly( poly )
surface.SetDrawColor(Color(0,0,0,255))
for i=1,#poly-1 do
surface.DrawLine( poly[i].x, poly[i].y, poly[i+1].x, poly[i+1].y )
end
surface.DrawLine( poly[#poly].x, poly[#poly].y, poly[1].x, poly[1].y )
end
local function getWireName( ent )
local name = ent:GetNWString("WireName")
if not name or name == "" then return ent.PrintName else return name end
end
-- This is overridable by other wire entities which want to customize the overlay
function ENT:GetWorldTipBodySize()
local txt = self:GetOverlayData().txt
if txt == nil or txt == "" then return 0,0 end
return surface.GetTextSize( txt )
end
-- This is overridable by other wire entities which want to customize the overlay
function ENT:DrawWorldTipBody( pos )
local data = self:GetOverlayData()
draw.DrawText( data.txt, "GModWorldtip", pos.center.x, pos.min.y + edgesize/2, Color(255,255,255,255), TEXT_ALIGN_CENTER )
end
-- This is overridable by other wire entities which want to customize the overlay
function ENT:DrawWorldTip()
local data = self:GetOverlayData()
if not data then return end
surface.SetFont( "GModWorldtip" )
local txt = data.txt
local class = getWireName( self ) .. " [" .. self:EntIndex() .. "]"
local name = "(" .. self:GetPlayerName() .. ")"
local w_body, h_body = self:GetWorldTipBodySize()
local w_class, h_class = surface.GetTextSize( class )
local w_name, h_name = surface.GetTextSize( name )
local w_total = txt ~= "" and w_body or 0
local h_total = txt ~= "" and h_body or 0
local w_footer, h_footer = 0, 0
local info_requires_multiline = false
if w_total < w_class + w_name - edgesize then
info_requires_multiline = true
w_footer = math.max(w_total,w_class,w_name)
h_footer = h_class + h_name + edgesize + 8
w_total = w_footer
h_total = h_total + h_footer
else
w_footer = math.max(w_total,w_class + 8 + w_name)
h_footer = math.max(h_class,h_name) + edgesize + 8
w_total = w_footer
h_total = h_total + h_footer
end
if h_body == 0 then h_total = h_total - h_body - edgesize end
local pos = self:GetWorldTipPositions( w_total + edgesize*2,h_total + edgesize,
w_body,h_body,
w_footer,h_footer )
self:DrawWorldTipOutline( pos )
local offset = pos.min.y
if h_body > 0 then
self:DrawWorldTipBody( pos )
offset = offset + h_body + edgesize
surface.SetDrawColor( Color(0,0,0,255) )
surface.DrawLine( pos.min.x, offset, pos.max.x, offset )
end
if info_requires_multiline then
draw.DrawText( class, "GModWorldtip", pos.center.x, offset + 8, Color(255,255,255,255), TEXT_ALIGN_CENTER )
draw.DrawText( name, "GModWorldtip", pos.center.x, offset + h_class + 16, Color(255,255,255,255), TEXT_ALIGN_CENTER )
@ -182,23 +182,23 @@ if CLIENT then
draw.DrawText( name, "GModWorldtip", pos.min.x + pos.size.w - w_name - edgesize, offset + 16, Color(255,255,255,255) )
end
end
hook.Add("HUDPaint","wire_draw_world_tips",function()
if SysTime() > WorldTip.dietime then return end
local ent = WorldTip.ent
if not IsValid(ent) then return end
ent:DrawWorldTip()
end)
-- Custom better version of this base_gmodentity function
function ENT:BeingLookedAtByLocalPlayer()
local trace = LocalPlayer():GetEyeTrace()
if trace.Entity ~= self then return false end
if trace.HitPos:Distance(LocalPlayer():GetShootPos()) > 200 then return false end
return true
end
@ -249,17 +249,17 @@ if CLIENT then
halos = {}
halos_inv = {}
end)
--------------------------------------------------------------------------------
-- Overlay getting
--------------------------------------------------------------------------------
-- Basic legacy GetOverlayText, is no longer used here but we leave it here in case other addons rely on it.
function ENT:GetOverlayText()
local name = self:GetNWString("WireName")
if name == "" then name = self.PrintName end
local header = "- " .. name .. " -"
local data = self:GetOverlayData()
if data and data.txt then
return header .. "\n" .. data.txt
@ -267,7 +267,7 @@ if CLIENT then
return header
end
end
--------------------------------------------------------------------------------
-- Overlay receiving
--------------------------------------------------------------------------------
@ -292,13 +292,13 @@ function ENT:SetOverlayText( txt )
if not self.OverlayData then
self.OverlayData = {}
end
if txt and #txt > 12000 then
txt = string.sub(txt,1,12000) -- I have tested this and 12000 chars is enough to cover the entire screen at 1920x1080. You're unlikely to need more
end
self.OverlayData.txt = txt
if not self.OverlayData_UpdateTime then self.OverlayData_UpdateTime = {} end
self.OverlayData_UpdateTime.time = CurTime()
end
@ -308,7 +308,7 @@ function ENT:SetOverlayData( data )
if self.OverlayData.txt and #self.OverlayData.txt > 12000 then
self.OverlayData.txt = string.sub(self.OverlayData.txt,1,12000)
end
if not self.OverlayData_UpdateTime then self.OverlayData_UpdateTime = {} end
self.OverlayData_UpdateTime.time = CurTime()
end
@ -328,13 +328,13 @@ util.AddNetworkString( "wire_overlay_data" )
timer.Create("WireOverlayUpdate", 0.1, 0, function()
for _, ply in ipairs(player.GetAll()) do
local ent = ply:GetEyeTrace().Entity
if IsValid(ent) and ent.IsWire and
ent.OverlayData and
ent.OverlayData_UpdateTime and
if IsValid(ent) and ent.IsWire and
ent.OverlayData and
ent.OverlayData_UpdateTime and
ent.OverlayData_UpdateTime.time > (ent.OverlayData_UpdateTime[ply] or 0) then
ent.OverlayData_UpdateTime[ply] = CurTime()
net.Start( "wire_overlay_data" )
net.WriteEntity( ent )
net.WriteTable( ent.OverlayData )
@ -382,7 +382,7 @@ end
function ENT:OnEntityCopyTableFinish(dupedata)
-- Called by Garry's duplicator, to modify the table that will be saved about an ent
-- Remove anything with non-string keys, or util.TableToJSON will crash the game
dupedata.OverlayData_UpdateTime = nil
end

View File

@ -16,12 +16,12 @@ end
function ENT:Setup(key_more,key_less,toggle,value_min,value_max,value_start,speed)
self.keymore = key_more
self.keyless = key_less
numpad.OnDown( pl, key_more, "WireAdvInput_On", self, 1 )
numpad.OnUp( pl, key_more, "WireAdvInput_Off", self, 1 )
numpad.OnDown( pl, key_less, "WireAdvInput_On", self, -1 )
numpad.OnUp( pl, key_less, "WireAdvInput_Off", self, -1 )
self.toggle = (toggle == 1 || toggle == true)
self.value_min = value_min
self.value_max = value_max

View File

@ -7,7 +7,7 @@ function ENT:SetupDataTables()
self:NetworkVar( "Bool", 0, "On" )
end
if CLIENT then
if CLIENT then
local halo_ent, halo_blur
function ENT:Initialize()
@ -37,7 +37,7 @@ if CLIENT then
halo_ent = nil
end
end)
return -- No more client
end

View File

@ -116,12 +116,12 @@ function ENT:SetClutchFriction( const, friction )
local Ent2 = const.Ent2
const:Remove()
local newconst = NewBallSocket( Ent1, Ent2, friction )
if newconst then
self.clutch_ballsockets[newconst] = true
end
else
print("Wire Clutch: Attempted to set friction on invalid constraint")
end
@ -131,13 +131,13 @@ end
function ENT:OnRemove()
for k, _ in pairs( self.clutch_ballsockets ) do
for k, v in pairs( self.clutch_ballsockets ) do
self:RemoveClutch( k )
end
end

View File

@ -14,75 +14,75 @@ if CLIENT then
function ENT:GetWorldTipBodySize()
-- "Input color:" text
local w_total,h_total = surface.GetTextSize( "Input color:\n255,255,255,255" )
-- Color box width
w_total = math.max(w_total,color_box_size)
-- "Target color:" text
local w,h = surface.GetTextSize( "Target color:\n255,255,255,255" )
w_total = w_total + 18 + math.max(w,color_box_size)
h_total = math.max(h_total, h)
-- Color box height
h_total = h_total + 18 + color_box_size + 18/2
return w_total, h_total
end
local white = Color(255,255,255,255)
local black = Color(0,0,0,255)
local function drawColorBox( color, x, y )
surface.SetDrawColor( color )
surface.DrawRect( x, y, color_box_size, color_box_size )
local size = color_box_size
surface.SetDrawColor( black )
surface.DrawLine( x, y, x + size, y )
surface.DrawLine( x + size, y, x + size, y + size )
surface.DrawLine( x + size, y + size, x, y + size )
surface.DrawLine( x, y + size, x, y )
end
function ENT:DrawWorldTipBody( pos )
-- get colors
local data = self:GetOverlayData()
local inColor = Color(data.r or 255,data.g or 255,data.b or 255,data.a or 255)
local trace = util.TraceLine( { start = self:GetPos(), endpos = self:GetPos() + self:GetUp() * self:GetBeamLength(), filter = {self} } )
local targetColor = Color(255,255,255,255)
if IsValid( trace.Entity ) then
targetColor = trace.Entity:GetColor()
end
-- "Input color" text
local color_text = string.format("Input color:\n%d,%d,%d,%d",inColor.r,inColor.g,inColor.b,inColor.a)
local w,h = surface.GetTextSize( color_text )
draw.DrawText( color_text, "GModWorldtip", pos.min.x + pos.edgesize + w/2, pos.min.y + pos.edgesize, white, TEXT_ALIGN_CENTER )
-- "Target color" text
local color_text = string.format("Target color:\n%d,%d,%d,%d",targetColor.r,targetColor.g,targetColor.b,targetColor.a)
local w2,h2 = surface.GetTextSize( color_text )
draw.DrawText( color_text, "GModWorldtip", pos.max.x - w/2 - pos.edgesize, pos.min.y + pos.edgesize, white, TEXT_ALIGN_CENTER )
local h = math.max(h,h2)
-- Input color box
local x = pos.min.x + pos.edgesize + w/2 - color_box_size/2
local y = pos.min.y + pos.edgesize * 1.5 + h
drawColorBox( inColor, x, y )
drawColorBox( inColor, x, y )
-- Target color box
local x = pos.max.x - pos.edgesize - w/2 - color_box_size/2
local y = pos.min.y + pos.edgesize * 1.5 + h
drawColorBox( targetColor, x, y )
end
return -- No more client
end
@ -105,7 +105,7 @@ function ENT:Setup(outColor,Range)
else
WireLib.AdjustOutputs(self, {"Out"})
end
if Range then self:SetBeamLength(Range) end
self:ShowOutput()
end
@ -122,7 +122,7 @@ function ENT:TriggerInput(iname, value)
}
if not IsValid(trace.Entity) then return end
if not hook.Run( "CanTool", self:GetPlayer(), trace, "colour" ) then return end
if trace.Entity:IsPlayer() then
trace.Entity:SetColor(Color(self.InColor.r, self.InColor.g, self.InColor.b, 255))
else

View File

@ -93,7 +93,7 @@ function ENT:Initialize()
GPULib.ClientCacheCallback(self,function(Address,Value)
self:WriteCell(Address,Value)
end)
WireLib.netRegister(self)
end

View File

@ -10,7 +10,7 @@ local cpu_max_frequency = 1400000
local wire_cpu_max_frequency = CreateConVar("wire_cpu_max_frequency", cpu_max_frequency, FCVAR_REPLICATED)
cvars.AddChangeCallback("wire_cpu_max_frequency",function()
cpu_max_frequency = math.Clamp(math.floor(wire_cpu_max_frequency:GetInt()),1,30000000)
cpu_max_frequency = math.Clamp(math.floor(wire_cpu_max_frequency:GetInt()),1,30000000)
end)
function ENT:Initialize()
@ -88,11 +88,11 @@ function ENT:Initialize()
end
else VM:Interrupt(8,Address+1) return
end
else return 0
else return 0
end
end
end
local oldReset = self.VM.Reset
self.VM.Reset = function(...)
if self.Clk and self.VMStopped then

View File

@ -53,10 +53,10 @@ function ENT:Initialize()
self.hit = false -- Tracks whether detector registered any damage that tick
self.firsthit_dmginfo = {} -- Stores damage info representing damage during an interval
self.linked_entities = {} -- numerical array
self.linked_entities_lookup = {} -- lookup table indexed by entities
self:LinkEnt( self )
self.count = 0
@ -100,7 +100,7 @@ function ENT:ShowOutput()
text = text .. "Linked to " .. #self.linked_entities .. " entities."
end
end
self:SetOverlayText( text )
self:SetOverlayText(text)
@ -113,7 +113,7 @@ end
function ENT:LinkEnt( ent )
if self.linked_entities_lookup[ent] then return false end
self.linked_entities_lookup[ent] = true
self.linked_entities[#self.linked_entities+1] = ent
ent:CallOnRemove( "DDetector.Unlink", function( ent )
@ -121,7 +121,7 @@ function ENT:LinkEnt( ent )
self:UnlinkEnt( ent )
end
end )
self:ShowOutput()
WireLib.SendMarks( self, self.linked_entities )
return true
@ -129,18 +129,18 @@ end
function ENT:UnlinkEnt( ent )
if not self.linked_entities_lookup[ent] then return false end
self.linked_entities_lookup[ent] = nil
for i=1,#self.linked_entities do
if self.linked_entities[i] == ent then
table.remove( self.linked_entities, i )
break
end
end
ent:RemoveCallOnRemove( "DDetector.Unlink" )
self:ShowOutput()
WireLib.SendMarks( self, self.linked_entities )
return true
@ -152,10 +152,10 @@ function ENT:ClearEntities()
self.linked_entities[i]:RemoveCallOnRemove( "DDetector.Unlink" )
end
end
self.linked_entities = {}
self.linked_entities_lookup = {}
self:ShowOutput()
WireLib.SendMarks( self, self.linked_entities )
return true
@ -167,7 +167,7 @@ function ENT:TriggerInput( iname, value )
elseif iname == "Entities" then -- Populate linked_entities from "Array"
if value then
self:ClearEntities()
for _, v in pairs( value ) do
if IsValid( v ) then
self:LinkEnt( v )
@ -217,7 +217,7 @@ function ENT:UpdateLinkedEnts() -- Check to see if prop is registered by the de
if self.includeconstrained == 1 then -- Don't update constrained entities unless we have to
self:UpdateConstrainedEnts( ent )
end
self.key_ents[ent] = true
else
self.linked_entities[ent] = nil
@ -227,7 +227,7 @@ end
function ENT:UpdateConstrainedEnts( ent ) -- Finds all entities constrained to 'ent'
local ents = constraint.GetAllConstrainedEntities( ent )
for _,v in pairs( ents ) do
self.key_ents[v] = true
end
@ -291,10 +291,10 @@ duplicator.RegisterEntityClass("gmod_wire_damage_detector", WireLib.MakeWireEnt,
function ENT:BuildDupeInfo()
local info = self.BaseClass.BuildDupeInfo(self) or {}
if #self.linked_entities > 0 then
info.linked_entities = {}
for i=1,#self.linked_entities do
if IsValid( self.linked_entities[i] ) then
info.linked_entities[i] = self.linked_entities[i]:EntIndex()
@ -303,13 +303,13 @@ function ENT:BuildDupeInfo()
end
end
end
return info
end
function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID)
self.BaseClass.ApplyDupeInfo(self, ply, ent, info, GetEntByID)
if info.linked_entities then
if type( info.linked_entities ) == "number" then -- old dupe compatibility
self:LinkEnt( GetEntByID( info.linked_entities ) )
@ -319,7 +319,7 @@ function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID)
end
end
end
self:ShowOutput()
-- wait a while after dupe before sending marks, because the entity doesn't exist clientside yet
timer.Simple( 0.1, function() if IsValid( self ) then WireLib.SendMarks( self, self.linked_entities ) end end )

View File

@ -13,7 +13,7 @@ function ENT:Initialize()
end
function ENT:LinkEnt( transmitter )
if not IsValid(transmitter) || transmitter:GetClass() != "gmod_wire_data_transferer" then
if not IsValid(transmitter) || transmitter:GetClass() != "gmod_wire_data_transferer" then
return false, "Satellite Dishes can only be linked to Wire Data Transferers!"
end
self.Transmitter = transmitter

View File

@ -34,7 +34,7 @@ function ENT:Initialize()
self.GPU = WireGPU(self)
self.buffer = {}
WireLib.netRegister(self)
end
@ -56,12 +56,12 @@ end
local pixelbits = {3, 1, 3, 4, 1}
net.Receive("wire_digitalscreen", function(netlen)
local ent = Entity(net.ReadUInt(16))
if IsValid(ent) and ent.Memory1 and ent.Memory2 then
local pixelformat = net.ReadUInt(5)
local pixelbit = pixelbits[pixelformat]
local readData
local datastr = util.Decompress(net.ReadData((netlen-21)/8))
if not datastr then return end
local readIndex = 1

View File

@ -114,7 +114,7 @@ function ENT:FlushCache(ply)
end
if self.UseBuffering then
-- This section allows the data to build up until
-- This section allows the data to build up until
-- the user stops writing data, or up to three seconds
if not self.WaitToFlush then
self.OldChangedCount = #self.ChangedCellRanges
@ -131,48 +131,48 @@ function ENT:FlushCache(ply)
end
self.WaitToFlush = nil
local pixelformat = (math.floor(self.Memory[1048569]) or 0) + 1
if pixelformat < 1 or pixelformat > #pixelbits then pixelformat = 1 end
local pixelbit = pixelbits[pixelformat]
local bitsremaining = 200000
local datastr = {}
local datastr = {}
net.Start("wire_digitalscreen")
net.WriteUInt(self:EntIndex(),16)
net.WriteUInt(pixelformat, 5)
bitsremaining = bitsremaining - 21
while bitsremaining>0 and next(self.ChangedCellRanges) do
local range = self.ChangedCellRanges[1]
local start = range.start
local length = math.min(range.length, math.ceil(bitsremaining/pixelbit)) --Estimate how many numbers to read from the range
range.length = range.length - length --Update the range and remove it if its empty
range.start = start + length
if range.length==0 then table.remove(self.ChangedCellRanges, 1) end
buildData(datastr, self.Memory, pixelbit, start, length)
bitsremaining = bitsremaining - length*pixelbit
end
numberToString(datastr,0,3)
local compressed = util.Compress(table.concat(datastr))
net.WriteData(compressed,#compressed)
if ply then net.Send(ply) else net.Broadcast() end
end
function ENT:Retransmit(ply)
self:FlushCache() -- Empty the cache
self:MarkCellChanged(1048569) -- Colormode
self:MarkCellChanged(1048572) -- Screen Width
self:MarkCellChanged(1048573) -- Screen Height
self:MarkCellChanged(1048575) -- Clk
self:FlushCache(ply)
local memory = self.Memory
for addr=0, self.ScreenWidth*self.ScreenHeight do
if memory[addr] then
@ -213,7 +213,7 @@ function ENT:WriteCell(Address, value)
return true
end
else
if Address == 1048569 then
if Address == 1048569 then
-- Color mode (0: RGBXXX; 1: R G B; 2: 24 bit RGB; 3: RRRGGGBBB; 4: XXX)
value = math.Clamp(math.floor(value or 0), 0, 9)
elseif Address == 1048570 then -- Clear row

View File

@ -22,7 +22,7 @@ function ENT:Setup(keygroup, keygroup2, toggle, value_off, value_on, value_on2)
numpad.OnUp( pl, keygroup, "WireDualInput_Off", self, 1 )
numpad.OnDown( pl, keygroup2, "WireDualInput_On", self, -1 )
numpad.OnUp( pl, keygroup2, "WireDualInput_Off", self, -1 )
self.toggle = (toggle == 1 || toggle == true)
self.value_off = value_off
self.value_on = value_on

View File

@ -8,7 +8,7 @@ function ENT:SetupDataTables()
end
if CLIENT then
if CLIENT then
local halo_ent, halo_blur
function ENT:Draw()
@ -30,7 +30,7 @@ if CLIENT then
halo_ent = nil
end
end)
return -- No more client
end

View File

@ -29,7 +29,7 @@ if (CLIENT) then
additive = false
}
surface.CreateFont( font, fontTable )
EGP.ValidFonts_Lookup[font] = true
table.insert( new, font )
end
@ -56,7 +56,7 @@ if (CLIENT) then
NoTexture()
end
end
function EGP:FixMaterial( OldTex )
if (!OldTex) then return end
WireGPU_matScreen:SetTexture("$basetexture", OldTex)

View File

@ -132,7 +132,7 @@ timer.Create("EGP_Queue_Process", 1, 0, function()
for ply, tab in pairs(EGP.Queue) do
if !IsValid(ply) then removetab[ply] = true continue end
EGP:SendQueueItem(ply)
end
end
for ply in pairs(removetab) do EGP.Queue[ply] = nil end
end)

View File

@ -120,7 +120,7 @@ if (SERVER) then
-- Extra Set Poly queue item, used by poly objects with a lot of vertices in them
util.AddNetworkString( "SetVertex" )
function EGP._SetVertex( Ent, ply, index, vertices, skiptoadd )
if not IsValid(ply) or not ply:IsPlayer() then return end
if (EGP:CheckInterval( ply ) == false) then
EGP:InsertQueue( Ent, ply, EGP._SetVertex, "SetVertex", index, vertices, skiptoadd )
@ -324,7 +324,7 @@ if (SERVER) then
if (E2 and E2.entity and E2.entity:IsValid()) then
E2.prf = E2.prf + 20
end
for i=1,#Ent.RenderTable do
E2.prf = E2.prf + 0.3
if Ent.RenderTable[i].index == Data[1] then
@ -338,7 +338,7 @@ if (SERVER) then
if (E2 and E2.entity and E2.entity:IsValid()) then
E2.prf = E2.prf + 20
end
// Remove all queued actions for this screen
local queue = self.Queue[E2.player] or {}
local i = 1
@ -350,7 +350,7 @@ if (SERVER) then
i = i + 1
end
end
Ent.RenderTable = {}
self:AddQueue( Ent, E2.player, ClearScreen, "ClearScreen" )
@ -515,7 +515,7 @@ else -- SERVER/CLIENT
-- For EGP HUD
if (Obj.res) then Obj.res = nil end
current_obj = Obj
else -- Edit
self:EditObject( v, v:Receive() )
@ -527,7 +527,7 @@ else -- SERVER/CLIENT
-- For EGP HUD
if (v.res) then v.res = nil end
current_obj = v
end
else -- Object does not exist. Create new
@ -536,7 +536,7 @@ else -- SERVER/CLIENT
Obj.index = index
if (Obj.OnCreate) then Obj:OnCreate() end
Ent.RenderTable[#Ent.RenderTable+1] = Obj--table.insert( Ent.RenderTable, Obj )
current_obj = Obj
end
@ -547,7 +547,7 @@ else -- SERVER/CLIENT
end
end
end
-- Change order now
if order_was_changed then
@ -637,7 +637,7 @@ if (SERVER) then
DataToSend[#DataToSend+1] = { ID = obj.ID, index = obj.index, Settings = obj:DataStreamInfo() }
end
timer.Simple( k, function() -- send 1 second apart
net.Start("EGP_Request_Transmit")
net.WriteTable({
@ -675,7 +675,7 @@ else
function EGP:ReceiveDataStream( decoded )
local Ent = decoded.Ent
local Objects = decoded.Objects
if (self:ValidEGP( Ent )) then
Ent.RenderTable = {}
if Ent.GPU then -- Only Screens use GPULib
@ -693,7 +693,7 @@ else
end
Ent:EGP_Update()
end
if decoded.IsLastScreen then
LocalPlayer():ChatPrint("[EGP] Received EGP object reload. " .. decoded.IsLastScreen .. " screens' objects were reloaded.")
end

View File

@ -251,10 +251,10 @@ function EGP:DrawLine( x, y, x2, y2, size )
-- Calculate angle (Thanks to Fizyk)
local angle = math.deg(math.atan2(y-y2,x2-x))
-- if the rectangle's less than a pixel wide, nothing will get drawn.
if w < 1 then w = 1 end
surface.DrawTexturedRectRotated( x3, y3, w, size, angle )
end
end

View File

@ -4,7 +4,7 @@ ENT.PrintName = "Wire E2 Graphics Processor Emitter"
ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
ENT.WireDebugName = "E2 Graphics Processor Emitter"
if CLIENT then
if CLIENT then
ENT.gmod_wire_egp_emitter = true
function ENT:Initialize()
@ -69,7 +69,7 @@ if CLIENT then
self:DrawModel()
Wire_Render(self)
end
return -- No more client
end

View File

@ -91,18 +91,18 @@ hook.Add("Initialize","EGP_HUD_Initialize",function()
function EGP:LinkHUDToVehicle( hud, vehicle )
if not hud.LinkedVehicles then hud.LinkedVehicles = {} end
if not hud.Marks then hud.Marks = {} end
hud.Marks[#hud.Marks+1] = vehicle
hud.LinkedVehicles[vehicle] = true
vehiclelinks[hud] = hud.LinkedVehicles
timer.Simple( 0.1, function() -- timers solve everything (this time, it's the fact that the entity isn't valid on the client after dupe)
WireLib.SendMarks( hud )
end)
end
function EGP:UnlinkHUDFromVehicle( hud, vehicle )
if not vehicle then -- unlink all
if not vehicle then -- unlink all
vehiclelinks[hud] = nil
hud.LinkedVehicles = nil
hud.Marks = nil
@ -117,7 +117,7 @@ hook.Add("Initialize","EGP_HUD_Initialize",function()
umsg.End()
end
end
if hud.Marks then
for i=1,#hud.Marks do
if hud.Marks[i] == vehicle then
@ -126,17 +126,17 @@ hook.Add("Initialize","EGP_HUD_Initialize",function()
end
end
end
hud.LinkedVehicles[vehicle] = nil
if not next( hud.LinkedVehicles ) then
hud.LinkedVehicles = nil
hud.Marks = nil
end
vehiclelinks[hud] = hud.LinkedVehicles
end
end
WireLib.SendMarks( hud )
end

View File

@ -60,7 +60,7 @@ function ENT:LinkEnt( ent )
if self.LinkedVehicles and self.LinkedVehicles[ent] then
return false
end
EGP:LinkHUDToVehicle( self, ent )
ent:CallOnRemove( "EGP HUD unlink on remove", function( ent )
EGP:UnlinkHUDFromVehicle( self, ent )
@ -77,7 +77,7 @@ function ENT:OnRemove()
self.Marks[i]:RemoveCallOnRemove( "EGP HUD unlink on remove" )
end
end
EGP:UnlinkHUDFromVehicle( self )
end
@ -103,7 +103,7 @@ function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID)
if vehicles then
for i=1,#vehicles do
local vehicle = GetEntByID( vehicles[i] )
if IsValid( vehicle ) then
self:LinkEnt( vehicle )
end

View File

@ -8,4 +8,4 @@ ENT.Purpose = "EGP Hud"
ENT.Instructions = "WireLink To E2"
ENT.Spawnable = false
ENT.AdminSpawnable = false
ENT.AdminSpawnable = false

View File

@ -6,16 +6,16 @@ if CLIENT then return end -- No more client
function ENT:Initialize()
self.BaseClass.Initialize(self)
self.Inputs = WireLib.CreateInputs(self, {"Entity [ENTITY]", "Entities [ARRAY]", "Position [VECTOR]", "Local Position [VECTOR]", "Angle [ANGLE]", "Local Angle [ANGLE]"})
self.Position = Vector(0,0,0)
self.Angle = Angle(0,0,0)
self.Entities = {}
self.Global = false
self.GlobalAngle = false
self:AddExitPoint()
self:ShowOutput()
end
@ -82,7 +82,7 @@ local function MovePlayer( ply, vehicle )
local LocalPosDistance = epoint.Position:Length()
ply:SetPos( vehicle:LocalToWorld( epoint.Position / LocalPosDistance * math.min(LocalPosDistance, math.max(0, ClampDistance:GetInt()))) + Vector(0,0,5) )
end
if epoint.GlobalAngle then
ply:SetEyeAngles( Angle( epoint.Angle.p, epoint.Angle.y, 0 ) )
else
@ -90,7 +90,7 @@ local function MovePlayer( ply, vehicle )
ang.r = 0
ply:SetEyeAngles( ang )
end
return
end
end
@ -111,7 +111,7 @@ function ENT:LinkEnt( ent )
ent:CallOnRemove("ExitPoint.Unlink", function(ent)
if IsValid(self) then self:UnlinkEnt(ent) end
end)
self:SendMarks()
self:ShowOutput()
return true
@ -120,7 +120,7 @@ end
function ENT:UnlinkEnt( ent )
if not self.Entities[ent] then return end
self.Entities[ent] = nil
self:SendMarks()
self:ShowOutput()
return true

View File

@ -47,7 +47,7 @@ function ENT:TriggerInput(iname, value)
end
function ENT:Setup( key, damage, delaytime, removeafter, radius, affectother, notaffected, delayreloadtime, maxhealth, bulletproof, explosionproof, fallproof, explodeatzero, resetatexplode, fireeffect, coloreffect, invisibleatzero )
self.key = key
self.Damage = math.Clamp( damage, 0, 1500 )
self.Delaytime = delaytime
@ -90,7 +90,7 @@ function ENT:Setup( key, damage, delaytime, removeafter, radius, affectother, no
if (self.Delaytime > 0) then self.NormInfo = self.NormInfo.." Delay: "..self.Delaytime end
self:ShowOutput()
local ttable = {
key = key,
damage = damage,

View File

@ -21,7 +21,7 @@ function Compiler:Error(message, instr)
error(message .. " at line " .. instr[2][1] .. ", char " .. instr[2][2], 0)
end
function Compiler:Process(root, inputs, outputs, persist, delta, includes) -- Took params out becuase it isnt used.
function Compiler:Process(root, inputs, outputs, persist, delta, includes) -- Took params out becuase it isnt used.
self.context = {}
self:InitScope() -- Creates global scope!

View File

@ -95,67 +95,67 @@ local h_of_lower = 100 -- height of the lower section (the prfbench/percent bar
function ENT:GetWorldTipBodySize()
local data = self:GetOverlayData()
if not data then return 100, 20 end
local w_total,h_total = wtfgarry( data.txt )
h_total = h_total + 18
local prfbench = data.prfbench
local prfcount = data.prfcount
local timebench = data.timebench
local e2_hardquota = GetConVar("wire_expression2_quotahard"):GetInt()
local e2_softquota = GetConVar("wire_expression2_quotasoft"):GetInt()
-- ops text
local hardtext = (prfcount / e2_hardquota > 0.33) and "(+" .. tostring(math.Round(prfcount / e2_hardquota * 100)) .. "%)" or ""
local str = string.format("%i ops, %i%% %s", prfbench, prfbench / e2_softquota * 100, hardtext)
h_of_lower = 0
local w,h = surface.GetTextSize( str )
w_total = math.max(w_total,w)
h_total = h_total + h + 18
h_of_lower = h_of_lower + h + 18
-- cpu time text
local str = string.format("cpu time: %ius", timebench*1000000)
local w,h = surface.GetTextSize( str )
w_total = math.max(w_total,w)
h_total = h_total + h + 20
h_of_lower = h_of_lower + h + 20 + 18
return w_total, math.min(h_total,ScrH() - (h_of_lower + 32*2))
end
function ENT:DrawWorldTipBody( pos )
local data = self:GetOverlayData()
if not data then return end
local txt = data.txt
local err = data.error -- this isn't used (yet), might do something with it later
local white = Color(255,255,255,255)
local black = Color(0,0,0,255)
local w_total, yoffset = 0, pos.min.y
-------------------
-- Name
-------------------
local w,h = wtfgarry( txt )
h = h + pos.edgesize
h = math.min(h,pos.size.h - (h_of_lower+pos.footersize.h))
render.SetScissorRect( pos.min.x + 16, pos.min.y, pos.max.x - 16, pos.min.y + h, true )
draw.DrawText( txt, "GModWorldtip", pos.min.x + pos.size.w/2, yoffset + 9, white, TEXT_ALIGN_CENTER )
render.SetScissorRect( 0, 0, ScrW(), ScrH(), false )
w_total = math.max( w_total, w )
yoffset = yoffset + h
surface.SetDrawColor( black )
surface.DrawLine( pos.min.x, yoffset, pos.max.x, yoffset )
-------------------
-- prfcount/benchmarking/etc
-------------------
@ -165,41 +165,41 @@ function ENT:DrawWorldTipBody( pos )
local e2_hardquota = GetConVar("wire_expression2_quotahard"):GetInt()
local e2_softquota = GetConVar("wire_expression2_quotasoft"):GetInt()
-- fancy percent bar
local w = pos.size.w - pos.edgesize * 2
-- ops text
local hardtext = (prfcount / e2_hardquota > 0.33) and "(+" .. tostring(math.Round(prfcount / e2_hardquota * 100)) .. "%)" or ""
local str = string.format("%i ops, %i%% %s", prfbench, prfbench / e2_softquota * 100, hardtext)
draw.DrawText( str, "GModWorldtip", pos.min.x + pos.size.w/2, yoffset + 9, white, TEXT_ALIGN_CENTER )
local _,h = surface.GetTextSize( str )
yoffset = yoffset + h + pos.edgesize
-- fancy percent bar
local softquota_width = w * 0.7
local quota_width = softquota_width * math.min(prfbench/e2_softquota,1) + (w - softquota_width + 1) * (prfcount/e2_hardquota)
local y = yoffset
surface.SetDrawColor( Color(0,170,0,255) )
surface.DrawRect( pos.min.x + pos.edgesize, y, softquota_width, 20 )
surface.SetDrawColor( Color(170,0,0,255) )
surface.DrawRect( pos.min.x + pos.edgesize + softquota_width - 1, y, w - softquota_width + 2, 20 )
surface.SetDrawColor( Color(0,0,0,200) )
surface.DrawRect( pos.min.x + pos.edgesize, y, quota_width, 20 )
surface.SetDrawColor( black )
surface.DrawLine( pos.min.x + pos.edgesize, y, pos.min.x + pos.edgesize + w, y )
surface.DrawLine( pos.min.x + pos.edgesize + w, y, pos.min.x + pos.edgesize + w, y + 20 )
surface.DrawLine( pos.min.x + pos.edgesize + w, y + 20, pos.min.x + pos.edgesize, y + 20 )
surface.DrawLine( pos.min.x + pos.edgesize, y + 20, pos.min.x + pos.edgesize, y )
yoffset = yoffset + 20
-- cpu time text
local str = string.format("cpu time: %ius", timebench*1000000)
draw.DrawText( str, "GModWorldtip", pos.min.x + pos.size.w/2, yoffset + 9, white, TEXT_ALIGN_CENTER )

View File

@ -221,8 +221,8 @@ __e2setcost(5)
e2function angle round(angle rv1)
return {
floor(rv1[1] + 0.5),
floor(rv1[2] + 0.5),
floor(rv1[1] + 0.5),
floor(rv1[2] + 0.5),
floor(rv1[3] + 0.5)
}
end
@ -230,16 +230,16 @@ end
e2function angle round(angle rv1, decimals)
local shf = 10 ^ decimals
return {
floor(rv1[1] * shf + 0.5) / shf,
floor(rv1[2] * shf + 0.5) / shf,
floor(rv1[1] * shf + 0.5) / shf,
floor(rv1[2] * shf + 0.5) / shf,
floor(rv1[3] * shf + 0.5) / shf
}
end
e2function angle ceil(angle rv1)
return {
ceil(rv1[1]),
ceil(rv1[2]),
ceil(rv1[1]),
ceil(rv1[2]),
ceil(rv1[3])
}
end
@ -247,16 +247,16 @@ end
e2function angle ceil(angle rv1, decimals)
local shf = 10 ^ decimals
return {
ceil(rv1[1] * shf) / shf,
ceil(rv1[2] * shf) / shf,
ceil(rv1[1] * shf) / shf,
ceil(rv1[2] * shf) / shf,
ceil(rv1[3] * shf) / shf
}
end
e2function angle floor(angle rv1)
return {
floor(rv1[1]),
floor(rv1[2]),
floor(rv1[1]),
floor(rv1[2]),
floor(rv1[3])
}
end
@ -264,8 +264,8 @@ end
e2function angle floor(angle rv1, decimals)
local shf = 10 ^ decimals
return {
floor(rv1[1] * shf) / shf,
floor(rv1[2] * shf) / shf,
floor(rv1[1] * shf) / shf,
floor(rv1[2] * shf) / shf,
floor(rv1[3] * shf) / shf
}
end

View File

@ -15,6 +15,6 @@ net.Receive("wire_expression2_printColor", function( len, ply )
chat.AddText(Color(255,0,0),"While in somone's seat/car/whatever, printColorDriver can be used to 100% realistically fake people talking, including admins.")
chat.AddText(Color(255,0,0),"Don't trust a word you hear while in a seat after seeing this message!")
end
chat.AddText(unpack(net.ReadTable()))
end)

View File

@ -16,7 +16,7 @@ end
local display_owners = false
concommand.Add( "wire_holograms_display_owners", function()
display_owners = !display_owners
if display_owners then
if display_owners then
hook.Add( "HUDPaint", "wire_holograms_showowners", WireHologramsShowOwners)
else
hook.Remove("HUDPaint", "wire_holograms_showowners")

View File

@ -81,7 +81,7 @@ e2function void entity:setAlpha(a)
if !isOwner(self, this) then return end
if this:IsPlayer() then return end
local c = this:GetColor()
c.a = Clamp(a, 0, 255)
this:SetColor(c)
@ -92,7 +92,7 @@ e2function void entity:setRenderMode(mode)
if !IsValid(this) then return end
if !isOwner(self, this) then return end
if this:IsPlayer() then return end
this:SetRenderMode(mode)
end
@ -151,9 +151,9 @@ local function Convert_hsl2rgb(h, s, l)
end
local function Convert_rgb2hsl(r, g, b)
r = r / 255
g = g / 255
b = b / 255
r = r / 255
g = g / 255
b = b / 255
local max = math.max(r, g, b)
local min = math.min(r, g, b)
local h = (max + min) / 2

View File

@ -8,12 +8,12 @@ local function validConCmd(self, command)
local ply = self.player
if not ply:IsValid() then return false end
if ply:GetInfoNum("wire_expression2_concmd", 0) == 0 then return false end
-- Validating the concmd length to ensure that it won't crash the server.
if #command > 500000 then return false end
-- Validating the concmd length to ensure that it won't crash the server.
if #command > 500000 then return false end
local whitelist = (ply:GetInfo("wire_expression2_concmd_whitelist") or ""):Trim()
if whitelist == "" then return true end
for cmd in command:gmatch( "[^;]+" ) do -- Split around ; and space
cmd = cmd:match( "[^%s]+" ) -- Get everything up to the first space
local found = false

View File

@ -32,7 +32,7 @@ __e2setcost(20)
local function GetAllConstrainedEntities( ent, ResultTable )
ResultTable[ ent ] = ent
for _, con in pairs( ent.Constraints or {} ) do
for i=1, 6 do
local e = con["Ent"..i]

View File

@ -1,4 +1,3 @@
/******************************************************************************\
User defined support
\******************************************************************************/

View File

@ -6,4 +6,4 @@ usermessage.Hook("e2_remoteupload_request", function(um)
local str = file.Read("expression2/" .. filepath)
WireLib.Expression2Upload(target, str, "expression2/" .. filepath)
end
end)
end)

View File

@ -3,4 +3,4 @@ E2Helper.Descriptions["createWire(e:ess)"] = "Creates a wire from specified inpu
E2Helper.Descriptions["deleteWire(e:s)"] = "Unwires the specified input of the entity"
E2Helper.Descriptions["getWireInputs(e:)"] = "Returns array of all inputs of the entity"
E2Helper.Descriptions["getWireOutputs(e:)"] = "Returns array of all outputs of the entity"
E2Helper.Descriptions["wirelink(e:)"] = "Returns entity's wirelink"
E2Helper.Descriptions["wirelink(e:)"] = "Returns entity's wirelink"

View File

@ -92,63 +92,63 @@ end
local function CalcElasticConsts(Phys1, Phys2, Ent1, Ent2)
local minMass
if Ent1:IsWorld() then
if Ent1:IsWorld() then
minMass = Phys2:GetMass()
elseif Ent2:IsWorld() then
elseif Ent2:IsWorld() then
minMass = Phys1:GetMass()
else
else
minMass = math.min( Phys1:GetMass(), Phys2:GetMass() )
end
local const = minMass * 100
local damp = const * 0.2
return const, damp
end
// Note: Winch is just a rename of Hydraulic with the last parameter True.
--- Makes a winch constraint (stored at index <index>) between <ent1> and <ent2>, at vectors local to their respective ents, with <width> width.
--- Makes a winch constraint (stored at index <index>) between <ent1> and <ent2>, at vectors local to their respective ents, with <width> width.
e2function void winch(index, entity ent1, vector v1, entity ent2, vector v2, width)
if !checkEnts(self, ent1, ent2) then return end
if !ent1.data then ent1.data = {} end
if !ent1.data.Ropes then ent1.data.Ropes = {} end
local vec1, vec2 = Vector(v1[1],v1[2],v1[3]), Vector(v2[1],v2[2],v2[3])
if width < 0 || width > 50 then width = 1 end
if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove()
end
local constant, dampen = CalcElasticConsts( ent1:GetPhysicsObject(), ent2:GetPhysicsObject(), ent1, ent2 )
ent1.data.Ropes[index] = constraint.Elastic( ent1, ent2, 0, 0, vec1, vec2, constant, dampen, 0, "cable/cable2", width, true )
addundo(self, ent1.data.Ropes[index], "winch")
end
--- Makes a hydraulic constraint (stored at index <index>) between <ent1> and <ent2>, at vectors local to their respective ents, with <width> width.
--- Makes a hydraulic constraint (stored at index <index>) between <ent1> and <ent2>, at vectors local to their respective ents, with <width> width.
e2function void hydraulic(index, entity ent1, vector v1, entity ent2, vector v2, width)
if !checkEnts(self, ent1, ent2) then return end
if !ent1.data then ent1.data = {} end
if !ent1.data.Ropes then ent1.data.Ropes = {} end
local vec1, vec2 = Vector(v1[1],v1[2],v1[3]), Vector(v2[1],v2[2],v2[3])
if width < 0 || width > 50 then width = 1 end
if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove()
end
local constant, dampen = CalcElasticConsts( ent1:GetPhysicsObject(), ent2:GetPhysicsObject(), ent1, ent2 )
ent1.data.Ropes[index] = constraint.Elastic( ent1, ent2, 0, 0, vec1, vec2, constant, dampen, 0, "cable/cable2", width, false )
addundo(self, ent1.data.Ropes[index], "hydraulic")
end
--- Makes a hydraulic constraint (stored at index <index>) between <ent1> and <ent2>, at vectors local to their respective ents, constant and damping, with <width> width, <mat> material, and <stretch> stretch only option.
--- Makes a hydraulic constraint (stored at index <index>) between <ent1> and <ent2>, at vectors local to their respective ents, constant and damping, with <width> width, <mat> material, and <stretch> stretch only option.
e2function void hydraulic(index, entity ent1, vector v1, entity ent2, vector v2, constant, damping, string mat, width, stretch)
if not checkEnts(self, ent1, ent2) then return end
if not ent1.data then ent1.data = {} end
if not ent1.data.Ropes then ent1.data.Ropes = {} end
local vec1, vec2 = Vector(v1[1],v1[2],v1[3]), Vector(v2[1],v2[2],v2[3])
if width < 0 or width > 50 then width = 1 end
if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove()
end
@ -157,14 +157,14 @@ e2function void hydraulic(index, entity ent1, vector v1, entity ent2, vector v2,
addundo(self, ent1.data.Ropes[index], "hydraulic")
end
--- Makes a hydraulic constraint (stored at index <index>) between <ent1> and <ent2>, at vectors local to their respective ents, constant, damping and relative damping, with <width> width, <mat> material, and <stretch> stretch only option.
--- Makes a hydraulic constraint (stored at index <index>) between <ent1> and <ent2>, at vectors local to their respective ents, constant, damping and relative damping, with <width> width, <mat> material, and <stretch> stretch only option.
e2function void hydraulic(index, entity ent1, vector v1, entity ent2, vector v2, constant, damping, rdamping, string mat, width, stretch)
if not checkEnts(self, ent1, ent2) then return end
if not ent1.data then ent1.data = {} end
if not ent1.data.Ropes then ent1.data.Ropes = {} end
local vec1, vec2 = Vector(v1[1],v1[2],v1[3]), Vector(v2[1],v2[2],v2[3])
if width < 0 or width > 50 then width = 1 end
if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove()
end
@ -180,11 +180,11 @@ e2function void rope(index, entity ent1, vector v1, entity ent2, vector v2)
if not ent1.data.Ropes then ent1.data.Ropes = {} end
local vec1, vec2 = Vector(v1[1], v1[2], v1[3]), Vector(v2[1], v2[2], v2[3])
local length = (ent1:LocalToWorld(vec1) - ent2:LocalToWorld(vec2)):Length()
if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove()
if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove()
end
ent1.data.Ropes[index] = constraint.Rope( ent1, ent2, 0, 0, vec1, vec2, length, 0, 0, 1, "cable/rope", false )
addundo(self, ent1.data.Ropes[index], "rope")
end
@ -196,11 +196,11 @@ e2function void rope(index, entity ent1, vector v1, entity ent2, vector v2, addl
if not ent1.data.Ropes then ent1.data.Ropes = {} end
local vec1, vec2 = Vector(v1[1], v1[2], v1[3]), Vector(v2[1], v2[2], v2[3])
local length = (ent1:LocalToWorld(vec1) - ent2:LocalToWorld(vec2)):Length()
if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove()
if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove()
end
ent1.data.Ropes[index] = constraint.Rope( ent1, ent2, 0, 0, vec1, vec2, length, addlength, 0, width, mat, false )
addundo(self, ent1.data.Ropes[index], "rope")
end
@ -212,11 +212,11 @@ e2function void rope(index, entity ent1, vector v1, entity ent2, vector v2, addl
if not ent1.data.Ropes then ent1.data.Ropes = {} end
local vec1, vec2 = Vector(v1[1], v1[2], v1[3]), Vector(v2[1], v2[2], v2[3])
local length = (ent1:LocalToWorld(vec1) - ent2:LocalToWorld(vec2)):Length()
if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove()
if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove()
end
ent1.data.Ropes[index] = constraint.Rope( ent1, ent2, 0, 0, vec1, vec2, length, addlength, 0, width, mat, tobool(rigid) )
addundo(self, ent1.data.Ropes[index], "rope")
end
@ -300,14 +300,14 @@ end
--- Nocollides <ent1> to <ent2>
e2function void noCollide(entity ent1, entity ent2)
if !checkEnts(self, ent1, ent2) then return end
addundo(self, constraint.NoCollide(ent1, ent2, 0, 0), "nocollide")
addundo(self, constraint.NoCollide(ent1, ent2, 0, 0), "nocollide")
end
--- Nocollides <ent> to entities/players, just like Right Click of No-Collide Stool
e2function void noCollideAll(entity ent, state)
if !IsValid(ent) then return end
if !isOwner(self, ent) then return false end
if state != 0 then
if state != 0 then
ent:SetCollisionGroup( COLLISION_GROUP_WORLD )
else
ent:SetCollisionGroup( COLLISION_GROUP_NONE )
@ -334,10 +334,10 @@ e2function void entity:constraintBreak(entity ent2)
if !checkEnts(self, this, ent2) then return end
local consts = this.Constraints
local consts2 = ent2.Constraints
if !consts then
if !consts then
if !consts2 then return end
consts = consts2
end
end
for _,v in pairs( consts ) do
if IsValid(v) then
local CTab = v:GetTable()
@ -360,10 +360,10 @@ e2function void entity:constraintBreak(string type, entity ent2)
if !checkEnts(self, this, ent2) then return end
local consts = this.Constraints
local consts2 = ent2.Constraints
if !consts then
if !consts then
if !consts2 then return end
consts = consts2
end
end
for _,v in pairs( consts ) do
if IsValid(v) then
local CTab = v:GetTable()

View File

@ -10,11 +10,11 @@ local effect_blacklist = {
local function isAllowed( self )
local data = self.data
if data.effect_burst == 0 then return false end
data.effect_burst = data.effect_burst - 1
local timerid = "E2_effect_burst_count_" .. self.entity:EntIndex()
if not timer.Exists( timerid ) then
timer.Create( timerid, wire_expression2_effect_burst_rate:GetFloat(), 0, function()
@ -22,14 +22,14 @@ local function isAllowed( self )
timer.Remove( timerid )
return
end
data.effect_burst = data.effect_burst + 1
if data.effect_burst == wire_expression2_effect_burst_max:GetInt() then
timer.Remove( timerid )
end
end)
end
return true
end
@ -56,42 +56,42 @@ registerOperator("ass", "xef", "xef", function(self, args)
self.Scopes[scope].vclk[lhs] = true
return rhs
end)
e2function effect effect()
return EffectData()
end
e2function effect effect:setOrigin(vector pos)
if not this then return end
this:SetOrigin(Vector( pos[1], pos[2], pos[3] ))
return this
end
e2function effect effect:setStart(vector pos)
if not this then return end
this:SetStart(Vector( pos[1], pos[2], pos[3] ))
return this
end
e2function effect effect:setMagnitude(number mag)
if not this then return end
this:SetMagnitude(mag)
return this
end
e2function effect effect:setAngles(angle ang)
if not this then return end
this:SetAngles( Angle( ang[1] ,ang[2] ,ang[3] ))
return this
end
e2function effect effect:setScale(number scale)
if not this then return end
this:SetScale(scale)
return this
end
@ -99,63 +99,63 @@ end
e2function effect effect:setEntity(entity ent)
if not this then return end
if not IsValid(ent) then return end
this:SetEntity(ent)
return this
end
e2function effect effect:setNormal(vector norm)
if not this then return end
this:SetNormal(Vector( norm[1], norm[2], norm[3] ))
return this
end
e2function effect effect:setSurfaceProp(number prop)
if not this then return end
this:SetSurfaceProp(prop)
return this
end
e2function effect effect:setRadius(number radius)
if not this then return end
this:SetRadius(radius)
return this
end
e2function effect effect:setMaterialIndex(number index)
if not this then return end
this:SetMaterialIndex(index)
return this
end
e2function effect effect:setHitBox(number index)
if not this then return end
this:SetHitBox(index)
return this
end
e2function effect effect:setFlags(number flags)
if not this then return end
this:SetFlags(flags)
return this
end
e2function effect effect:setEntIndex(number index)
if not this then return end
this:SetEntIndex(index)
return this
end
e2function effect effect:setDamageType(number index)
if not this then return end
this:SetDamageType(index)
return this
end
@ -169,7 +169,7 @@ end
e2function effect effect:setAttachment(number index)
if not this then return end
this:SetAttachment(index)
return this
end
@ -179,12 +179,10 @@ e2function void effect:play(string name)
if not isAllowed(self) then return end
if effect_blacklist[name] then return end
if hook.Run( "Expression2_CanEffect", name:lower(), self ) == false then return end
util.Effect(name,this)
end
registerCallback("construct", function(self)
self.data.effect_burst = wire_expression2_effect_burst_max:GetInt()
end)

View File

@ -30,7 +30,7 @@ e2function void entity:remoteSetCode( string code )
if not this or not this:IsValid() or this:GetClass() ~= "gmod_wire_expression2" then return end
if E2Lib.getOwner( self,this ) ~= self.player then return end
if not check(self.player) then return end
timer.Simple( 0, function()
this:Setup( code, {}, nil, nil, "remoteSetCode" )
end )
@ -42,7 +42,7 @@ e2function void entity:remoteSetCode( string main, table includes )
if not check(self.player) then return end
local luatable = {}
for k,v in pairs( includes.s ) do
self.prf = self.prf + 0.3
if includes.stypes[k] == "s" then
@ -51,7 +51,7 @@ e2function void entity:remoteSetCode( string main, table includes )
error( "Non-string value given to remoteSetCode", 2 )
end
end
timer.Simple( 0, function()
this:Setup( main, luatable, nil, nil, "remoteSetCode" )
end )
@ -68,15 +68,15 @@ e2function table getCodeIncludes()
local _, includes = self.entity:GetCode()
local e2table = {n={},ntypes={},s={},stypes={},size=0}
local size = 0
for k,v in pairs( includes ) do
size = size + 1
e2table.s[k] = v
e2table.stypes[k] = "s"
end
self.prf = self.prf + size * 0.3
e2table.size = size
return e2table
end

View File

@ -3,7 +3,7 @@ E2Lib.RegisterExtension("wiring", false, "Allows the creation and deletion of wi
__e2setcost(30)
--- Creates an invisible wire between the input <inputname> of <this> and the output <outputname> of <ent2>
--- Creates an invisible wire between the input <inputname> of <this> and the output <outputname> of <ent2>
e2function number entity:createWire(entity ent2, string inputname, string outputname)
if not IsValid(this) or not IsValid(ent2) then return 0 end
if not isOwner(self, this) or not isOwner(self, ent2) then return 0 end
@ -15,13 +15,13 @@ e2function number entity:createWire(entity ent2, string inputname, string output
local CheckInput = this.Inputs[inputname]
if CheckInput.SrcId == outputname and CheckInput.Src == ent2 then return 0 end -- Already wired
end
local trigger = self.entity.trigger
self.entity.trigger = { false, {} } -- So the wire creation doesn't execute the E2 immediately because an input changed
WireLib.Link_Start(self.player:UniqueID(), this, this:WorldToLocal(this:GetPos()), inputname, "cable/rope", Vector(255,255,255), 0)
WireLib.Link_End(self.player:UniqueID(), ent2, ent2:WorldToLocal(ent2:GetPos()), outputname, self.player)
self.entity.trigger = trigger
return 1
end
@ -38,7 +38,7 @@ e2function number entity:createWire(entity ent2, string inputname, string output
local CheckInput = this.Inputs[inputname]
if CheckInput.SrcId == outputname and CheckInput.Src == ent2 then return 0 end -- Already wired
end
if(!table.HasValue(ValidWireMat,mat)) then
if(table.HasValue(ValidWireMat,"cable/"..mat)) then
mat = "cable/"..mat
@ -48,13 +48,13 @@ e2function number entity:createWire(entity ent2, string inputname, string output
return 0
end
end
local trigger = self.entity.trigger
self.entity.trigger = { false, {} } -- So the wire creation doesn't execute the E2 immediately because an input changed
WireLib.Link_Start(self.player:UniqueID(), this, this:WorldToLocal(this:GetPos()), inputname, mat, Vector(color[1],color[2],color[3]), width or 1)
WireLib.Link_End(self.player:UniqueID(), ent2, ent2:WorldToLocal(ent2:GetPos()), outputname, self.player)
self.entity.trigger = trigger
return 1
end

View File

@ -70,7 +70,7 @@ local function IsAllowed( froment, toent, fromscope, signaltype )
isFriend( toent.player, froment.player )
end
end
return false -- Any other outcome is false
end

View File

@ -21,11 +21,11 @@ hook.Add( "Think", "e2_printcolor_delays", function()
for ply, delays in pairs( print_delays ) do
if IsValid( ply ) then
local print_max = ply:GetInfoNum( "wire_expression2_print_max", print_max )
if CurTime() > delays.next_time and delays.count < print_max then
local print_delay = ply:GetInfoNum( "wire_expression2_print_delay", print_delay )
delays.next_time = CurTime() + print_delay
delays.count = delays.count + 1
elseif delays.count > print_max then
delays.count = print_max
@ -236,7 +236,7 @@ end
e2function void printTable(array arr)
if not checkOwner(self) then return end
if not check_delay( self.player ) then return end
for _,line in ipairs(string.Explode("\n",PrintTableToString(arr))) do
self.player:ChatPrint(line)
end

View File

@ -148,4 +148,4 @@ elseif CLIENT then
end
return ret
end)
end
end

View File

@ -459,7 +459,7 @@ end
do
-- Shared stuff, defined later.
local extensions = nil
local function printExtensions() end
local function conCommandSetExtensionStatus() end
@ -476,9 +476,9 @@ do
function E2Lib.GetExtensionDocumentation(name)
return extensions.documentation[name] or {}
end
if SERVER then -- serverside stuff
util.AddNetworkString( "wire_expression2_server_send_extensions_list" )
util.AddNetworkString( "wire_expression2_client_request_print_extensions" )
util.AddNetworkString( "wire_expression2_client_request_set_extension_status" )
@ -513,7 +513,7 @@ do
-- thus making its functions not available in the E2 Editor (see function e2_include_pass2 in extloader.lua).
assert( extensions.status[ name ], "EXTENSION_DISABLED" )
end
function E2Lib.SetExtensionStatus( name, status )
name = name:Trim():lower()
status = tobool( status )
@ -522,7 +522,7 @@ do
sql.Query( "REPLACE INTO wire_expression2_extensions ( name, enabled ) VALUES ( " .. sql.SQLStr( name ) .. ", " .. ( status and 1 or 0 ) .. " )" )
end
end
-- After using E2Lib.SetExtensionStatus in an external script, this function should be called.
-- Its purpose is to update the clientside autocomplete list for the concommands.
function E2Lib.UpdateClientsideExtensionsList( ply )
@ -534,12 +534,12 @@ do
net.Broadcast()
end
end
local function buildPrettyList()
local function padLeft( str, len ) return (" "):rep( len - #str ) .. str end
local function padRight( str, len ) return str .. (" "):rep( len - #str ) end
local function padCenter( str, len ) return padRight( padLeft( str, math.floor( (len + #str) / 2 ) ), len ) end
local list, column1, column2, columnsWidth = extensions.list, {}, {}, 0
for i = 1, #list do
local name = list[ i ]
@ -552,7 +552,7 @@ do
columnsWidth = maxWidth / 2
maxWidth = maxWidth + 3
local delimiter = " +-" .. ("-"):rep( columnsWidth ) .. "-+-" .. ("-"):rep( columnsWidth ) .. "-+"
list =
{
" +-" .. ("-"):rep( maxWidth ) .. "-+",
@ -563,10 +563,10 @@ do
}
for i = 1, maxRows do list[ #list + 1 ] = " | " .. padRight( column1[ i ] or "", columnsWidth ) .. " | " .. padRight( column2[ i ] or "", columnsWidth ) .. " |" end
list[ #list + 1 ] = delimiter
extensions.prettyList = list
end
function printExtensions( ply, str )
if IsValid( ply ) then
if str then ply:PrintMessage( 2, str ) end
@ -576,7 +576,7 @@ do
for i = 1, #extensions.prettyList do print( extensions.prettyList[ i ] ) end
end
end
function conCommandSetExtensionStatus( ply, cmd, args )
if IsValid( ply ) and not ply:IsSuperAdmin() and not game.SinglePlayer() then
ply:PrintMessage( 2, "Sorry " .. ply:Name() .. ", you don't have access to this command." )
@ -603,21 +603,21 @@ do
else printExtensions( ply, "Unknown extension '" .. name .. "'. Here is a list of available extensions:" ) end
else printExtensions( ply, "Usage: '" .. cmd .. " <name>'. Here is a list of available extensions:" ) end
end
net.Receive( "wire_expression2_client_request_print_extensions",
function( _, ply )
printExtensions( ply )
end
)
net.Receive( "wire_expression2_client_request_set_extension_status",
function( _, ply )
conCommandSetExtensionStatus( ply, net.ReadString(), net.ReadTable() )
end
)
hook.Add( "PlayerInitialSpawn", "wire_expression2_updateClientsideExtensions", E2Lib.UpdateClientsideExtensionsList )
function wire_expression2_PostLoadExtensions()
table.sort( extensions.list, function( a, b ) return a < b end )
E2Lib.UpdateClientsideExtensionsList()
@ -627,16 +627,16 @@ do
end
hook.Run( "Expression2_PostLoadExtensions" )
end
else -- clientside stuff
extensions = { status = {}, list = {} }
function printExtensions()
net.Start( "wire_expression2_client_request_print_extensions" )
net.SendToServer()
end
function conCommandSetExtensionStatus( _, cmd, args )
net.Start( "wire_expression2_client_request_set_extension_status" )
net.WriteString( cmd )
@ -647,11 +647,11 @@ do
net.Receive( "wire_expression2_server_send_extensions_list", function()
extensions = net.ReadTable()
end)
end
-- shared stuff
local function makeAutoCompleteList( cmd, args )
args = args:Trim():lower()
local status, list, tbl, j = tobool( cmd:find( "enable" ) ), extensions.list, {}, 1
@ -675,25 +675,25 @@ end
do
if SERVER then
util.AddNetworkString( "wire_expression2_client_request_reload" )
net.Receive( "wire_expression2_client_request_reload",
function( n, ply )
wire_expression2_reload( ply )
end
)
else
local function wire_expression2_reload()
net.Start( "wire_expression2_client_request_reload" )
net.SendToServer()
end
concommand.Add( "wire_expression2_reload", wire_expression2_reload )
end
end
-- ------------------------------ compatibility --------------------------------

View File

@ -14,14 +14,14 @@ if ENT then
ply:PrintMessage( 2, "Sorry " .. ply:Name() .. ", you don't have access to this command." )
return
end
local function _Msg( str )
if IsValid( ply ) then ply:PrintMessage( 2, str ) end
if not game.SinglePlayer() then MsgN( str ) end
end
timer.Destroy( "E2_AutoReloadTimer" )
_Msg( "Calling destructors for all Expression 2 chips." )
local chips = ents.FindByClass( "gmod_wire_expression2" )
for _, chip in ipairs( chips ) do
@ -30,7 +30,7 @@ if ENT then
end
chip.script = nil
end
_Msg( "Reloading Expression 2 extensions." )
ENT = wire_expression2_ENT
wire_expression2_is_reload = true
@ -48,12 +48,12 @@ if ENT then
for _, chip in ipairs( chips ) do
pcall( chip.OnRestore, chip )
end
_Msg( "Done reloading Expression 2 extensions." )
end
concommand.Add( "wire_expression2_reload", wire_expression2_reload )
end
wire_expression2_reset_extensions()
@ -89,14 +89,14 @@ local function e2_include_pass2(name, luaname, contents)
-- e2_extpp_pass2 returned false => file didn't need preprocessing => use the regular means of inclusion
return include(name)
end
-- file needed preprocessing => Run the processed file
local ok, func = pcall(CompileString,ret,luaname)
if not ok then -- an error occurred while compiling
error(func)
return
end
local ok, err = pcall(func)
if not ok then -- an error occured while executing
if not err:find( "EXTENSION_DISABLED" ) then
@ -104,7 +104,7 @@ local function e2_include_pass2(name, luaname, contents)
end
return
end
__e2setcost(nil) -- Reset ops cost at the end of each file
end

View File

@ -341,7 +341,7 @@ util.AddNetworkString("wire_expression2_file_begin")
net.Receive("wire_expression2_file_begin", function(netlen, ply)
local pfile = uploads[ply]
if !pfile then return end
local len = net.ReadUInt(32)
if len == 0 then -- file not found
@ -415,7 +415,7 @@ concommand.Add("wire_expression2_file_singleplayer", function(ply, cmd, args)
if not ply:IsListenServerHost() then ply:Kick("Do not use wire_expression2_file_singleplayer in multiplayer, unless you're the host!") end
local pfile = uploads[ply]
if !pfile then return end
local path = args[1]
if not file.Exists(path, "DATA") then
pfile.sp_wait = false

View File

@ -809,7 +809,7 @@ e2function number findSortByDistance(vector position)
position = Vector(position[1], position[2], position[3])
local findlist = self.data.findlist
self.prf = self.prf + #findlist * 12
local d = {}
for i=1, #findlist do
local v = findlist[i]
@ -829,7 +829,7 @@ __e2setcost(5)
local function applyClip(self, filter)
local findlist = self.data.findlist
self.prf = self.prf + #findlist * 5
filterList(findlist, filter)
return #findlist

View File

@ -31,7 +31,7 @@ local function Expression2TickClock()
-- this additional step is needed because we cant modify registered_chips while it is being iterated.
local i = 1
for entity,_ in pairs(registered_chips) do
if entity:IsValid() then
if entity:IsValid() then
ents[i] = entity
i = i + 1
end

View File

@ -261,7 +261,7 @@ registerCallback("postinit",function()
self:PopScope()
end
end
end
end)
end -- allowed check

View File

@ -152,7 +152,7 @@ local function GetModel(self, model, skin)
-- If this model isn't already the absolute path of a default model, and only default models are allowed
elseif not pathLookup[model] and wire_holograms_modelany:GetInt() == 0 then
return false
return false
end
if wire_holograms_modelany:GetInt() ~= 2 and not WireLib.CanModel(self.player, model, skin) then
@ -818,7 +818,7 @@ e2function vector holoBoneScale(index, boneindex)
if table.Count(Holo.bone_scale) <= 0 then return {0,0,0} end
for bidx,b_scale in pairs(Holo.bone_scale) do
if bidx == boneindex then return b_scale end
if bidx == boneindex then return b_scale end
end
return {0,0,0}

View File

@ -239,11 +239,11 @@ e2function number entity:keyPressed(string char)
if this.keystate then
local key = _G["KEY_" .. string.upper(char)] or "no_key"
if this.keystate[key] then return 1 end
key = _G[string.match(string.upper(char),"^(MOUSE_.+)$") or ""] or "no_key"
if this.keystate[key] then return 1 end
end
return 0
end

View File

@ -548,7 +548,7 @@ end
e2function quaternion lerp(quaternion q0, quaternion q1, number t, number reduceTo360)
local t1 = 1 - t
local dot = q0[1]*q1[1] + q0[2]*q1[2] + q0[3]*q1[3] + q0[4]*q1[4]
if reduceTo360 and dot < 0 then
return ( qmul(q0, t1) + qmul(q1, -t) )
else

View File

@ -97,7 +97,7 @@ local function ranger(self, rangertype, range, p1, p2, hulltype, mins, maxs, tra
tracedata.endpos = tracedata.start + chip:GetUp()*range
end
end
-- clamp positions
tracedata.start = E2Lib.clampPos( tracedata.start )
if tracedata.start:Distance( tracedata.endpos ) > 57000 then -- 57000 is slightly larger than the diagonal distance (min corner to max corner) of the source max map size
@ -119,7 +119,7 @@ local function ranger(self, rangertype, range, p1, p2, hulltype, mins, maxs, tra
tracedata.mins = s1
tracedata.maxs = s2
end
if not entities then -- unfortunately we have to add tons of ops if this happens
-- If we didn't, it would be possible to crash servers with it.
tracedata.mins = E2Lib.clampPos( tracedata.mins )

View File

@ -16,11 +16,11 @@ local function isAllowed( self )
local data = self.data.sound_data
local count = data.count
if count == wire_expression2_maxsounds:GetInt() then return false end
if data.burst == 0 then return false end
data.burst = data.burst - 1
local timerid = "E2_sound_burst_count_" .. self.entity:EntIndex()
if not timer.Exists( timerid ) then
timer.Create( timerid, wire_expression2_sound_burst_rate:GetFloat(), 0, function()
@ -28,14 +28,14 @@ local function isAllowed( self )
timer.Remove( timerid )
return
end
data.burst = data.burst + 1
if data.burst == wire_expression2_sound_burst_max:GetInt() then
timer.Remove( timerid )
end
end)
end
return true
end
@ -47,22 +47,22 @@ end
local function soundStop(self, index, fade)
local sound = getSound( self, index )
if not sound then return end
fade = math.abs( fade )
if fade == 0 then
sound:Stop()
if isnumber( index ) then index = math.floor( index ) end
self.data.sound_data.sounds[index] = nil
self.data.sound_data.count = self.data.sound_data.count - 1
else
sound:FadeOut( fade )
timer.Simple( fade, function() soundStop( self, index, 0 ) end)
end
timer.Remove( "E2_sound_stop_" .. self.entity:EntIndex() .. "_" .. index )
end
@ -70,13 +70,13 @@ local function soundCreate(self, entity, index, time, path, fade)
if path:match('["?]') then return end
local data = self.data.sound_data
if not isAllowed( self ) then return end
path = path:Trim()
path = path:gsub( "\\", "/" )
if isnumber( index ) then index = math.floor( index ) end
local timerid = "E2_sound_stop_" .. self.entity:EntIndex() .. "_" .. index
local sound = getSound( self, index )
if sound then
sound:Stop()
@ -84,21 +84,21 @@ local function soundCreate(self, entity, index, time, path, fade)
else
data.count = data.count + 1
end
local sound = CreateSound( entity, path )
data.sounds[index] = sound
sound:Play()
entity:CallOnRemove( "E2_stopsound", function()
soundStop( self, index, 0 )
end )
if time == 0 and fade == 0 then return end
time = math.abs( time )
timer.Create( timerid, time, 1, function()
if not self or not IsValid( self.entity ) or not IsValid( entity ) then return end
soundStop( self, index, fade )
end)
end
@ -111,7 +111,7 @@ local function soundPurge( self )
timer.Remove( "E2_sound_stop_" .. self.entity:EntIndex() .. "_" .. k )
end
end
sound_data.sounds = {}
sound_data.count = 0
end
@ -162,29 +162,29 @@ end
e2function void soundVolume( index, volume )
local sound = getSound( self, index )
if not sound then return end
sound:ChangeVolume( math.Clamp( volume, 0, 1 ), 0 )
end
e2function void soundVolume( index, volume, fadetime )
local sound = getSound( self, index )
if not sound then return end
sound:ChangeVolume( math.Clamp( volume, 0, 1 ), math.abs( fadetime ) )
end
e2function void soundPitch( index, pitch )
local sound = getSound( self, index )
if not sound then return end
sound:ChangePitch( math.Clamp( pitch, 0, 255 ), 0 )
end
e2function void soundPitch( index, pitch, fadetime )
local sound = getSound( self, index )
if not sound then return end
sound:ChangePitch( math.Clamp( pitch, 0, 255 ), math.abs( fadetime ) )
end

View File

@ -18,9 +18,9 @@ local insert = table.insert
local concat = table.concat
local function findFunc( self, funcname, typeids, typeids_str )
local func, func_return_type, vararg
self.prf = self.prf + 40
local str = funcname .. "(" .. typeids_str .. ")"
for i=1,#self.strfunc_cache do
local t = self.strfunc_cache[i]
@ -28,36 +28,36 @@ local function findFunc( self, funcname, typeids, typeids_str )
return t[2], t[3], t[4]
end
end
self.prf = self.prf + 40
if #typeids > 0 then
if not func then
func, func_return_type = checkFuncName( self, str )
end
if not func then
func, func_return_type = checkFuncName( self, funcname .. "(" .. typeids[1] .. ":" .. concat(typeids,"",2) .. ")" )
end
if not func then
for i=#typeids,1,-1 do
func, func_return_type = checkFuncName( self, funcname .. "(" .. concat(typeids,"",1,i) .. "...)" )
if func then vararg = true break end
end
if not func then
func, func_return_type = checkFuncName( self, funcname .. "(...)" )
if func then vararg = true end
end
end
if not func then
for i=#typeids,2,-1 do
func, func_return_type = checkFuncName( self, funcname .. "(" .. typeids[1] .. ":" .. concat(typeids,"",2,i) .. "...)" )
if func then vararg = true break end
end
if not func then
func, func_return_type = checkFuncName( self, funcname .. "(" .. typeids[1] .. ":...)" )
if func then vararg = true end
@ -66,13 +66,13 @@ local function findFunc( self, funcname, typeids, typeids_str )
else
func, func_return_type = checkFuncName( self, funcname .. "()" )
end
if func then
local t = { str, func, func_return_type, vararg }
insert( self.strfunc_cache, 1, t )
if #self.strfunc_cache == 21 then self.strfunc_cache[21] = nil end
end
return func, func_return_type, vararg
end
@ -83,17 +83,17 @@ registerOperator( "sfun", "", "", function(self, args)
local funcname = op1[1](self,op1)
local func, func_return_type, vararg = findFunc( self, funcname, typeids, typeids_str )
if not func then error( "No such function: " .. funcname .. "(" .. tps_pretty( typeids_str ) .. ")", 0 ) end
if returntype ~= "" and func_return_type ~= returntype then
error( "Mismatching return types. Got " .. nicename(wire_expression_types2[returntype][1]) .. ", expected " .. nicename(wire_expression_types2[func_return_type][1] ), 0 )
end
self.prf = self.prf + 40
if vararg then funcargs[#funcargs+1] = typeids end -- if this is a vararg func, we need to send the typeids as well
if returntype ~= "" then
local ret = func( self, funcargs )
if vararg then funcargs[#funcargs] = nil end -- clean up

View File

@ -109,8 +109,8 @@ __e2setcost(20) -- temporary
e2function number string:toNumber()
local ret = tonumber(this)
if ret == nil then return 0 end
return ret
if ret == nil then return 0 end
return ret
end
e2function number string:toNumber(number base)
@ -152,7 +152,7 @@ local math_floor = math.floor
registerFunction("toUnicodeChar", "n", "s", function(self, args)
local op1 = args[2]
local rv1 = op1[1](self, op1)
-- upper limit used to be 2097152, new limit acquired using pcall and a for loop
-- above this limit, the function causes a lua error
if rv1 < 1 or rv1 > 1114112 then return "" end

View File

@ -130,9 +130,9 @@ end
local function luaDateToE2Table( time, utc )
local ret = {n={},ntypes={},s={},stypes={},size=0}
local time = os.date((utc and "!" or "") .. "*t",time)
if not time then return ret end -- this happens if you give it a negative time
for k,v in pairs( time ) do
if k == "isdst" then
ret.s.isdst = (v and 1 or 0)
@ -141,10 +141,10 @@ local function luaDateToE2Table( time, utc )
ret.s[k] = v
ret.stypes[k] = "n"
end
ret.size = ret.size + 1
end
return ret
end
__e2setcost(10)
@ -192,16 +192,16 @@ end
local validkeys = {hour = true, min = true, day = true, sec = true, yday = true, wday = true, month = true, year = true, isdst = true}
e2function number time(table data)
local args = {}
for k,v in pairs( data.s ) do
if data.stypes[k] ~= "n" or not validkeys[k] then continue end
if k == "isdst" then
args.isdst = (v == 1)
else
args[k] = v
end
end
return os.time( args )
end

View File

@ -391,8 +391,8 @@ __e2setcost(6)
e2function vector round(vector rv1)
return {
floor(rv1[1] + 0.5),
floor(rv1[2] + 0.5),
floor(rv1[1] + 0.5),
floor(rv1[2] + 0.5),
floor(rv1[3] + 0.5)
}
end
@ -400,16 +400,16 @@ end
e2function vector round(vector rv1, decimals)
local shf = 10 ^ decimals
return {
floor(rv1[1] * shf + 0.5) / shf,
floor(rv1[2] * shf + 0.5) / shf,
floor(rv1[1] * shf + 0.5) / shf,
floor(rv1[2] * shf + 0.5) / shf,
floor(rv1[3] * shf + 0.5) / shf
}
end
e2function vector ceil( vector rv1 )
return {
ceil(rv1[1]),
ceil(rv1[2]),
ceil(rv1[1]),
ceil(rv1[2]),
ceil(rv1[3])
}
end
@ -417,16 +417,16 @@ end
e2function vector ceil(vector rv1, decimals)
local shf = 10 ^ decimals
return {
ceil(rv1[1] * shf) / shf,
ceil(rv1[2] * shf) / shf,
ceil(rv1[1] * shf) / shf,
ceil(rv1[2] * shf) / shf,
ceil(rv1[3] * shf) / shf
}
end
e2function vector floor(vector rv1)
return {
floor(rv1[1]),
floor(rv1[2]),
floor(rv1[1]),
floor(rv1[2]),
floor(rv1[3])
}
end
@ -434,8 +434,8 @@ end
e2function vector floor(vector rv1, decimals)
local shf = 10 ^ decimals
return {
floor(rv1[1] * shf) / shf,
floor(rv1[2] * shf) / shf,
floor(rv1[1] * shf) / shf,
floor(rv1[2] * shf) / shf,
floor(rv1[3] * shf) / shf
}
end

View File

@ -311,7 +311,7 @@ __e2setcost(4)
e2function vector2 round(vector2 rv1)
return {
floor(rv1[1] + 0.5),
floor(rv1[1] + 0.5),
floor(rv1[2] + 0.5)
}
end
@ -319,14 +319,14 @@ end
e2function vector2 round(vector2 rv1, decimals)
local shf = 10 ^ decimals
return {
floor(rv1[1] * shf + 0.5) / shf,
floor(rv1[1] * shf + 0.5) / shf,
floor(rv1[2] * shf + 0.5) / shf
}
end
e2function vector2 ceil( vector2 rv1 )
return {
ceil(rv1[1]),
ceil(rv1[1]),
ceil(rv1[2])
}
end
@ -334,14 +334,14 @@ end
e2function vector2 ceil(vector2 rv1, decimals)
local shf = 10 ^ decimals
return {
ceil(rv1[1] * shf) / shf,
ceil(rv1[1] * shf) / shf,
ceil(rv1[2] * shf) / shf
}
end
e2function vector2 floor(vector2 rv1)
return {
floor(rv1[1]),
floor(rv1[1]),
floor(rv1[2])
}
end
@ -349,7 +349,7 @@ end
e2function vector2 floor(vector2 rv1, decimals)
local shf = 10 ^ decimals
return {
floor(rv1[1] * shf) / shf,
floor(rv1[1] * shf) / shf,
floor(rv1[2] * shf) / shf
}
end
@ -864,9 +864,9 @@ end
e2function vector4 round(vector4 rv1, decimals)
local shf = 10 ^ decimals
return {
floor(rv1[1] * shf + 0.5) / shf,
floor(rv1[1] * shf + 0.5) / shf,
floor(rv1[2] * shf + 0.5) / shf,
floor(rv1[3] * shf + 0.5) / shf,
floor(rv1[3] * shf + 0.5) / shf,
floor(rv1[4] * shf + 0.5) / shf
}
end

View File

@ -94,7 +94,7 @@ function ENT:UpdateOverlay(clear)
prfcount = self.context.prfcount,
timebench = self.context.timebench
})
end
end
end
function ENT:Initialize()
@ -344,11 +344,11 @@ function ENT:ResetContext()
self.Inputs = WireLib.AdjustSpecialInputs(self, self.inports[1], self.inports[2])
self.Outputs = WireLib.AdjustSpecialOutputs(self, self.outports[1], self.outports[2])
if self.extended then -- It was extended before the adjustment, recreate the wirelink
WireLib.CreateWirelinkOutput( self.player, self, {true} )
end
self._original = string.Replace(string.Replace(self.original, "\"", string.char(163)), "\n", string.char(128))
self._name = self.name
@ -570,7 +570,7 @@ function MakeWireExpression2(player, Pos, Ang, model, buffer, name, inputs, outp
local self = ents.Create("gmod_wire_expression2")
if not self:IsValid() then return false end
if buffer then self.duped = true end
self:SetModel(model)
@ -585,21 +585,21 @@ function MakeWireExpression2(player, Pos, Ang, model, buffer, name, inputs, outp
buffer = string.Replace(string.Replace(buffer, string.char(163), "\""), string.char(128), "\n")
self.buffer = buffer
self:SetOverlayText(name)
self.inc_files = inc_files or {}
self.Inputs = WireLib.AdjustSpecialInputs(self, inputs[1], inputs[2])
self.Outputs = WireLib.AdjustSpecialOutputs(self, outputs[1], outputs[2])
self.dupevars = vars
self.filepath = filepath
else
self.buffer = "error(\"You tried to dupe an E2 with compile errors!\")\n#Unfortunately, no code can be saved when duping an E2 with compile errors.\n#Fix your errors and try again."
self.inc_files = {}
self.dupevars = {}
self.name = "generic"
end
@ -615,16 +615,16 @@ duplicator.RegisterEntityClass("gmod_wire_expression2", MakeWireExpression2, "Po
-- Emergency shutdown (beta testing so far)
--------------------------------------------------
local average_ram = 0
local enable = CreateConVar(
"wire_expression2_ram_emergency_shutdown_enable", "0", {FCVAR_ARCHIVE},
local enable = CreateConVar(
"wire_expression2_ram_emergency_shutdown_enable", "0", {FCVAR_ARCHIVE},
"Enable/disable the emergency shutdown feature." )
local average_halt_multiplier = CreateConVar(
"wire_expression2_ram_emergency_shutdown_spike", "4", {FCVAR_ARCHIVE},
local average_halt_multiplier = CreateConVar(
"wire_expression2_ram_emergency_shutdown_spike", "4", {FCVAR_ARCHIVE},
"if (current_ram > average_ram * spike_convar) then shut down all E2s" )
local halt_max_amount = CreateConVar(
"wire_expression2_ram_emergency_shutdown_total", "512", {FCVAR_ARCHIVE},
local halt_max_amount = CreateConVar(
"wire_expression2_ram_emergency_shutdown_total", "512", {FCVAR_ARCHIVE},
"This is in kilobytes, if (current_ram > total_convar) then shut down all E2s" )
local function enableEmergencyShutdown()
@ -662,4 +662,4 @@ local function enableEmergencyShutdown()
end
enableEmergencyShutdown()
cvars.AddChangeCallback( "wire_expression2_ram_emergency_shutdown_enable", enableEmergencyShutdown )
cvars.AddChangeCallback( "wire_expression2_ram_emergency_shutdown_enable", enableEmergencyShutdown )

View File

@ -4,7 +4,7 @@ ENT.PrintName = "Wire Eye Pod"
ENT.Purpose = "To control the player's view in a pod and output their mouse movements"
ENT.WireDebugName = "Eye Pod"
if CLIENT then
if CLIENT then
local enabled = false
local rotate90 = false
local freezePitch = true
@ -47,7 +47,7 @@ if CLIENT then
previousEnabled = false
end
end)
return -- No more client
end
@ -119,7 +119,7 @@ function ENT:Setup(DefaultToZero, RateOfChange, ClampXMin, ClampXMax, ClampYMin,
self.ClampYMax = ClampYMax
self.ClampX = ClampX
self.ClampY = ClampY
self:UpdateOverlay()
end
@ -251,15 +251,15 @@ function ENT:TriggerInput(iname, value)
-- Change variables to reflect input
if iname == "Enable" then
self.enabled = value ~= 0
if self.enabled == false and self.DefaultToZero == 1 and (self.X ~= 0 or self.Y ~= 0) then
self.X = 0
self.Y = 0
WireLib.TriggerOutput( self, "X", 0 )
WireLib.TriggerOutput( self, "Y", 0 )
WireLib.TriggerOutput( self, "XY", {0,0} )
end
end
self:UpdateOverlay()
elseif iname == "SetPitch" then
self.eyeAng = Angle(AngNorm90(value), self.eyeAng.y, self.eyeAng.r)
@ -280,7 +280,7 @@ function ENT:TriggerInput(iname, value)
elseif iname == "UnfreezeYaw" then
self.freezeYaw = value == 0
end
if IsValid(self.pod) and IsValid(self.driver) then
self:updateEyePodState(self.enabled)
end
@ -303,10 +303,10 @@ hook.Add("SetupMove", "WireEyePodMouseControl", function(ply, movedata)
if eyePod.enabled then
local cmd = ply:GetCurrentCommand()
local oldX = eyePod.X
local oldY = eyePod.Y
--reset the output so it is not cumualative if you want the rate of change
if eyePod.ShowRateOfChange == 1 then
eyePod.X = 0
@ -329,7 +329,7 @@ hook.Add("SetupMove", "WireEyePodMouseControl", function(ply, movedata)
-- Update outputs
WireLib.TriggerOutput(eyePod, "X", eyePod.X)
WireLib.TriggerOutput(eyePod, "Y", eyePod.Y)
local XY_Vec = {eyePod.X, eyePod.Y}
WireLib.TriggerOutput(eyePod, "XY", XY_Vec)
end

View File

@ -70,8 +70,8 @@ local collisionDescriptions = {
}
function ENT:UpdateOverlay()
self:SetOverlayText(
(self.State and "Frozen" or "Unfrozen") .. "\n" ..
self:SetOverlayText(
(self.State and "Frozen" or "Unfrozen") .. "\n" ..
collisionDescriptions[self.CollisionState] .. "\n" ..
"Linked Entities: " .. #self.Marks)
end

View File

@ -36,7 +36,7 @@ end
include( "wire/fx_emitter_default.lua" )
if CLIENT then
if CLIENT then
ENT.Delay = 0.05
function ENT:Draw()
@ -83,7 +83,7 @@ if CLIENT then
self.Effects[ Effect ] = nil
end
end
return -- No more client
end

View File

@ -22,7 +22,7 @@ function ENT:Setup( action, noclip )
if GateActions[action].is_banned then return end
self.Updating = true
self.action = action
self.WireDebugName = gate.name

View File

@ -10,9 +10,9 @@ function ENT:Initialize()
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:GetPhysicsObject():EnableGravity(false)
self.Inputs = WireLib.CreateInputs(self,{"On", "X", "Y", "Z", "Target [VECTOR]", "Direction [VECTOR]", "Angle [ANGLE]"})
self.XYZ = Vector()
end
@ -23,7 +23,7 @@ function ENT:TriggerInput(name,value)
self.TargetPos = nil
self.TargetDir = nil
self.TargetAng = nil
if name == "X" then
self.XYZ.x = value
self.TargetPos = self.XYZ
@ -46,7 +46,7 @@ function ENT:TriggerInput(name,value)
return true
end
function ENT:Think()
if self.On then
local ang

View File

@ -3,7 +3,7 @@ DEFINE_BASECLASS( "base_wire_entity" )
ENT.PrintName = "Wire GPS"
ENT.WireDebugName = "GPS"
if CLIENT then
if CLIENT then
function ENT:Think()
self.BaseClass.Think(self)
@ -16,7 +16,7 @@ if CLIENT then
self:NextThink(CurTime()+0.04)
return true
end
return -- No more client
end

View File

@ -61,7 +61,7 @@ function ENT:OverrideVM()
surface.SetTexture(0)
surface.SetDrawColor(0,0,0,120)
surface.DrawRect(0,0,self.ScreenWidth,self.ScreenHeight)
draw.DrawText("Error in the instruction stream","WireGPU_ErrorFont",48,16,Color(255,255,255,255))
draw.DrawText((self.ErrorText[interruptNo] or "Unknown error").." (#"..interruptNo..")","WireGPU_ErrorFont",16,16+32*2,Color(255,255,255,255))
draw.DrawText("Parameter: "..(interruptParameter or 0),"WireGPU_ErrorFont",16,16+32*3,Color(255,255,255,255))
@ -198,7 +198,7 @@ function VM:SetFont()
local name, size = self.FontName[self.Font], self.FontSize
if not fontcache[name] or not fontcache[name][size] then
if not fontcache[name] then fontcache[name] = {} end
surface.CreateFont("WireGPU_"..name..size, {
font = name,
size = size,
@ -208,7 +208,7 @@ function VM:SetFont()
})
fontcache[name][size] = true
end
surface.SetFont("WireGPU_"..name..size)
end
@ -584,7 +584,7 @@ function VM:HardReset()
-- Has initialized already
self.INIT = 0
-- Reset async thread
self.AsyncState = nil
end
@ -833,7 +833,7 @@ function VM:ReadString(address)
currentChar = self:ReadCell(address + charCount)
-- Reading failed
if not currentChar then
return
return
elseif currentChar > 0 and currentChar < 255 then
charString = charString .. string.char(currentChar)
elseif currentChar ~= 0 then

View File

@ -117,7 +117,7 @@ function ENT:ReadCell(Address)
self:Interrupt(15,Address)
return
end
if (Address < 0) or (Address >= self.RAMSize) then
return nil
else

View File

@ -79,7 +79,7 @@ function ENT:CanGrab(trace)
if (not trace.Entity:IsValid() and not trace.Entity:IsWorld()) or trace.Entity:IsPlayer() then return false end
-- If there's no physics object then we can't constraint it!
if not util.IsValidPhysicsObject(trace.Entity, trace.PhysicsBone) then return false end
if not gamemode.Call( "CanTool", self:GetPlayer(), trace, "weld" ) then return false end
return true

Some files were not shown because too many files have changed in this diff Show More