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 *.vvd binary
*.wav 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 - luarocks list --outdated --porcelain | awk '{ print $1, $3 }' | xargs --no-run-if-empty -n 2 luarocks install
script: 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 - 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 - 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" 39:"Weld"
40:"Keepupright" 40:"Keepupright"
41:"angularlimit" 41:"angularlimit"
Saved:291 Saved:291

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,8 +9,8 @@ void Main()
{ {
glSleep( 40 ); // Sleep for 40 milliseconds (reduces fps lag) glSleep( 40 ); // Sleep for 40 milliseconds (reduces fps lag)
glClear( 100, 149, 237 ); // Clear screen 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 glVertexPipe( GL_VPIPE_XYZTRANSFORM ); // Set vertex pipe to xyz transformation
glLightPos( 0, 0, -50 ); // Set the light position glLightPos( 0, 0, -50 ); // Set the light position
@ -20,29 +20,29 @@ void Main()
0, 0, -2.8, // Camera pos 0, 0, -2.8, // Camera pos
0, 0, 0, // Camera target 0, 0, 0, // Camera target
0, 1, 0 // Camera up 0, 1, 0 // Camera up
); );
// Create variable to hold curtime // Create variable to hold curtime
float time; float time;
timer time; timer time;
// Create perspective and matrix transformations // Create perspective and matrix transformations
glPerspective( 30, 1, 1, 20 ); // FOV, ASPECT RATIO, ZNEAR, ZFAR glPerspective( 30, 1, 1, 20 ); // FOV, ASPECT RATIO, ZNEAR, ZFAR
glRotate( 0, 1, 0, time ); // AXIS X, Y, Z, ANGLE W glRotate( 0, 1, 0, time ); // AXIS X, Y, Z, ANGLE W
glTranslate( 0, -0.1, 0, 0 ); // TRANSLATION X, Y, Z glTranslate( 0, -0.1, 0, 0 ); // TRANSLATION X, Y, Z
glScale( 1, 1, 1, 0 ); // SCALE 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_ZSORT ); // Enable Z sorting
glEnable( GL_VERTEX_LIGHTING ); // Enable vertex lighting glEnable( GL_VERTEX_LIGHTING ); // Enable vertex lighting
glEnable( GL_VERTEX_CULLING ); // Enable face culling glEnable( GL_VERTEX_CULLING ); // Enable face culling
// Solid 3D polygon // Solid 3D polygon
glFillMode( GL_FILL_SOLID ); // Set fillmode as solid glFillMode( GL_FILL_SOLID ); // Set fillmode as solid
glColor4( 255, 255, 255, 255 ); // Set draw color with alpha 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 glFlush(); // Flush the vertex buffer to the screen
glExit(); // Exit 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.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.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;
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; 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 -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; 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) glSleep( 60 ); // Sleep for 60 milliseconds (reduces fps lag)
glClear( 0, 0, 0 ); // Clear screen 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 glVertexPipe( GL_VPIPE_XYZTRANSFORM ); // Set vertex pipe to xyz transformation
glLightPos( -1, -1, -1 ); // Set the light position glLightPos( -1, -1, -1 ); // Set the light position
@ -20,7 +20,7 @@ void Main()
0, 0, -25, // Camera pos 0, 0, -25, // Camera pos
0, 0, 0, // Camera target 0, 0, 0, // Camera target
0, 1, 0 // Camera up 0, 1, 0 // Camera up
); );
// Loop and draw 4 models // Loop and draw 4 models
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
@ -30,14 +30,14 @@ void Main()
zTranslate *= -16; zTranslate *= -16;
mod zTranslate,16; mod zTranslate,16;
zTranslate += (i * 16); zTranslate += (i * 16);
// Create perspective and matrix transformations // Create perspective and matrix transformations
glPerspective( 8, 1, 0.4, 20 ); // FOV, ASPECT RATIO, ZNEAR, ZFAR glPerspective( 8, 1, 0.4, 20 ); // FOV, ASPECT RATIO, ZNEAR, ZFAR
glRotate( 0, 0, 0, 0 ); // AXIS X, Y, Z, ANGLE W glRotate( 0, 0, 0, 0 ); // AXIS X, Y, Z, ANGLE W
glTranslate( 0, 0, zTranslate ); // TRANSLATION X, Y, Z glTranslate( 0, 0, zTranslate ); // TRANSLATION X, Y, Z
glScale( 1.2, 1, 8 ); // SCALE 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_ZSORT ); // Enable Z sorting
glEnable( GL_VERTEX_LIGHTING ); // Enable vertex lighting glEnable( GL_VERTEX_LIGHTING ); // Enable vertex lighting
glEnable( GL_VERTEX_CULLING ); // Enable face culling glEnable( GL_VERTEX_CULLING ); // Enable face culling
@ -47,7 +47,7 @@ void Main()
glColor4( 255, 255, 255, 150 ); // Set the draw color with alpha glColor4( 255, 255, 255, 150 ); // Set the draw color with alpha
glPoly3D( VertexBuffer, 12 ); // Draw 3D polygon glPoly3D( VertexBuffer, 12 ); // Draw 3D polygon
glFlush(); // Send our vertex buffer to screen glFlush(); // Send our vertex buffer to screen
// Wireframe 3D polygon // Wireframe 3D polygon
glLineWidth( 1 ); // Set line width of wireframe glLineWidth( 1 ); // Set line width of wireframe
glFillMode( GL_FILL_WIREFRAME ); // Set fillmode to 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; 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 vector2f d,1.0,1.0; // Movement direction & speed
// //
string text,'Bouncing ball!'; // "Bouncing ball!" 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 vector3f vLookAt_Up, 0, 1, 0; //Where our matt-hat is
color fg_color,255,255,25; 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 286,257
db 274,203 db 274,203
db 311,213 db 311,213
//=========================================== //===========================================

View File

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

View File

