Author Topic: Script for two keybinds?  (Read 1296 times)

I need a script for two keybinds.
I want to script on my own, I'll try not to post these anymore.
« Last Edit: May 19, 2013, 12:08:51 PM by Setro »

Code: [Select]
if(!$YourAddonHasBinds)
{
$remapdivision[$remapcount] = "Your Addon Title";
$remapname[$remapcount] = "Do Something";
$remapcmd[($remapcount++)-1] = "myFunction1";

$remapdivision[$remapcount] = "Your Addon Title";
$remapname[$remapcount] = "Do Something Else";
$remapcmd[($remapcount++)-1] = "myFunction2";

$YourAddonHasBinds = 1;
}

function myFunction1(%val)
{
echo("Did something!");
}

function myFunction2(%val)
{
echo("Did something else!");
}
Make one of the 3 line paragraphs for every bind you want, the if check is so when someone gets the idea to execute your add-on 2 times it doesn't double the bindings.
The function get's called when the key is pressed, and when it is released. %val is 1 when the key is pressed and 0 when it is released, the rest should be self-explanatory

Code: [Select]
if(!$YourAddonHasBinds)
{
$remapdivision[$remapcount] = "Your Addon Title";
$remapname[$remapcount] = "Do Something";
$remapcmd[($remapcount++)-1] = "myFunction1";

$remapdivision[$remapcount] = "Your Addon Title";
$remapname[$remapcount] = "Do Something Else";
$remapcmd[($remapcount++)-1] = "myFunction2";

$YourAddonHasBinds = 1;
}

function myFunction1(%val)
{
echo("Did something!");
}

function myFunction2(%val)
{
echo("Did something else!");
}
Make one of the 3 line paragraphs for every bind you want, the if check is so when someone gets the idea to execute your add-on 2 times it doesn't double the bindings.
The function get's called when the key is pressed, and when it is released. %val is 1 when the key is pressed and 0 when it is released, the rest should be self-explanatory
Thanks

Code: [Select]
if(!$YourAddonHasBinds)
{
$remapdivision[$remapcount] = "Your Addon Title";
$remapname[$remapcount] = "Do Something";
$remapcmd[($remapcount++)-1] = "myFunction1";

$remapdivision[$remapcount] = "Your Addon Title";
$remapname[$remapcount] = "Do Something Else";
$remapcmd[($remapcount++)-1] = "myFunction2";

$YourAddonHasBinds = 1;
}

function myFunction1(%val)
{
echo("Did something!");
}

function myFunction2(%val)
{
echo("Did something else!");
}
Make one of the 3 line paragraphs for every bind you want, the if check is so when someone gets the idea to execute your add-on 2 times it doesn't double the bindings.
The function get's called when the key is pressed, and when it is released. %val is 1 when the key is pressed and 0 when it is released, the rest should be self-explanatory
EDIT: Oh! I think i understand now! Thanks!
« Last Edit: May 19, 2013, 12:11:05 PM by Setro »

You actually should only include the $remapdivision[$remapcount] = "Your Addon Title"; once. Doing it again will create multiple categories with the same name.

Where would I learn about keybinds? I want to make something toggle able...
Like say I wanted to make a keybind to jet forever... and then I use the same keybind
to make it stop.

Where would I learn about keybinds? I want to make something toggle able...
Like say I wanted to make a keybind to jet forever... and then I use the same keybind
to make it stop.
If the first variable in the function called is true then the key was pushed. If it's false then the key was released. jet(1); will make you jet forever or until the jet key is released and jet(0); will stop you from jetting.

If the first variable in the function called is true then the key was pushed. If it's false then the key was released. jet(1); will make you jet forever or until the jet key is released and jet(0); will stop you from jetting.
I know that, but put it in a keybind
and make it toggleable.

You would do something like this:
Code: [Select]
if(!$YourAddonHasBinds)
{
$remapdivision[$remapcount] = "Your Addon Title";
$remapname[$remapcount] = "Toggle Something";
$remapcmd[($remapcount++)-1] = "toggleSOmething";

$YourAddonHasBinds = 1;
}

function toggleSomething(%val)
{
if(!%val) return;
$toggleSomething = !$toggleSomething;
if($toggleSomething)
{
echo("On");
}
else
{
echo("Off");
}
}
Press button to turn it on, press button again to turn it off