Author Topic: Help with keybind...?  (Read 899 times)

This is a copy from FunkyTemp, could you make the text bold where the Keybind part is please?

Code: [Select]
if(!$FunkyTempBindings)
{
   $remapDivision[$remapCount] = "Funky Temp Brick";
   $remapName[$remapCount] = "Activate/Deacticate";
   $remapCmd[$remapCount] = "FunkyTempToggle";
   $remapCount++;
   $FunkyTempBindings = true;
}

$FunkyTempCount = 0;
$FunkyTempFlag = 0;
$FunkyTempORed = $pref::HUD::tempBrickOutsideRed;
$FunkyTempOGreen = $pref::HUD::tempBrickOutsideGreen;
$FunkyTempOBlue = $pref::HUD::tempBrickOutsideBlue;
$FunkyTempIRed = $pref::HUD::tempBrickInsideRed;
$FunkyTempIGreen = $pref::HUD::tempBrickInsideGreen;
$FunkyTempIBlue = $pref::HUD::tempBrickInsideBlue;
function FunkyTempToggle(%nobitches)
{
    if(!%nobitches)
    {
       return;
    }
    if($FunkyTempFlag == 0)
    {
        $FunkyTempFlag = 1;
        $FunkyTempORed = $pref::HUD::tempBrickOutsideRed;
        $FunkyTempOGreen = $pref::HUD::tempBrickOutsideGreen;
        $FunkyTempOBlue = $pref::HUD::tempBrickOutsideBlue;
        $FunkyTempIRed = $pref::HUD::tempBrickInsideRed;
        $FunkyTempIGreen = $pref::HUD::tempBrickInsideGreen;
        $FunkyTempIBlue = $pref::HUD::tempBrickInsideBlue;
        $FunkyTempIUsePaint = $pref::HUD::tempBrickInsideUsePaintColor;
        $FunkyTempOUsePaint = $pref::HUD::tempBrickOutsideUsePaintColor;
        $pref::HUD::tempBrickInsideUsePaintColor = 0;
        $pref::HUD::tempBrickOutsideUsePaintColor = 0;
        updateTempBrickSettings();
        FunkyTempLoop();
    }
    else if($FunkyTempFlag == 1)
    {
        $FunkyTempFlag = 0;
        cancel($FunkyTemp);
        $pref::HUD::tempBrickInsideRed = $FunkyTempIRed;
        $pref::HUD::tempBrickInsideGreen = $FunkyTempIGreen;
        $pref::HUD::tempBrickInsideBlue = $FunkyTempIBlue;
        $pref::HUD::tempBrickOutsideRed = $FunkyTempORed;
        $pref::HUD::tempBrickOutsideGreen = $FunkyTempOGreen;
        $pref::HUD::tempBrickOutsideBlue = $FunkyTempOBlue;
        $pref::HUD::tempBrickInsideUsePaintColor = $FunkyTempIUsePaint;
        $pref::HUD::tempBrickOutsideUsePaintColor = $FunkyTempOUsePaint;
        updateTempBrickSettings();
    }
}

function FunkyTempLoop()
{
        if($FunkyTempCount > 63)
        {
           $FunkyTempCount=0;
        }
        $R=0.5+0.5*mSin($FunkyTempCount*3.14/16.0);
        $G=0.5+0.5*mSin($FunkyTempCount*3.14/16.0+21.0);
        $B=0.5+0.5*mSin($FunkyTempCount*3.14/16.0+42.0);
        $pref::HUD::tempBrickInsideRed = $R;
        $pref::HUD::tempBrickInsideGreen = $G;
        $pref::HUD::tempBrickInsideBlue = $B;
        $pref::HUD::tempBrickOutsideRed = $R;
        $pref::HUD::tempBrickOutsideGreen = $G;
        $pref::HUD::tempBrickOutsideBlue = $B;
        updateTempBrickSettings();
        $FunkyTempCount++;
        $FunkyTemp = schedule(100,0,FunkyTempLoop);
}

AND! make A EG for a CMD Bindkey eg. please.

Code: [Select]
if(!$FunkyTempBindings)
{
   $remapDivision[$remapCount] = "Funky Temp Brick";
   $remapName[$remapCount] = "Activate/Deacticate";
   $remapCmd[$remapCount] = "FunkyTempToggle";
   $remapCount++;
   $FunkyTempBindings = true;
}
This code creates a new category in the Options menu called "Funky Temp Brick" with one keybind in it for "Activate/Deactivate". The variable $FunkyTempBindings is set to prevent the category from being added twice.

Code: [Select]
function FunkyTempToggle(%nobitches)
{
    if(!%nobitches)
    {
       return;
    }
    // Main contents of function here
}
When you press the specific key you set, the function "FunkyTempToggle" is called with one argument (handily called "%nobitches" by whoever made the Add-On, but it can be anything) which is 1 when you first press it and 0 when you release it. This is so the main code is only called once - otherwise you'd have to hold down the key to keep the Funky Temp Brick on as releasing it would call the rest of the function again and turn it off each time.

Edit the names of the functions and variables to suit your needs. Make sure you replace $FunkyTempBindings in particular as leaving that could break either of the two Add-Ons if people have them installed.

Code: [Select]
if(!$FunkyTempBindings)
{
   $remapDivision[$remapCount] = "TestNub";
   $remapName[$remapCount] = "TryTry";
   $remapCmd[$remapCount] = "TESTTESTe";
   $remapCount++;
   $FunkyTempBindings = true;
}

function FunkyTempToggle(%nobitches)
{
    if(!%nobitches)
    {
       return;
    }
    CommandToServer("Reloadbricks")
}

Right, eh? Correct if wrong.

Code: [Select]
if(!$FunkyTempBindings)
{
   $remapDivision[$remapCount] = "TestNub";
   $remapName[$remapCount] = "TryTry";
   $remapCmd[$remapCount] = "TESTTESTe";
   $remapCount++;
   $FunkyTempBindings = true;
}

function FunkyTempToggle(%nobitches)
{
    if(!%nobitches)
    {
       return;
    }
    CommandToServer("Reloadbricks")
}

Right, eh? Correct if wrong.
The command it is trying to call is "TESTTESTe", but you've defined the function as "FunkyTempToggle". If it had called that, the code would have had a syntax error and the command needs single quotes. (Tagged strings and stuff, it's a server command) You also didn't replace the bindings part so it might not even be calling any of this.

Try this:
Code: [Select]
if(!$HaylordCommandBinds)
{
   $remapDivision[$remapCount] = "Haylord's Commands";
   $remapName[$remapCount] = "Reload Bricks (Admin Only)";
   $remapCmd[$remapCount] = "serverReloadBricks";
   $remapCount++;
   $HaylordCommandBinds = true;
}

function serverReloadBricks(%val)
{
    if(!%val)
    {
       return;
    }
    CommandToServer('Reloadbricks'); //You missed the semicolon out off the end
}

Nope, unknown command !

:

if(!$HaylordCommandBinds)
{
   $remapDivision[$remapCount] = "Haylord's Commands";
   $remapName[$remapCount] = "Reload Bricks (Admin Only)";
   $remapCmd[$remapCount] = "serverReloadBricks";
   $remapCount++;
   $HaylordCommandBinds = true;
}

function serverReloadBricks(%val)
{
    if(!%val)
    {
       return;
    }
    CommandToServer('Reloadbricks'); //You missed the semicolon out off the end

You're missing a } at the end