@ -17,27 +17,27 @@ void Main()
{ {
glVertexMode( 1 ); // Enable vertex mode glVertexMode( 1 ); // Enable vertex mode
glColor( 255, 255, 255 ); // Set draw color glColor( 255, 255, 255 ); // Set draw color
// Set texture as background // Set texture as background
glBindTexture( "phoenix_storms/lag_sign" ); glBindTexture( "phoenix_storms/lag_sign" );
glClearTexture(); glClearTexture();
glBindTexture( 0 ); // Discard texture glBindTexture( 0 ); // Discard texture
glFont( GL_FONT_AKBAR ); // Set font type glFont( GL_FONT_AKBAR ); // Set font type
glFontSize( 36 ); // Set font size glFontSize( 36 ); // Set font size
glWriteString( 2, 2, "LAG-O-METER" ); // Write string to screen glWriteString( 2, 2, "LAG-O-METER" ); // Write string to screen
glOffset( lineWidth, 90 ); // Offset the screen coordinates glOffset( lineWidth, 90 ); // Offset the screen coordinates
glColor4( 0, 0, 0, 160 ); // Set draw color with alpha glColor4( 0, 0, 0, 160 ); // Set draw color with alpha
glRectWH( 0, 0, frameWidth, frameHeight ); // Draw rectangle glRectWH( 0, 0, frameWidth, frameHeight ); // Draw rectangle
glColor( 255, 255, 255 ); glColor( 255, 255, 255 );
glLineWidth( lineWidth ); // Set line width glLineWidth( lineWidth ); // Set line width
glORectWH( 0, 0, frameWidth, frameHeight ); // Draw outlined rectangle glORectWH( 0, 0, frameWidth, frameHeight ); // Draw outlined rectangle
glLineWidth( 1 ); // Set line width to 1 glLineWidth( 1 ); // Set line width to 1
// Loop and make a bunch of connected lines // Loop and make a bunch of connected lines
for (i = 0; i < lines; i++) for (i = 0; i < lines; i++)
{ {
@ -54,9 +54,9 @@ void Main()
y *= frameHeight; y *= frameHeight;
glLine( ox, oy, x, y ); // Draw line on graph glLine( ox, oy, x, y ); // Draw line on graph
} }
glOffset( 0, 0 ); // Set screen offset back to 0,0 glOffset( 0, 0 ); // Set screen offset back to 0,0
glWriteString( 2, 400, "INTENSE LAG DETECTED" ); glWriteString( 2, 400, "INTENSE LAG DETECTED" );
glExit(); // Exit 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.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.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; fsin #HSL.B,EAX; mul #HSL.B,127; add #HSL.B,128;
dcolor HSL; dcolor HSL;
//Looks very nice //Looks very nice
@ -26,7 +26,7 @@ DrawLoop:
dline StartPoint2,EndPoint; dline StartPoint2,EndPoint;
dline StartPoint3,EndPoint; dline StartPoint3,EndPoint;
dline StartPoint4,EndPoint; dline StartPoint4,EndPoint;
mul EDX,EBP; mul EDX,EBP;
add #Angle,EDX; add #Angle,EDX;
loop DrawLoop; loop DrawLoop;

View File

@ -38,7 +38,7 @@
// drotatescale EAX,EBX; mul EBX,2; // drotatescale EAX,EBX; mul EBX,2;
dsetwidth 0.8; dsetwidth 0.8;
call Draw.Background; call Draw.Background;
dexit; dexit;
alloc Time; alloc Time;
@ -48,7 +48,7 @@ Draw.Background:
//Draw all the rectangles //Draw all the rectangles
mov EAX,#Background.MinDepth; mov ECX,#Background.ShadeStart; mov EAX,#Background.MinDepth; mov ECX,#Background.ShadeStart;
BackgroundLoop: BackgroundLoop:
mov EDX,#Time; add EDX,EAX; mov EDX,#Time; add EDX,EAX;
mov EBP,#Time; div EBP,6.28; fcos EBP,EBP; mov EBP,#Time; div EBP,6.28; fcos EBP,EBP;
fsin EDI,EDX; mul EDI,EBP; mul EDI,0.8; sub EDI,1; 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 EDX,ECX; fpwr EDX,2;
mov #regZOffset,EAX; mov #regZOffset,EAX;
dcolor _rect.color; dcolor _rect.color;
// Uncomment this for trippy HSL color // Uncomment this for trippy HSL color
// mov ESI,#Time; add ESI,EAX; // 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; // 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 void main(){ //Main function
dsetbuf_spr; //Use sprite buffer dsetbuf_spr; //Use sprite buffer
setColor(255,255,255); //Set the colour to white setColor(255,255,255); //Set the colour to white
rect(0,0,512,512); //Draw a large rectangle rect(0,0,512,512); //Draw a large rectangle
@ -36,58 +36,58 @@ void main(){ //Main function
width = 512; //GPU Width width = 512; //GPU Width
height = 512; //GPU Height height = 512; //GPU Height
noise = 5; //How noisy it will be noise = 5; //How noisy it will be
//Give initial corner values //Give initial corner values
R1 = random(1); R1 = random(1);
R2 = random(1); R2 = random(1);
R3 = random(1); R3 = random(1);
R4 = random(1); R4 = random(1);
plasma(0,0,width,height,R1,R2,R3,R4) //Start recursive function 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 void plasma(float x, y, width, height, c1, c2, c3, c4){ //Plasma function
//Setup local variables //Setup local variables
float edge1, edge2, edge3, edge4, midPoint; float edge1, edge2, edge3, edge4, midPoint;
//Work out the size of the next segments //Work out the size of the next segments
float newWidth = width / 2; float newWidth = width / 2;
float newHeight = height / 2; float newHeight = height / 2;
if((width > gridSize)||(height > gridSize)){ //If it is still bigger than the rectangle size 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 midPoint = (c1 + c2 + c3 + c4) / 4 + displace(newWidth + newHeight); //Randomly change the midpoint
//Calculate edges by averaging the corners //Calculate edges by averaging the corners
edge1 = (c1 + c2) / 2; edge1 = (c1 + c2) / 2;
edge2 = (c2 + c3) / 2; edge2 = (c2 + c3) / 2;
edge3 = (c3 + c4) / 2; edge3 = (c3 + c4) / 2;
edge4 = (c4 + c1) / 2; edge4 = (c4 + c1) / 2;
//Make sure it doesn't displace too far //Make sure it doesn't displace too far
max midPoint,0; max midPoint,0;
min midPoint,1; min midPoint,1;
//Run on the newly calculated segments //Run on the newly calculated segments
plasma(x, y, newWidth, newHeight, c1, edge1, midPoint, edge4); plasma(x, y, newWidth, newHeight, c1, edge1, midPoint, edge4);
plasma(x + newWidth, y, newWidth, newHeight, edge1, c2, edge2, midPoint); 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 + newHeight, newWidth, newHeight, midPoint, edge2, c3, edge3);
plasma(x, y + newHeight, newWidth, newHeight, edge4, midPoint, edge3, c4); plasma(x, y + newHeight, newWidth, newHeight, edge4, midPoint, edge3, c4);
}else{ //Woo! It's the right size }else{ //Woo! It's the right size
float c = (c1 + c2 + c3 + c4) / 4; //Average the corners float c = (c1 + c2 + c3 + c4) / 4; //Average the corners
float grey = c*255; //Multiply the corners by 255 to get a valid color 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" setColor(grey,grey,grey); //Set the color to your new color based on the "height"
rect(x,y,gridSize,gridSize); //Draw your rectangle rect(x,y,gridSize,gridSize); //Draw your rectangle
} }
} }
float displace(float num){ //Displace function, it just works float displace(float num){ //Displace function, it just works
float m = num / (width + height) * (1/noise); float m = num / (width + height) * (1/noise);
R1 = random(1); R1 = random(1);
return (R1-0.5) * m; return (R1-0.5) * m;
} }
float random(float x){ //C version of the ASM rand opcode 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.r,r;
mov #col.g,g; mov #col.g,g;
mov #col.b,b; mov #col.b,b;
dcolor col; dcolor col;
} }
void rect(float x, float y, float width, float height){ //C version of the drectwh opcode void rect(float x, float y, float width, float height){ //C version of the drectwh opcode
mov #pos.x,x; mov #pos.x,x;
mov #pos.y,y; mov #pos.y,y;
mov #size.x,width; mov #size.x,width;
mov #size.y,height; mov #size.y,height;
drectwh pos, size; drectwh pos, size;
dswap; //dswap to make it show since we're drawing to the sprite buffer 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 // Enable vertex mode
glVertexMode( 1 ); glVertexMode( 1 );
// Draw to sprite buffer // Draw to sprite buffer
glSetRenderTarget( GL_BUFFER_BACK ); glSetRenderTarget( GL_BUFFER_BACK );
glClear( 0, 255, 0 ); glClear( 0, 255, 0 );
// Draw to vertex buffer (world) // Draw to vertex buffer (world)
glSetRenderTarget( GL_BUFFER_VERTEX ); glSetRenderTarget( GL_BUFFER_VERTEX );
glEnable( GL_VERTEX_TEXTURING ); glEnable( GL_VERTEX_TEXTURING );
// Sample from sprite 0 // Sample from sprite 0
glTextureSize( 256 ); glTextureSize( 256 );
glTexture( 0 ); glTexture( 0 );
glClear( 0, 255, 0 ); glClear( 0, 255, 0 );
glRectWH( 128, 128, 256, 256 ); glRectWH( 128, 128, 256, 256 );
glSetRenderTarget( GL_BUFFER_FRONT ); glSetRenderTarget( GL_BUFFER_FRONT );
glExit(); glExit();
} }

View File

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

View File

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

View File

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

View File

@ -51,4 +51,4 @@ vec2f p3,60,60;
vec2f p4,430,430; vec2f p4,430,430;
vec2f p5,70,70; 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' string _s_74,'Y: %f'
vec2f _a_76,272,456 vec2f _a_76,272,456
string _s_77,'Z: %f' string _s_77,'Z: %f'

View File

