Blockland Forums > Modification Help
Provide Your Custom Scripts for Streamlining Development
<< < (2/4) > >>
Conan:

--- Quote from: Electrk.. on January 07, 2018, 05:20:31 AM ---removeWord()

--- End quote ---
exists but uses word index, not string

removeword as listed in torque console functions reference
PhantOS:
the only really useful snippets are the euler / axis scripts and port's within fov check
phflack:
and the keybind adding code
(the good one, not the crappy short ones)
Swollow:

--- Code: ---function rgbGradient(%step, %c1, %c2)
{
%r1 = getWord(%c1, 0);
%g1 = getWord(%c1, 1);
%b1 = getWord(%c1, 2);

%r2 = getWord(%c2, 0);
%g2 = getWord(%c2, 1);
%b2 = getWord(%c2, 2);

%r3 = %r1 + %step * (%r2 - %r1);
%g3 = %g1 + %step * (%g2 - %g1);
%b3 = %b1 + %step * (%b2 - %b1);

return %r3 SPC %g3 SPC %b3;
}
function rgbToHex( %rgb )
{
%r = _compToHex( 255 * getWord( %rgb, 0 ) );
%g = _compToHex( 255 * getWord( %rgb, 1 ) );
%b = _compToHex( 255 * getWord( %rgb, 2 ) );

return %r @ %g @ %b;
}
function _compToHex( %comp )
{
%left = mFloor( %comp / 16 );
%comp = mFloor( %comp - %left * 16 );

%left = getSubStr( "0123456789ABCDEF", %left, 1 );
%comp = getSubStr( "0123456789ABCDEF", %comp, 1 );

return %left @ %comp;
}

function hexToRgb( %rgb )
{
%r = _hexToComp( getSubStr( %rgb, 0, 2 ) ) / 255;
%g = _hexToComp( getSubStr( %rgb, 2, 2 ) ) / 255;
%b = _hexToComp( getSubStr( %rgb, 4, 2 ) ) / 255;

return %r SPC %g SPC %b;
}
function _hexToComp(%hex)
{
%left = getSubStr(%hex,0,1);
%comp = getSubStr(%hex,1,2);

%left = striPos("0123456789ABCDEF",%left);
%comp = striPos("0123456789ABCDEF",%comp);

if(%left < 0 || %comp < 0)
{
return 0;
}

return %left * 16 + %comp;
}
--- End code ---




--- Code: ---function vectorAngleRotate(%vec,%ref,%ang)
{
%x = getWord(%vec,0);
%y = getWord(%vec,1);
%z = getWord(%vec,2);
%u = getWord(%ref,0);
%v = getWord(%ref,1);
%w = getWord(%ref,2);
%cos = mCos(%ang);
%sin = mSin(%ang);
return %u*(%u*%x+%v*%y+%w*%z)*(1-%cos)+%x*%cos+(%v*%z-%w*%y)*%sin SPC %u*(%u*%x+%v*%y+%w*%z)*(1-%cos)+%y*%cos+(%w*%x-%u*%z)*%sin SPC %u*(%u*%x+%v*%y+%w*%z)*(1-%cos)+%z*%cos+(%u*%y-%v*%x)*%sin;
}
function player::getUpVectorHack(%pl)
{
%muz = MatrixMulVector(%pl.getSlotTransform(0),"0 1 0");
%forward = %pl.getForwardVector();
%up = %pl.getUpVector();
return vectorAngleRotate(%muz,vectorCross(%forward,%up),$PI/2);
}
function player::getEyeVectorHack(%pl)
{
    %forward = %pl.getForwardVector();
    %eye = %pl.getEyeVector();

    %x = getWord(%eye, 0);
    %y = getWord(%eye, 1);

    %yaw = mATan(getWord(%forward,0),getWord(%forward,1));
    %pitch = mATan(getWord(%eye,2),mSqrt(%x*%x+%y*%y));

    return MatrixMulVector(MatrixCreateFromEuler(%pitch SPC 0 SPC -%yaw),"0 1 0");
}
function vectorRelativeShift(%forward,%up,%shift)
{
return vectorAdd(vectorAdd(vectorScale(%forward,getWord(%shift,0)),vectorScale(vectorCross(%forward,%up),getWord(%shift,1))),vectorScale(%up,getWord(%shift,2)));
}
--- End code ---

i don't leave home without these functions

credit to my ex wife port and old friend amade
PhantOS:
can you commentate the vector functions because they're really confusing and its unclear on what they return. the names give some guess but already im confused on how geteyevectorhack is any different from the default geteye vector
Navigation
Message Index
Next page
Previous page

Go to full version