@ -151,13 +151,13 @@ void glTextureOffsetUV( float u, float v ) {
// Frame // Frame
void glSleep( float ms ) { void glSleep( float ms ) {
div ms,1000; div ms,1000;
timer #GL_CURTIME; timer #GL_CURTIME;
sub #GL_CURTIME,#GL_TIMESTAMP; sub #GL_CURTIME,#GL_TIMESTAMP;
if (*GL_CURTIME <= ms) { if (*GL_CURTIME <= ms) {
mov #regHWClear,0; mov #regHWClear,0;
dexit; dexit;
} }
timer #GL_TIMESTAMP; timer #GL_TIMESTAMP;
} }
void glExit() { void glExit() {
dexit; dexit;
@ -360,7 +360,7 @@ float glParamList() {
// 3D graphics // 3D graphics
void glPoly3D( float* buffer, float count ) { void glPoly3D( float* buffer, float count ) {
if (*GL_MUPDATE == 1) { if (*GL_MUPDATE == 1) {
mov #GL_MUPDATE,0; mov #GL_MUPDATE,0;
mrotate GL_MROTATEMATRIX,GL_VROTATE; mrotate GL_MROTATEMATRIX,GL_VROTATE;
@ -371,10 +371,10 @@ void glPoly3D( float* buffer, float count ) {
mmul GL_MMODELMATRIX,GL_MSCALEMATRIX; mmul GL_MMODELMATRIX,GL_MSCALEMATRIX;
mmov GL_MMODELVIEWMATRIX,GL_MVIEWMATRIX; mmov GL_MMODELVIEWMATRIX,GL_MVIEWMATRIX;
mmul GL_MMODELVIEWMATRIX,GL_MMODELMATRIX; mmul GL_MMODELVIEWMATRIX,GL_MMODELMATRIX;
mload GL_MMODELVIEWMATRIX; mload GL_MMODELVIEWMATRIX;
mloadproj GL_MPROJECTIONMATRIX; mloadproj GL_MPROJECTIONMATRIX;
} }
if (*GL_FILLMODE == GL_FILL_SOLID) { if (*GL_FILLMODE == GL_FILL_SOLID) {
dvxdata_3f buffer,count; dvxdata_3f buffer,count;
} }
@ -420,7 +420,7 @@ void glPerspective( float fov, float asp, float znear, float zfar ) {
mov #GL_MUPDATE,1; mov #GL_MUPDATE,1;
} }
void glRotate( float x, float y, float z, float w ) { 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; mov #GL_MUPDATE,1;
} }
void glTranslate( float x, float y, float z ) { void glTranslate( float x, float y, float z ) {
@ -500,5 +500,3 @@ vec4f GL_VROTATE;
vec4f GL_VTRANSLATE; vec4f GL_VTRANSLATE;
vec4f GL_VPERSPECTIVE; vec4f GL_VPERSPECTIVE;
vec4f GL_VSCALE,1,1,1,0; 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) void gltVertex(float x, float y, float z)
{ {
if ((__GLT_VERTCNT / 3) >= GLT_MAX_TRIANGLES) if ((__GLT_VERTCNT / 3) >= GLT_MAX_TRIANGLES)
return; return;
float* ptr = __GLT_VERTBUFF; float* ptr = __GLT_VERTBUFF;
ptr += (__GLT_VERTCNT * 3); ptr += (__GLT_VERTCNT * 3);
*ptr = x; *ptr = x;
*(++ptr) = y; *(++ptr) = y;
*(++ptr) = z; *(++ptr) = z;
__GLT_VERTCNT++; __GLT_VERTCNT++;
} }
@ -44,7 +44,7 @@ void gltQuad(float tlx, float tly, float tlz,
tlx, tly, tlz, tlx, tly, tlz,
blx, bly, blz blx, bly, blz
); );
gltTriangle( gltTriangle(
brx, bry, brz, brx, bry, brz,
trx, try, trz, 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) void gltCube(float cex, float cey, float cez, float size)
{ {
float s2 = size / 2; float s2 = size / 2;
gltQuad( 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,
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( 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,
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( 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,
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( 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,
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( 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,
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( 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,
@ -108,13 +108,13 @@ void gltFlushBuffer()
{ {
if (__GLT_VERTCNT <= 3) if (__GLT_VERTCNT <= 3)
return; return;
float vcnt = __GLT_VERTCNT; float vcnt = __GLT_VERTCNT;
float tcnt = (vcnt / 3) - (vcnt % 3); float tcnt = (vcnt / 3) - (vcnt % 3);
if (tcnt > GLT_MAX_TRIANGLES) if (tcnt > GLT_MAX_TRIANGLES)
tcnt = GLT_MAX_TRIANGLES; tcnt = GLT_MAX_TRIANGLES;
glPoly3D(__GLT_VERTBUFF, tcnt); glPoly3D(__GLT_VERTBUFF, tcnt);
glFlush(); glFlush();
} }

View File

@ -35,22 +35,22 @@ void main()
fpwr note,(trackA[i]/12); fpwr note,(trackA[i]/12);
note /= 100; note /= 100;
chpitch 0,note; chpitch 0,note;
// Track B // Track B
note = 2; note = 2;
fpwr note,(trackB[i]/12); fpwr note,(trackB[i]/12);
note /= 100; note /= 100;
chpitch 1,note; chpitch 1,note;
// Bass // Bass
note = 2; note = 2;
fpwr note,(bass[i]/12); fpwr note,(bass[i]/12);
note /= 100; note /= 100;
chpitch 2,note; chpitch 2,note;
// Index // Index
i++; mod i,tracklen; i++; mod i,tracklen;
// Repeat // Repeat
jmp main; 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 // 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,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 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,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 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,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 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 db 0; // End string
@ -106,7 +106,7 @@ db 0; // End string
trackB: trackB:
// Intro // 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; 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 // 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 db 0; // End string
bass: bass:
// Intro // 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; 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 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 db 0; // End string

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -93,7 +93,7 @@ function ENT:Initialize()
GPULib.ClientCacheCallback(self,function(Address,Value) GPULib.ClientCacheCallback(self,function(Address,Value)
self:WriteCell(Address,Value) self:WriteCell(Address,Value)
end) end)
WireLib.netRegister(self) WireLib.netRegister(self)
end 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) local wire_cpu_max_frequency = CreateConVar("wire_cpu_max_frequency", cpu_max_frequency, FCVAR_REPLICATED)
cvars.AddChangeCallback("wire_cpu_max_frequency",function() 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) end)
function ENT:Initialize() function ENT:Initialize()
@ -88,11 +88,11 @@ function ENT:Initialize()
end end
else VM:Interrupt(8,Address+1) return else VM:Interrupt(8,Address+1) return
end end
else return 0 else return 0
end end
end end
end end
local oldReset = self.VM.Reset local oldReset = self.VM.Reset
self.VM.Reset = function(...) self.VM.Reset = function(...)
if self.Clk and self.VMStopped then 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.hit = false -- Tracks whether detector registered any damage that tick
self.firsthit_dmginfo = {} -- Stores damage info representing damage during an interval self.firsthit_dmginfo = {} -- Stores damage info representing damage during an interval
self.linked_entities = {} -- numerical array self.linked_entities = {} -- numerical array
self.linked_entities_lookup = {} -- lookup table indexed by entities self.linked_entities_lookup = {} -- lookup table indexed by entities
self:LinkEnt( self ) self:LinkEnt( self )
self.count = 0 self.count = 0
@ -100,7 +100,7 @@ function ENT:ShowOutput()
text = text .. "Linked to " .. #self.linked_entities .. " entities." text = text .. "Linked to " .. #self.linked_entities .. " entities."
end end
end end
self:SetOverlayText( text ) self:SetOverlayText( text )
self:SetOverlayText(text) self:SetOverlayText(text)
@ -113,7 +113,7 @@ end
function ENT:LinkEnt( ent ) function ENT:LinkEnt( ent )
if self.linked_entities_lookup[ent] then return false end if self.linked_entities_lookup[ent] then return false end
self.linked_entities_lookup[ent] = true self.linked_entities_lookup[ent] = true
self.linked_entities[#self.linked_entities+1] = ent self.linked_entities[#self.linked_entities+1] = ent
ent:CallOnRemove( "DDetector.Unlink", function( ent ) ent:CallOnRemove( "DDetector.Unlink", function( ent )
@ -121,7 +121,7 @@ function ENT:LinkEnt( ent )
self:UnlinkEnt( ent ) self:UnlinkEnt( ent )
end end
end ) end )
self:ShowOutput() self:ShowOutput()
WireLib.SendMarks( self, self.linked_entities ) WireLib.SendMarks( self, self.linked_entities )
return true return true
@ -129,18 +129,18 @@ end
function ENT:UnlinkEnt( ent ) function ENT:UnlinkEnt( ent )
if not self.linked_entities_lookup[ent] then return false end if not self.linked_entities_lookup[ent] then return false end
self.linked_entities_lookup[ent] = nil self.linked_entities_lookup[ent] = nil
for i=1,#self.linked_entities do for i=1,#self.linked_entities do
if self.linked_entities[i] == ent then if self.linked_entities[i] == ent then
table.remove( self.linked_entities, i ) table.remove( self.linked_entities, i )
break break
end end
end end
ent:RemoveCallOnRemove( "DDetector.Unlink" ) ent:RemoveCallOnRemove( "DDetector.Unlink" )
self:ShowOutput() self:ShowOutput()
WireLib.SendMarks( self, self.linked_entities ) WireLib.SendMarks( self, self.linked_entities )
return true return true
@ -152,10 +152,10 @@ function ENT:ClearEntities()
self.linked_entities[i]:RemoveCallOnRemove( "DDetector.Unlink" ) self.linked_entities[i]:RemoveCallOnRemove( "DDetector.Unlink" )
end end
end end
self.linked_entities = {} self.linked_entities = {}
self.linked_entities_lookup = {} self.linked_entities_lookup = {}
self:ShowOutput() self:ShowOutput()
WireLib.SendMarks( self, self.linked_entities ) WireLib.SendMarks( self, self.linked_entities )
return true return true
@ -167,7 +167,7 @@ function ENT:TriggerInput( iname, value )
elseif iname == "Entities" then -- Populate linked_entities from "Array" elseif iname == "Entities" then -- Populate linked_entities from "Array"
if value then if value then
self:ClearEntities() self:ClearEntities()
for _, v in pairs( value ) do for _, v in pairs( value ) do
if IsValid( v ) then if IsValid( v ) then
self:LinkEnt( v ) 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 if self.includeconstrained == 1 then -- Don't update constrained entities unless we have to
self:UpdateConstrainedEnts( ent ) self:UpdateConstrainedEnts( ent )
end end
self.key_ents[ent] = true self.key_ents[ent] = true
else else
self.linked_entities[ent] = nil self.linked_entities[ent] = nil
@ -227,7 +227,7 @@ end
function ENT:UpdateConstrainedEnts( ent ) -- Finds all entities constrained to 'ent' function ENT:UpdateConstrainedEnts( ent ) -- Finds all entities constrained to 'ent'
local ents = constraint.GetAllConstrainedEntities( ent ) local ents = constraint.GetAllConstrainedEntities( ent )
for _,v in pairs( ents ) do for _,v in pairs( ents ) do
self.key_ents[v] = true self.key_ents[v] = true
end end
@ -291,10 +291,10 @@ duplicator.RegisterEntityClass("gmod_wire_damage_detector", WireLib.MakeWireEnt,
function ENT:BuildDupeInfo() function ENT:BuildDupeInfo()
local info = self.BaseClass.BuildDupeInfo(self) or {} local info = self.BaseClass.BuildDupeInfo(self) or {}
if #self.linked_entities > 0 then if #self.linked_entities > 0 then
info.linked_entities = {} info.linked_entities = {}
for i=1,#self.linked_entities do for i=1,#self.linked_entities do
if IsValid( self.linked_entities[i] ) then if IsValid( self.linked_entities[i] ) then
info.linked_entities[i] = self.linked_entities[i]:EntIndex() info.linked_entities[i] = self.linked_entities[i]:EntIndex()
@ -303,13 +303,13 @@ function ENT:BuildDupeInfo()
end end
end end
end end
return info return info
end end
function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID) function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID)
self.BaseClass.ApplyDupeInfo(self, ply, ent, info, GetEntByID) self.BaseClass.ApplyDupeInfo(self, ply, ent, info, GetEntByID)
if info.linked_entities then if info.linked_entities then
if type( info.linked_entities ) == "number" then -- old dupe compatibility if type( info.linked_entities ) == "number" then -- old dupe compatibility
self:LinkEnt( GetEntByID( info.linked_entities ) ) self:LinkEnt( GetEntByID( info.linked_entities ) )
@ -319,7 +319,7 @@ function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID)
end end
end end
end end
self:ShowOutput() self:ShowOutput()
-- wait a while after dupe before sending marks, because the entity doesn't exist clientside yet -- 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 ) 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 end
function ENT:LinkEnt( transmitter ) 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!" return false, "Satellite Dishes can only be linked to Wire Data Transferers!"
end end
self.Transmitter = transmitter self.Transmitter = transmitter

View File

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

View File

@ -114,7 +114,7 @@ function ENT:FlushCache(ply)
end end
if self.UseBuffering then 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 -- the user stops writing data, or up to three seconds
if not self.WaitToFlush then if not self.WaitToFlush then
self.OldChangedCount = #self.ChangedCellRanges self.OldChangedCount = #self.ChangedCellRanges
@ -131,48 +131,48 @@ function ENT:FlushCache(ply)
end end
self.WaitToFlush = nil self.WaitToFlush = nil
local pixelformat = (math.floor(self.Memory[1048569]) or 0) + 1 local pixelformat = (math.floor(self.Memory[1048569]) or 0) + 1
if pixelformat < 1 or pixelformat > #pixelbits then pixelformat = 1 end if pixelformat < 1 or pixelformat > #pixelbits then pixelformat = 1 end
local pixelbit = pixelbits[pixelformat] local pixelbit = pixelbits[pixelformat]
local bitsremaining = 200000 local bitsremaining = 200000
local datastr = {} local datastr = {}
net.Start("wire_digitalscreen") net.Start("wire_digitalscreen")
net.WriteUInt(self:EntIndex(),16) net.WriteUInt(self:EntIndex(),16)
net.WriteUInt(pixelformat, 5) net.WriteUInt(pixelformat, 5)
bitsremaining = bitsremaining - 21 bitsremaining = bitsremaining - 21
while bitsremaining>0 and next(self.ChangedCellRanges) do while bitsremaining>0 and next(self.ChangedCellRanges) do
local range = self.ChangedCellRanges[1] local range = self.ChangedCellRanges[1]
local start = range.start local start = range.start
local length = math.min(range.length, math.ceil(bitsremaining/pixelbit)) --Estimate how many numbers to read from the range 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.length = range.length - length --Update the range and remove it if its empty
range.start = start + length range.start = start + length
if range.length==0 then table.remove(self.ChangedCellRanges, 1) end if range.length==0 then table.remove(self.ChangedCellRanges, 1) end
buildData(datastr, self.Memory, pixelbit, start, length) buildData(datastr, self.Memory, pixelbit, start, length)
bitsremaining = bitsremaining - length*pixelbit bitsremaining = bitsremaining - length*pixelbit
end end
numberToString(datastr,0,3) numberToString(datastr,0,3)
local compressed = util.Compress(table.concat(datastr)) local compressed = util.Compress(table.concat(datastr))
net.WriteData(compressed,#compressed) net.WriteData(compressed,#compressed)
if ply then net.Send(ply) else net.Broadcast() end if ply then net.Send(ply) else net.Broadcast() end
end end
function ENT:Retransmit(ply) function ENT:Retransmit(ply)
self:FlushCache() -- Empty the cache self:FlushCache() -- Empty the cache
self:MarkCellChanged(1048569) -- Colormode self:MarkCellChanged(1048569) -- Colormode
self:MarkCellChanged(1048572) -- Screen Width self:MarkCellChanged(1048572) -- Screen Width
self:MarkCellChanged(1048573) -- Screen Height self:MarkCellChanged(1048573) -- Screen Height
self:MarkCellChanged(1048575) -- Clk self:MarkCellChanged(1048575) -- Clk
self:FlushCache(ply) self:FlushCache(ply)
local memory = self.Memory local memory = self.Memory
for addr=0, self.ScreenWidth*self.ScreenHeight do for addr=0, self.ScreenWidth*self.ScreenHeight do
if memory[addr] then if memory[addr] then
@ -213,7 +213,7 @@ function ENT:WriteCell(Address, value)
return true return true
end end
else 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) -- 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) value = math.Clamp(math.floor(value or 0), 0, 9)
elseif Address == 1048570 then -- Clear row 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.OnUp( pl, keygroup, "WireDualInput_Off", self, 1 )
numpad.OnDown( pl, keygroup2, "WireDualInput_On", self, -1 ) numpad.OnDown( pl, keygroup2, "WireDualInput_On", self, -1 )
numpad.OnUp( pl, keygroup2, "WireDualInput_Off", self, -1 ) numpad.OnUp( pl, keygroup2, "WireDualInput_Off", self, -1 )
self.toggle = (toggle == 1 || toggle == true) self.toggle = (toggle == 1 || toggle == true)
self.value_off = value_off self.value_off = value_off
self.value_on = value_on self.value_on = value_on

View File

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

View File

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

View File

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

View File

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

View File

@ -91,18 +91,18 @@ hook.Add("Initialize","EGP_HUD_Initialize",function()
function EGP:LinkHUDToVehicle( hud, vehicle ) function EGP:LinkHUDToVehicle( hud, vehicle )
if not hud.LinkedVehicles then hud.LinkedVehicles = {} end if not hud.LinkedVehicles then hud.LinkedVehicles = {} end
if not hud.Marks then hud.Marks = {} end if not hud.Marks then hud.Marks = {} end
hud.Marks[#hud.Marks+1] = vehicle hud.Marks[#hud.Marks+1] = vehicle
hud.LinkedVehicles[vehicle] = true hud.LinkedVehicles[vehicle] = true
vehiclelinks[hud] = hud.LinkedVehicles 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) 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 ) WireLib.SendMarks( hud )
end) end)
end end
function EGP:UnlinkHUDFromVehicle( hud, vehicle ) function EGP:UnlinkHUDFromVehicle( hud, vehicle )
if not vehicle then -- unlink all if not vehicle then -- unlink all
vehiclelinks[hud] = nil vehiclelinks[hud] = nil
hud.LinkedVehicles = nil hud.LinkedVehicles = nil
hud.Marks = nil hud.Marks = nil
@ -117,7 +117,7 @@ hook.Add("Initialize","EGP_HUD_Initialize",function()
umsg.End() umsg.End()
end end
end end
if hud.Marks then if hud.Marks then
for i=1,#hud.Marks do for i=1,#hud.Marks do
if hud.Marks[i] == vehicle then if hud.Marks[i] == vehicle then
@ -126,17 +126,17 @@ hook.Add("Initialize","EGP_HUD_Initialize",function()
end end
end end
end end
hud.LinkedVehicles[vehicle] = nil hud.LinkedVehicles[vehicle] = nil
if not next( hud.LinkedVehicles ) then if not next( hud.LinkedVehicles ) then
hud.LinkedVehicles = nil hud.LinkedVehicles = nil
hud.Marks = nil hud.Marks = nil
end end
vehiclelinks[hud] = hud.LinkedVehicles vehiclelinks[hud] = hud.LinkedVehicles
end end
end end
WireLib.SendMarks( hud ) WireLib.SendMarks( hud )
end end

View File

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

View File

@ -8,4 +8,4 @@ ENT.Purpose = "EGP Hud"
ENT.Instructions = "WireLink To E2" ENT.Instructions = "WireLink To E2"
ENT.Spawnable = false 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() function ENT:Initialize()
self.BaseClass.Initialize(self) self.BaseClass.Initialize(self)
self.Inputs = WireLib.CreateInputs(self, {"Entity [ENTITY]", "Entities [ARRAY]", "Position [VECTOR]", "Local Position [VECTOR]", "Angle [ANGLE]", "Local Angle [ANGLE]"}) 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.Position = Vector(0,0,0)
self.Angle = Angle(0,0,0) self.Angle = Angle(0,0,0)
self.Entities = {} self.Entities = {}
self.Global = false self.Global = false
self.GlobalAngle = false self.GlobalAngle = false
self:AddExitPoint() self:AddExitPoint()
self:ShowOutput() self:ShowOutput()
end end
@ -82,7 +82,7 @@ local function MovePlayer( ply, vehicle )
local LocalPosDistance = epoint.Position:Length() local LocalPosDistance = epoint.Position:Length()
ply:SetPos( vehicle:LocalToWorld( epoint.Position / LocalPosDistance * math.min(LocalPosDistance, math.max(0, ClampDistance:GetInt()))) + Vector(0,0,5) ) ply:SetPos( vehicle:LocalToWorld( epoint.Position / LocalPosDistance * math.min(LocalPosDistance, math.max(0, ClampDistance:GetInt()))) + Vector(0,0,5) )
end end
if epoint.GlobalAngle then if epoint.GlobalAngle then
ply:SetEyeAngles( Angle( epoint.Angle.p, epoint.Angle.y, 0 ) ) ply:SetEyeAngles( Angle( epoint.Angle.p, epoint.Angle.y, 0 ) )
else else
@ -90,7 +90,7 @@ local function MovePlayer( ply, vehicle )
ang.r = 0 ang.r = 0
ply:SetEyeAngles( ang ) ply:SetEyeAngles( ang )
end end
return return
end end
end end
@ -111,7 +111,7 @@ function ENT:LinkEnt( ent )
ent:CallOnRemove("ExitPoint.Unlink", function(ent) ent:CallOnRemove("ExitPoint.Unlink", function(ent)
if IsValid(self) then self:UnlinkEnt(ent) end if IsValid(self) then self:UnlinkEnt(ent) end
end) end)
self:SendMarks() self:SendMarks()
self:ShowOutput() self:ShowOutput()
return true return true
@ -120,7 +120,7 @@ end
function ENT:UnlinkEnt( ent ) function ENT:UnlinkEnt( ent )
if not self.Entities[ent] then return end if not self.Entities[ent] then return end
self.Entities[ent] = nil self.Entities[ent] = nil
self:SendMarks() self:SendMarks()
self:ShowOutput() self:ShowOutput()
return true return true

View File

@ -47,7 +47,7 @@ function ENT:TriggerInput(iname, value)
end end
function ENT:Setup( key, damage, delaytime, removeafter, radius, affectother, notaffected, delayreloadtime, maxhealth, bulletproof, explosionproof, fallproof, explodeatzero, resetatexplode, fireeffect, coloreffect, invisibleatzero ) function ENT:Setup( key, damage, delaytime, removeafter, radius, affectother, notaffected, delayreloadtime, maxhealth, bulletproof, explosionproof, fallproof, explodeatzero, resetatexplode, fireeffect, coloreffect, invisibleatzero )
self.key = key self.key = key
self.Damage = math.Clamp( damage, 0, 1500 ) self.Damage = math.Clamp( damage, 0, 1500 )
self.Delaytime = delaytime 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 if (self.Delaytime > 0) then self.NormInfo = self.NormInfo.." Delay: "..self.Delaytime end
self:ShowOutput() self:ShowOutput()
local ttable = { local ttable = {
key = key, key = key,
damage = damage, 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) error(message .. " at line " .. instr[2][1] .. ", char " .. instr[2][2], 0)
end 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.context = {}
self:InitScope() -- Creates global scope! 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() function ENT:GetWorldTipBodySize()
local data = self:GetOverlayData() local data = self:GetOverlayData()
if not data then return 100, 20 end if not data then return 100, 20 end
local w_total,h_total = wtfgarry( data.txt ) local w_total,h_total = wtfgarry( data.txt )
h_total = h_total + 18 h_total = h_total + 18
local prfbench = data.prfbench local prfbench = data.prfbench
local prfcount = data.prfcount local prfcount = data.prfcount
local timebench = data.timebench local timebench = data.timebench
local e2_hardquota = GetConVar("wire_expression2_quotahard"):GetInt() local e2_hardquota = GetConVar("wire_expression2_quotahard"):GetInt()
local e2_softquota = GetConVar("wire_expression2_quotasoft"):GetInt() local e2_softquota = GetConVar("wire_expression2_quotasoft"):GetInt()
-- ops text -- ops text
local hardtext = (prfcount / e2_hardquota > 0.33) and "(+" .. tostring(math.Round(prfcount / e2_hardquota * 100)) .. "%)" or "" 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) local str = string.format("%i ops, %i%% %s", prfbench, prfbench / e2_softquota * 100, hardtext)
h_of_lower = 0 h_of_lower = 0
local w,h = surface.GetTextSize( str ) local w,h = surface.GetTextSize( str )
w_total = math.max(w_total,w) w_total = math.max(w_total,w)
h_total = h_total + h + 18 h_total = h_total + h + 18
h_of_lower = h_of_lower + h + 18 h_of_lower = h_of_lower + h + 18
-- cpu time text -- cpu time text
local str = string.format("cpu time: %ius", timebench*1000000) local str = string.format("cpu time: %ius", timebench*1000000)
local w,h = surface.GetTextSize( str ) local w,h = surface.GetTextSize( str )
w_total = math.max(w_total,w) w_total = math.max(w_total,w)
h_total = h_total + h + 20 h_total = h_total + h + 20
h_of_lower = h_of_lower + h + 20 + 18 h_of_lower = h_of_lower + h + 20 + 18
return w_total, math.min(h_total,ScrH() - (h_of_lower + 32*2)) return w_total, math.min(h_total,ScrH() - (h_of_lower + 32*2))
end end
function ENT:DrawWorldTipBody( pos ) function ENT:DrawWorldTipBody( pos )
local data = self:GetOverlayData() local data = self:GetOverlayData()
if not data then return end if not data then return end
local txt = data.txt local txt = data.txt
local err = data.error -- this isn't used (yet), might do something with it later local err = data.error -- this isn't used (yet), might do something with it later
local white = Color(255,255,255,255) local white = Color(255,255,255,255)
local black = Color(0,0,0,255) local black = Color(0,0,0,255)
local w_total, yoffset = 0, pos.min.y local w_total, yoffset = 0, pos.min.y
------------------- -------------------
-- Name -- Name
------------------- -------------------
local w,h = wtfgarry( txt ) local w,h = wtfgarry( txt )
h = h + pos.edgesize h = h + pos.edgesize
h = math.min(h,pos.size.h - (h_of_lower+pos.footersize.h)) 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 ) 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 ) draw.DrawText( txt, "GModWorldtip", pos.min.x + pos.size.w/2, yoffset + 9, white, TEXT_ALIGN_CENTER )
render.SetScissorRect( 0, 0, ScrW(), ScrH(), false ) render.SetScissorRect( 0, 0, ScrW(), ScrH(), false )
w_total = math.max( w_total, w ) w_total = math.max( w_total, w )
yoffset = yoffset + h yoffset = yoffset + h
surface.SetDrawColor( black ) surface.SetDrawColor( black )
surface.DrawLine( pos.min.x, yoffset, pos.max.x, yoffset ) surface.DrawLine( pos.min.x, yoffset, pos.max.x, yoffset )
------------------- -------------------
-- prfcount/benchmarking/etc -- prfcount/benchmarking/etc
------------------- -------------------
@ -165,41 +165,41 @@ function ENT:DrawWorldTipBody( pos )
local e2_hardquota = GetConVar("wire_expression2_quotahard"):GetInt() local e2_hardquota = GetConVar("wire_expression2_quotahard"):GetInt()
local e2_softquota = GetConVar("wire_expression2_quotasoft"):GetInt() local e2_softquota = GetConVar("wire_expression2_quotasoft"):GetInt()
-- fancy percent bar -- fancy percent bar
local w = pos.size.w - pos.edgesize * 2 local w = pos.size.w - pos.edgesize * 2
-- ops text -- ops text
local hardtext = (prfcount / e2_hardquota > 0.33) and "(+" .. tostring(math.Round(prfcount / e2_hardquota * 100)) .. "%)" or "" 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) 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 ) draw.DrawText( str, "GModWorldtip", pos.min.x + pos.size.w/2, yoffset + 9, white, TEXT_ALIGN_CENTER )
local _,h = surface.GetTextSize( str ) local _,h = surface.GetTextSize( str )
yoffset = yoffset + h + pos.edgesize yoffset = yoffset + h + pos.edgesize
-- fancy percent bar -- fancy percent bar
local softquota_width = w * 0.7 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 quota_width = softquota_width * math.min(prfbench/e2_softquota,1) + (w - softquota_width + 1) * (prfcount/e2_hardquota)
local y = yoffset local y = yoffset
surface.SetDrawColor( Color(0,170,0,255) ) surface.SetDrawColor( Color(0,170,0,255) )
surface.DrawRect( pos.min.x + pos.edgesize, y, softquota_width, 20 ) surface.DrawRect( pos.min.x + pos.edgesize, y, softquota_width, 20 )
surface.SetDrawColor( Color(170,0,0,255) ) surface.SetDrawColor( Color(170,0,0,255) )
surface.DrawRect( pos.min.x + pos.edgesize + softquota_width - 1, y, w - softquota_width + 2, 20 ) surface.DrawRect( pos.min.x + pos.edgesize + softquota_width - 1, y, w - softquota_width + 2, 20 )
surface.SetDrawColor( Color(0,0,0,200) ) surface.SetDrawColor( Color(0,0,0,200) )
surface.DrawRect( pos.min.x + pos.edgesize, y, quota_width, 20 ) surface.DrawRect( pos.min.x + pos.edgesize, y, quota_width, 20 )
surface.SetDrawColor( black ) 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, 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, 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 + 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 ) surface.DrawLine( pos.min.x + pos.edgesize, y + 20, pos.min.x + pos.edgesize, y )
yoffset = yoffset + 20 yoffset = yoffset + 20
-- cpu time text -- cpu time text
local str = string.format("cpu time: %ius", timebench*1000000) 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 ) 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) e2function angle round(angle rv1)
return { return {
floor(rv1[1] + 0.5), floor(rv1[1] + 0.5),
floor(rv1[2] + 0.5), floor(rv1[2] + 0.5),
floor(rv1[3] + 0.5) floor(rv1[3] + 0.5)
} }
end end
@ -230,16 +230,16 @@ end
e2function angle round(angle rv1, decimals) e2function angle round(angle rv1, decimals)
local shf = 10 ^ decimals local shf = 10 ^ decimals
return { return {
floor(rv1[1] * shf + 0.5) / shf, floor(rv1[1] * shf + 0.5) / shf,
floor(rv1[2] * 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
} }
end end
e2function angle ceil(angle rv1) e2function angle ceil(angle rv1)
return { return {
ceil(rv1[1]), ceil(rv1[1]),
ceil(rv1[2]), ceil(rv1[2]),
ceil(rv1[3]) ceil(rv1[3])
} }
end end
@ -247,16 +247,16 @@ end
e2function angle ceil(angle rv1, decimals) e2function angle ceil(angle rv1, decimals)
local shf = 10 ^ decimals local shf = 10 ^ decimals
return { return {
ceil(rv1[1] * shf) / shf, ceil(rv1[1] * shf) / shf,
ceil(rv1[2] * shf) / shf, ceil(rv1[2] * shf) / shf,
ceil(rv1[3] * shf) / shf ceil(rv1[3] * shf) / shf
} }
end end
e2function angle floor(angle rv1) e2function angle floor(angle rv1)
return { return {
floor(rv1[1]), floor(rv1[1]),
floor(rv1[2]), floor(rv1[2]),
floor(rv1[3]) floor(rv1[3])
} }
end end
@ -264,8 +264,8 @@ end
e2function angle floor(angle rv1, decimals) e2function angle floor(angle rv1, decimals)
local shf = 10 ^ decimals local shf = 10 ^ decimals
return { return {
floor(rv1[1] * shf) / shf, floor(rv1[1] * shf) / shf,
floor(rv1[2] * shf) / shf, floor(rv1[2] * shf) / shf,
floor(rv1[3] * shf) / shf floor(rv1[3] * shf) / shf
} }
end 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),"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!") chat.AddText(Color(255,0,0),"Don't trust a word you hear while in a seat after seeing this message!")
end end
chat.AddText(unpack(net.ReadTable())) chat.AddText(unpack(net.ReadTable()))
end) end)

View File

@ -16,7 +16,7 @@ end
local display_owners = false local display_owners = false
concommand.Add( "wire_holograms_display_owners", function() concommand.Add( "wire_holograms_display_owners", function()
display_owners = !display_owners display_owners = !display_owners
if display_owners then if display_owners then
hook.Add( "HUDPaint", "wire_holograms_showowners", WireHologramsShowOwners) hook.Add( "HUDPaint", "wire_holograms_showowners", WireHologramsShowOwners)
else else
hook.Remove("HUDPaint", "wire_holograms_showowners") 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 !isOwner(self, this) then return end
if this:IsPlayer() then return end if this:IsPlayer() then return end
local c = this:GetColor() local c = this:GetColor()
c.a = Clamp(a, 0, 255) c.a = Clamp(a, 0, 255)
this:SetColor(c) this:SetColor(c)
@ -92,7 +92,7 @@ e2function void entity:setRenderMode(mode)
if !IsValid(this) then return end if !IsValid(this) then return end
if !isOwner(self, this) then return end if !isOwner(self, this) then return end
if this:IsPlayer() then return end if this:IsPlayer() then return end
this:SetRenderMode(mode) this:SetRenderMode(mode)
end end
@ -151,9 +151,9 @@ local function Convert_hsl2rgb(h, s, l)
end end
local function Convert_rgb2hsl(r, g, b) local function Convert_rgb2hsl(r, g, b)
r = r / 255 r = r / 255
g = g / 255 g = g / 255
b = b / 255 b = b / 255
local max = math.max(r, g, b) local max = math.max(r, g, b)
local min = math.min(r, g, b) local min = math.min(r, g, b)
local h = (max + min) / 2 local h = (max + min) / 2

View File

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

View File

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

View File

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

View File

@ -6,4 +6,4 @@ usermessage.Hook("e2_remoteupload_request", function(um)
local str = file.Read("expression2/" .. filepath) local str = file.Read("expression2/" .. filepath)
WireLib.Expression2Upload(target, str, "expression2/" .. filepath) WireLib.Expression2Upload(target, str, "expression2/" .. filepath)
end 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["deleteWire(e:s)"] = "Unwires the specified input of the entity"
E2Helper.Descriptions["getWireInputs(e:)"] = "Returns array of all inputs 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["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 function CalcElasticConsts(Phys1, Phys2, Ent1, Ent2)
local minMass local minMass
if Ent1:IsWorld() then if Ent1:IsWorld() then
minMass = Phys2:GetMass() minMass = Phys2:GetMass()
elseif Ent2:IsWorld() then elseif Ent2:IsWorld() then
minMass = Phys1:GetMass() minMass = Phys1:GetMass()
else else
minMass = math.min( Phys1:GetMass(), Phys2:GetMass() ) minMass = math.min( Phys1:GetMass(), Phys2:GetMass() )
end end
local const = minMass * 100 local const = minMass * 100
local damp = const * 0.2 local damp = const * 0.2
return const, damp return const, damp
end end
// Note: Winch is just a rename of Hydraulic with the last parameter True. // 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) e2function void winch(index, entity ent1, vector v1, entity ent2, vector v2, width)
if !checkEnts(self, ent1, ent2) then return end if !checkEnts(self, ent1, ent2) then return end
if !ent1.data then ent1.data = {} end if !ent1.data then ent1.data = {} end
if !ent1.data.Ropes then ent1.data.Ropes = {} 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]) 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 width < 0 || width > 50 then width = 1 end
if IsValid(ent1.data.Ropes[index]) then if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove() ent1.data.Ropes[index]:Remove()
end end
local constant, dampen = CalcElasticConsts( ent1:GetPhysicsObject(), ent2:GetPhysicsObject(), ent1, ent2 ) 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 ) 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") addundo(self, ent1.data.Ropes[index], "winch")
end 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) e2function void hydraulic(index, entity ent1, vector v1, entity ent2, vector v2, width)
if !checkEnts(self, ent1, ent2) then return end if !checkEnts(self, ent1, ent2) then return end
if !ent1.data then ent1.data = {} end if !ent1.data then ent1.data = {} end
if !ent1.data.Ropes then ent1.data.Ropes = {} 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]) 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 width < 0 || width > 50 then width = 1 end
if IsValid(ent1.data.Ropes[index]) then if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove() ent1.data.Ropes[index]:Remove()
end end
local constant, dampen = CalcElasticConsts( ent1:GetPhysicsObject(), ent2:GetPhysicsObject(), ent1, ent2 ) 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 ) 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") addundo(self, ent1.data.Ropes[index], "hydraulic")
end 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) 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 checkEnts(self, ent1, ent2) then return end
if not ent1.data then ent1.data = {} end if not ent1.data then ent1.data = {} end
if not ent1.data.Ropes then ent1.data.Ropes = {} 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]) 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 width < 0 or width > 50 then width = 1 end
if IsValid(ent1.data.Ropes[index]) then if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove() ent1.data.Ropes[index]:Remove()
end end
@ -157,14 +157,14 @@ e2function void hydraulic(index, entity ent1, vector v1, entity ent2, vector v2,
addundo(self, ent1.data.Ropes[index], "hydraulic") addundo(self, ent1.data.Ropes[index], "hydraulic")
end 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) 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 checkEnts(self, ent1, ent2) then return end
if not ent1.data then ent1.data = {} end if not ent1.data then ent1.data = {} end
if not ent1.data.Ropes then ent1.data.Ropes = {} 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]) 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 width < 0 or width > 50 then width = 1 end
if IsValid(ent1.data.Ropes[index]) then if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove() ent1.data.Ropes[index]:Remove()
end 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 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 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() local length = (ent1:LocalToWorld(vec1) - ent2:LocalToWorld(vec2)):Length()
if IsValid(ent1.data.Ropes[index]) then if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove() ent1.data.Ropes[index]:Remove()
end end
ent1.data.Ropes[index] = constraint.Rope( ent1, ent2, 0, 0, vec1, vec2, length, 0, 0, 1, "cable/rope", false ) 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") addundo(self, ent1.data.Ropes[index], "rope")
end 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 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 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() local length = (ent1:LocalToWorld(vec1) - ent2:LocalToWorld(vec2)):Length()
if IsValid(ent1.data.Ropes[index]) then if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove() ent1.data.Ropes[index]:Remove()
end end
ent1.data.Ropes[index] = constraint.Rope( ent1, ent2, 0, 0, vec1, vec2, length, addlength, 0, width, mat, false ) 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") addundo(self, ent1.data.Ropes[index], "rope")
end 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 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 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() local length = (ent1:LocalToWorld(vec1) - ent2:LocalToWorld(vec2)):Length()
if IsValid(ent1.data.Ropes[index]) then if IsValid(ent1.data.Ropes[index]) then
ent1.data.Ropes[index]:Remove() ent1.data.Ropes[index]:Remove()
end end
ent1.data.Ropes[index] = constraint.Rope( ent1, ent2, 0, 0, vec1, vec2, length, addlength, 0, width, mat, tobool(rigid) ) 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") addundo(self, ent1.data.Ropes[index], "rope")
end end
@ -300,14 +300,14 @@ end
--- Nocollides <ent1> to <ent2> --- Nocollides <ent1> to <ent2>
e2function void noCollide(entity ent1, entity ent2) e2function void noCollide(entity ent1, entity ent2)
if !checkEnts(self, ent1, ent2) then return end 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 end
--- Nocollides <ent> to entities/players, just like Right Click of No-Collide Stool --- Nocollides <ent> to entities/players, just like Right Click of No-Collide Stool
e2function void noCollideAll(entity ent, state) e2function void noCollideAll(entity ent, state)
if !IsValid(ent) then return end if !IsValid(ent) then return end
if !isOwner(self, ent) then return false end if !isOwner(self, ent) then return false end
if state != 0 then if state != 0 then
ent:SetCollisionGroup( COLLISION_GROUP_WORLD ) ent:SetCollisionGroup( COLLISION_GROUP_WORLD )
else else
ent:SetCollisionGroup( COLLISION_GROUP_NONE ) ent:SetCollisionGroup( COLLISION_GROUP_NONE )
@ -334,10 +334,10 @@ e2function void entity:constraintBreak(entity ent2)
if !checkEnts(self, this, ent2) then return end if !checkEnts(self, this, ent2) then return end
local consts = this.Constraints local consts = this.Constraints
local consts2 = ent2.Constraints local consts2 = ent2.Constraints
if !consts then if !consts then
if !consts2 then return end if !consts2 then return end
consts = consts2 consts = consts2
end end
for _,v in pairs( consts ) do for _,v in pairs( consts ) do
if IsValid(v) then if IsValid(v) then
local CTab = v:GetTable() local CTab = v:GetTable()
@ -360,10 +360,10 @@ e2function void entity:constraintBreak(string type, entity ent2)
if !checkEnts(self, this, ent2) then return end if !checkEnts(self, this, ent2) then return end
local consts = this.Constraints local consts = this.Constraints
local consts2 = ent2.Constraints local consts2 = ent2.Constraints
if !consts then if !consts then
if !consts2 then return end if !consts2 then return end
consts = consts2 consts = consts2
end end
for _,v in pairs( consts ) do for _,v in pairs( consts ) do
if IsValid(v) then if IsValid(v) then
local CTab = v:GetTable() local CTab = v:GetTable()

View File

@ -10,11 +10,11 @@ local effect_blacklist = {
local function isAllowed( self ) local function isAllowed( self )
local data = self.data local data = self.data
if data.effect_burst == 0 then return false end if data.effect_burst == 0 then return false end
data.effect_burst = data.effect_burst - 1 data.effect_burst = data.effect_burst - 1
local timerid = "E2_effect_burst_count_" .. self.entity:EntIndex() local timerid = "E2_effect_burst_count_" .. self.entity:EntIndex()
if not timer.Exists( timerid ) then if not timer.Exists( timerid ) then
timer.Create( timerid, wire_expression2_effect_burst_rate:GetFloat(), 0, function() timer.Create( timerid, wire_expression2_effect_burst_rate:GetFloat(), 0, function()
@ -22,14 +22,14 @@ local function isAllowed( self )
timer.Remove( timerid ) timer.Remove( timerid )
return return
end end
data.effect_burst = data.effect_burst + 1 data.effect_burst = data.effect_burst + 1
if data.effect_burst == wire_expression2_effect_burst_max:GetInt() then if data.effect_burst == wire_expression2_effect_burst_max:GetInt() then
timer.Remove( timerid ) timer.Remove( timerid )
end end
end) end)
end end
return true return true
end end
@ -56,42 +56,42 @@ registerOperator("ass", "xef", "xef", function(self, args)
self.Scopes[scope].vclk[lhs] = true self.Scopes[scope].vclk[lhs] = true
return rhs return rhs
end) end)
e2function effect effect() e2function effect effect()
return EffectData() return EffectData()
end end
e2function effect effect:setOrigin(vector pos) e2function effect effect:setOrigin(vector pos)
if not this then return end if not this then return end
this:SetOrigin(Vector( pos[1], pos[2], pos[3] )) this:SetOrigin(Vector( pos[1], pos[2], pos[3] ))
return this return this
end end
e2function effect effect:setStart(vector pos) e2function effect effect:setStart(vector pos)
if not this then return end if not this then return end
this:SetStart(Vector( pos[1], pos[2], pos[3] )) this:SetStart(Vector( pos[1], pos[2], pos[3] ))
return this return this
end end
e2function effect effect:setMagnitude(number mag) e2function effect effect:setMagnitude(number mag)
if not this then return end if not this then return end
this:SetMagnitude(mag) this:SetMagnitude(mag)
return this return this
end end
e2function effect effect:setAngles(angle ang) e2function effect effect:setAngles(angle ang)
if not this then return end if not this then return end
this:SetAngles( Angle( ang[1] ,ang[2] ,ang[3] )) this:SetAngles( Angle( ang[1] ,ang[2] ,ang[3] ))
return this return this
end end
e2function effect effect:setScale(number scale) e2function effect effect:setScale(number scale)
if not this then return end if not this then return end
this:SetScale(scale) this:SetScale(scale)
return this return this
end end
@ -99,63 +99,63 @@ end
e2function effect effect:setEntity(entity ent) e2function effect effect:setEntity(entity ent)
if not this then return end if not this then return end
if not IsValid(ent) then return end if not IsValid(ent) then return end
this:SetEntity(ent) this:SetEntity(ent)
return this return this
end end
e2function effect effect:setNormal(vector norm) e2function effect effect:setNormal(vector norm)
if not this then return end if not this then return end
this:SetNormal(Vector( norm[1], norm[2], norm[3] )) this:SetNormal(Vector( norm[1], norm[2], norm[3] ))
return this return this
end end
e2function effect effect:setSurfaceProp(number prop) e2function effect effect:setSurfaceProp(number prop)
if not this then return end if not this then return end
this:SetSurfaceProp(prop) this:SetSurfaceProp(prop)
return this return this
end end
e2function effect effect:setRadius(number radius) e2function effect effect:setRadius(number radius)
if not this then return end if not this then return end
this:SetRadius(radius) this:SetRadius(radius)
return this return this
end end
e2function effect effect:setMaterialIndex(number index) e2function effect effect:setMaterialIndex(number index)
if not this then return end if not this then return end
this:SetMaterialIndex(index) this:SetMaterialIndex(index)
return this return this
end end
e2function effect effect:setHitBox(number index) e2function effect effect:setHitBox(number index)
if not this then return end if not this then return end
this:SetHitBox(index) this:SetHitBox(index)
return this return this
end end
e2function effect effect:setFlags(number flags) e2function effect effect:setFlags(number flags)
if not this then return end if not this then return end
this:SetFlags(flags) this:SetFlags(flags)
return this return this
end end
e2function effect effect:setEntIndex(number index) e2function effect effect:setEntIndex(number index)
if not this then return end if not this then return end
this:SetEntIndex(index) this:SetEntIndex(index)
return this return this
end end
e2function effect effect:setDamageType(number index) e2function effect effect:setDamageType(number index)
if not this then return end if not this then return end
this:SetDamageType(index) this:SetDamageType(index)
return this return this
end end
@ -169,7 +169,7 @@ end
e2function effect effect:setAttachment(number index) e2function effect effect:setAttachment(number index)
if not this then return end if not this then return end
this:SetAttachment(index) this:SetAttachment(index)
return this return this
end end
@ -179,12 +179,10 @@ e2function void effect:play(string name)
if not isAllowed(self) then return end if not isAllowed(self) then return end
if effect_blacklist[name] then return end if effect_blacklist[name] then return end
if hook.Run( "Expression2_CanEffect", name:lower(), self ) == false then return end if hook.Run( "Expression2_CanEffect", name:lower(), self ) == false then return end
util.Effect(name,this) util.Effect(name,this)
end end
registerCallback("construct", function(self) registerCallback("construct", function(self)
self.data.effect_burst = wire_expression2_effect_burst_max:GetInt() self.data.effect_burst = wire_expression2_effect_burst_max:GetInt()
end) 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 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 E2Lib.getOwner( self,this ) ~= self.player then return end
if not check(self.player) then return end if not check(self.player) then return end
timer.Simple( 0, function() timer.Simple( 0, function()
this:Setup( code, {}, nil, nil, "remoteSetCode" ) this:Setup( code, {}, nil, nil, "remoteSetCode" )
end ) end )
@ -42,7 +42,7 @@ e2function void entity:remoteSetCode( string main, table includes )
if not check(self.player) then return end if not check(self.player) then return end
local luatable = {} local luatable = {}
for k,v in pairs( includes.s ) do for k,v in pairs( includes.s ) do
self.prf = self.prf + 0.3 self.prf = self.prf + 0.3
if includes.stypes[k] == "s" then 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 ) error( "Non-string value given to remoteSetCode", 2 )
end end
end end
timer.Simple( 0, function() timer.Simple( 0, function()
this:Setup( main, luatable, nil, nil, "remoteSetCode" ) this:Setup( main, luatable, nil, nil, "remoteSetCode" )
end ) end )
@ -68,15 +68,15 @@ e2function table getCodeIncludes()
local _, includes = self.entity:GetCode() local _, includes = self.entity:GetCode()
local e2table = {n={},ntypes={},s={},stypes={},size=0} local e2table = {n={},ntypes={},s={},stypes={},size=0}
local size = 0 local size = 0
for k,v in pairs( includes ) do for k,v in pairs( includes ) do
size = size + 1 size = size + 1
e2table.s[k] = v e2table.s[k] = v
e2table.stypes[k] = "s" e2table.stypes[k] = "s"
end end
self.prf = self.prf + size * 0.3 self.prf = self.prf + size * 0.3
e2table.size = size e2table.size = size
return e2table return e2table
end end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -341,7 +341,7 @@ util.AddNetworkString("wire_expression2_file_begin")
net.Receive("wire_expression2_file_begin", function(netlen, ply) net.Receive("wire_expression2_file_begin", function(netlen, ply)
local pfile = uploads[ply] local pfile = uploads[ply]
if !pfile then return end if !pfile then return end
local len = net.ReadUInt(32) local len = net.ReadUInt(32)
if len == 0 then -- file not found 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 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] local pfile = uploads[ply]
if !pfile then return end if !pfile then return end
local path = args[1] local path = args[1]
if not file.Exists(path, "DATA") then if not file.Exists(path, "DATA") then
pfile.sp_wait = false pfile.sp_wait = false

View File

@ -809,7 +809,7 @@ e2function number findSortByDistance(vector position)
position = Vector(position[1], position[2], position[3]) position = Vector(position[1], position[2], position[3])
local findlist = self.data.findlist local findlist = self.data.findlist
self.prf = self.prf + #findlist * 12 self.prf = self.prf + #findlist * 12
local d = {} local d = {}
for i=1, #findlist do for i=1, #findlist do
local v = findlist[i] local v = findlist[i]
@ -829,7 +829,7 @@ __e2setcost(5)
local function applyClip(self, filter) local function applyClip(self, filter)
local findlist = self.data.findlist local findlist = self.data.findlist
self.prf = self.prf + #findlist * 5 self.prf = self.prf + #findlist * 5
filterList(findlist, filter) filterList(findlist, filter)
return #findlist 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. -- this additional step is needed because we cant modify registered_chips while it is being iterated.
local i = 1 local i = 1
for entity,_ in pairs(registered_chips) do for entity,_ in pairs(registered_chips) do
if entity:IsValid() then if entity:IsValid() then
ents[i] = entity ents[i] = entity
i = i + 1 i = i + 1
end end

View File

@ -261,7 +261,7 @@ registerCallback("postinit",function()
self:PopScope() self:PopScope()
end end
end end
end) end)
end -- allowed check 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 -- 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 elseif not pathLookup[model] and wire_holograms_modelany:GetInt() == 0 then
return false return false
end end
if wire_holograms_modelany:GetInt() ~= 2 and not WireLib.CanModel(self.player, model, skin) then 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 if table.Count(Holo.bone_scale) <= 0 then return {0,0,0} end
for bidx,b_scale in pairs(Holo.bone_scale) do 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 end
return {0,0,0} return {0,0,0}

View File

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

View File

@ -548,7 +548,7 @@ end
e2function quaternion lerp(quaternion q0, quaternion q1, number t, number reduceTo360) e2function quaternion lerp(quaternion q0, quaternion q1, number t, number reduceTo360)
local t1 = 1 - t local t1 = 1 - t
local dot = q0[1]*q1[1] + q0[2]*q1[2] + q0[3]*q1[3] + q0[4]*q1[4] local dot = q0[1]*q1[1] + q0[2]*q1[2] + q0[3]*q1[3] + q0[4]*q1[4]
if reduceTo360 and dot < 0 then if reduceTo360 and dot < 0 then
return ( qmul(q0, t1) + qmul(q1, -t) ) return ( qmul(q0, t1) + qmul(q1, -t) )
else 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 tracedata.endpos = tracedata.start + chip:GetUp()*range
end end
end end
-- clamp positions -- clamp positions
tracedata.start = E2Lib.clampPos( tracedata.start ) 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 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.mins = s1
tracedata.maxs = s2 tracedata.maxs = s2
end end
if not entities then -- unfortunately we have to add tons of ops if this happens 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. -- If we didn't, it would be possible to crash servers with it.
tracedata.mins = E2Lib.clampPos( tracedata.mins ) tracedata.mins = E2Lib.clampPos( tracedata.mins )

View File

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

View File

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

View File

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

View File

@ -130,9 +130,9 @@ end
local function luaDateToE2Table( time, utc ) local function luaDateToE2Table( time, utc )
local ret = {n={},ntypes={},s={},stypes={},size=0} local ret = {n={},ntypes={},s={},stypes={},size=0}
local time = os.date((utc and "!" or "") .. "*t",time) 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 if not time then return ret end -- this happens if you give it a negative time
for k,v in pairs( time ) do for k,v in pairs( time ) do
if k == "isdst" then if k == "isdst" then
ret.s.isdst = (v and 1 or 0) ret.s.isdst = (v and 1 or 0)
@ -141,10 +141,10 @@ local function luaDateToE2Table( time, utc )
ret.s[k] = v ret.s[k] = v
ret.stypes[k] = "n" ret.stypes[k] = "n"
end end
ret.size = ret.size + 1 ret.size = ret.size + 1
end end
return ret return ret
end end
__e2setcost(10) __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} 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) e2function number time(table data)
local args = {} local args = {}
for k,v in pairs( data.s ) do for k,v in pairs( data.s ) do
if data.stypes[k] ~= "n" or not validkeys[k] then continue end if data.stypes[k] ~= "n" or not validkeys[k] then continue end
if k == "isdst" then if k == "isdst" then
args.isdst = (v == 1) args.isdst = (v == 1)
else else
args[k] = v args[k] = v
end end
end end
return os.time( args ) return os.time( args )
end end

View File

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

View File

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

View File

@ -94,7 +94,7 @@ function ENT:UpdateOverlay(clear)
prfcount = self.context.prfcount, prfcount = self.context.prfcount,
timebench = self.context.timebench timebench = self.context.timebench
}) })
end end
end end
function ENT:Initialize() function ENT:Initialize()
@ -344,11 +344,11 @@ function ENT:ResetContext()
self.Inputs = WireLib.AdjustSpecialInputs(self, self.inports[1], self.inports[2]) self.Inputs = WireLib.AdjustSpecialInputs(self, self.inports[1], self.inports[2])
self.Outputs = WireLib.AdjustSpecialOutputs(self, self.outports[1], self.outports[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 if self.extended then -- It was extended before the adjustment, recreate the wirelink
WireLib.CreateWirelinkOutput( self.player, self, {true} ) WireLib.CreateWirelinkOutput( self.player, self, {true} )
end end
self._original = string.Replace(string.Replace(self.original, "\"", string.char(163)), "\n", string.char(128)) self._original = string.Replace(string.Replace(self.original, "\"", string.char(163)), "\n", string.char(128))
self._name = self.name 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") local self = ents.Create("gmod_wire_expression2")
if not self:IsValid() then return false end if not self:IsValid() then return false end
if buffer then self.duped = true end if buffer then self.duped = true end
self:SetModel(model) 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") buffer = string.Replace(string.Replace(buffer, string.char(163), "\""), string.char(128), "\n")
self.buffer = buffer self.buffer = buffer
self:SetOverlayText(name) self:SetOverlayText(name)
self.inc_files = inc_files or {} self.inc_files = inc_files or {}
self.Inputs = WireLib.AdjustSpecialInputs(self, inputs[1], inputs[2]) self.Inputs = WireLib.AdjustSpecialInputs(self, inputs[1], inputs[2])
self.Outputs = WireLib.AdjustSpecialOutputs(self, outputs[1], outputs[2]) self.Outputs = WireLib.AdjustSpecialOutputs(self, outputs[1], outputs[2])
self.dupevars = vars self.dupevars = vars
self.filepath = filepath self.filepath = filepath
else 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.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.inc_files = {}
self.dupevars = {} self.dupevars = {}
self.name = "generic" self.name = "generic"
end end
@ -615,16 +615,16 @@ duplicator.RegisterEntityClass("gmod_wire_expression2", MakeWireExpression2, "Po
-- Emergency shutdown (beta testing so far) -- Emergency shutdown (beta testing so far)
-------------------------------------------------- --------------------------------------------------
local average_ram = 0 local average_ram = 0
local enable = CreateConVar( local enable = CreateConVar(
"wire_expression2_ram_emergency_shutdown_enable", "0", {FCVAR_ARCHIVE}, "wire_expression2_ram_emergency_shutdown_enable", "0", {FCVAR_ARCHIVE},
"Enable/disable the emergency shutdown feature." ) "Enable/disable the emergency shutdown feature." )
local average_halt_multiplier = CreateConVar( local average_halt_multiplier = CreateConVar(
"wire_expression2_ram_emergency_shutdown_spike", "4", {FCVAR_ARCHIVE}, "wire_expression2_ram_emergency_shutdown_spike", "4", {FCVAR_ARCHIVE},
"if (current_ram > average_ram * spike_convar) then shut down all E2s" ) "if (current_ram > average_ram * spike_convar) then shut down all E2s" )
local halt_max_amount = CreateConVar( local halt_max_amount = CreateConVar(
"wire_expression2_ram_emergency_shutdown_total", "512", {FCVAR_ARCHIVE}, "wire_expression2_ram_emergency_shutdown_total", "512", {FCVAR_ARCHIVE},
"This is in kilobytes, if (current_ram > total_convar) then shut down all E2s" ) "This is in kilobytes, if (current_ram > total_convar) then shut down all E2s" )
local function enableEmergencyShutdown() local function enableEmergencyShutdown()
@ -662,4 +662,4 @@ local function enableEmergencyShutdown()
end end
enableEmergencyShutdown() 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.Purpose = "To control the player's view in a pod and output their mouse movements"
ENT.WireDebugName = "Eye Pod" ENT.WireDebugName = "Eye Pod"
if CLIENT then if CLIENT then
local enabled = false local enabled = false
local rotate90 = false local rotate90 = false
local freezePitch = true local freezePitch = true
@ -47,7 +47,7 @@ if CLIENT then
previousEnabled = false previousEnabled = false
end end
end) end)
return -- No more client return -- No more client
end end
@ -119,7 +119,7 @@ function ENT:Setup(DefaultToZero, RateOfChange, ClampXMin, ClampXMax, ClampYMin,
self.ClampYMax = ClampYMax self.ClampYMax = ClampYMax
self.ClampX = ClampX self.ClampX = ClampX
self.ClampY = ClampY self.ClampY = ClampY
self:UpdateOverlay() self:UpdateOverlay()
end end
@ -251,15 +251,15 @@ function ENT:TriggerInput(iname, value)
-- Change variables to reflect input -- Change variables to reflect input
if iname == "Enable" then if iname == "Enable" then
self.enabled = value ~= 0 self.enabled = value ~= 0
if self.enabled == false and self.DefaultToZero == 1 and (self.X ~= 0 or self.Y ~= 0) then if self.enabled == false and self.DefaultToZero == 1 and (self.X ~= 0 or self.Y ~= 0) then
self.X = 0 self.X = 0
self.Y = 0 self.Y = 0
WireLib.TriggerOutput( self, "X", 0 ) WireLib.TriggerOutput( self, "X", 0 )
WireLib.TriggerOutput( self, "Y", 0 ) WireLib.TriggerOutput( self, "Y", 0 )
WireLib.TriggerOutput( self, "XY", {0,0} ) WireLib.TriggerOutput( self, "XY", {0,0} )
end end
self:UpdateOverlay() self:UpdateOverlay()
elseif iname == "SetPitch" then elseif iname == "SetPitch" then
self.eyeAng = Angle(AngNorm90(value), self.eyeAng.y, self.eyeAng.r) self.eyeAng = Angle(AngNorm90(value), self.eyeAng.y, self.eyeAng.r)
@ -280,7 +280,7 @@ function ENT:TriggerInput(iname, value)
elseif iname == "UnfreezeYaw" then elseif iname == "UnfreezeYaw" then
self.freezeYaw = value == 0 self.freezeYaw = value == 0
end end
if IsValid(self.pod) and IsValid(self.driver) then if IsValid(self.pod) and IsValid(self.driver) then
self:updateEyePodState(self.enabled) self:updateEyePodState(self.enabled)
end end
@ -303,10 +303,10 @@ hook.Add("SetupMove", "WireEyePodMouseControl", function(ply, movedata)
if eyePod.enabled then if eyePod.enabled then
local cmd = ply:GetCurrentCommand() local cmd = ply:GetCurrentCommand()
local oldX = eyePod.X local oldX = eyePod.X
local oldY = eyePod.Y local oldY = eyePod.Y
--reset the output so it is not cumualative if you want the rate of change --reset the output so it is not cumualative if you want the rate of change
if eyePod.ShowRateOfChange == 1 then if eyePod.ShowRateOfChange == 1 then
eyePod.X = 0 eyePod.X = 0
@ -329,7 +329,7 @@ hook.Add("SetupMove", "WireEyePodMouseControl", function(ply, movedata)
-- Update outputs -- Update outputs
WireLib.TriggerOutput(eyePod, "X", eyePod.X) WireLib.TriggerOutput(eyePod, "X", eyePod.X)
WireLib.TriggerOutput(eyePod, "Y", eyePod.Y) WireLib.TriggerOutput(eyePod, "Y", eyePod.Y)
local XY_Vec = {eyePod.X, eyePod.Y} local XY_Vec = {eyePod.X, eyePod.Y}
WireLib.TriggerOutput(eyePod, "XY", XY_Vec) WireLib.TriggerOutput(eyePod, "XY", XY_Vec)
end end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -61,7 +61,7 @@ function ENT:OverrideVM()
surface.SetTexture(0) surface.SetTexture(0)
surface.SetDrawColor(0,0,0,120) surface.SetDrawColor(0,0,0,120)
surface.DrawRect(0,0,self.ScreenWidth,self.ScreenHeight) 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("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((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)) 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 local name, size = self.FontName[self.Font], self.FontSize
if not fontcache[name] or not fontcache[name][size] then if not fontcache[name] or not fontcache[name][size] then
if not fontcache[name] then fontcache[name] = {} end if not fontcache[name] then fontcache[name] = {} end
surface.CreateFont("WireGPU_"..name..size, { surface.CreateFont("WireGPU_"..name..size, {
font = name, font = name,
size = size, size = size,
@ -208,7 +208,7 @@ function VM:SetFont()
}) })
fontcache[name][size] = true fontcache[name][size] = true
end end
surface.SetFont("WireGPU_"..name..size) surface.SetFont("WireGPU_"..name..size)
end end
@ -584,7 +584,7 @@ function VM:HardReset()
-- Has initialized already -- Has initialized already
self.INIT = 0 self.INIT = 0
-- Reset async thread -- Reset async thread
self.AsyncState = nil self.AsyncState = nil
end end
@ -833,7 +833,7 @@ function VM:ReadString(address)
currentChar = self:ReadCell(address + charCount) currentChar = self:ReadCell(address + charCount)
-- Reading failed -- Reading failed
if not currentChar then if not currentChar then
return return
elseif currentChar > 0 and currentChar < 255 then elseif currentChar > 0 and currentChar < 255 then
charString = charString .. string.char(currentChar) charString = charString .. string.char(currentChar)
elseif currentChar ~= 0 then elseif currentChar ~= 0 then

View File

@ -117,7 +117,7 @@ function ENT:ReadCell(Address)
self:Interrupt(15,Address) self:Interrupt(15,Address)
return return
end end
if (Address < 0) or (Address >= self.RAMSize) then if (Address < 0) or (Address >= self.RAMSize) then
return nil return nil
else 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 (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 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 util.IsValidPhysicsObject(trace.Entity, trace.PhysicsBone) then return false end
if not gamemode.Call( "CanTool", self:GetPlayer(), trace, "weld" ) then return false end if not gamemode.Call( "CanTool", self:GetPlayer(), trace, "weld" ) then return false end
return true return true

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