The KGB Oracle
Posted By: JetStar Debug Ligitech script help - 03/04/10 12:49 AM
keyArray = {
{ -- Profile 1
[6] = {"ctrl+O", "crtl+P"}
},
{ -- Profile 2
},
{ -- Profile 3
}
};

indexes = {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};
lastGkey = 0;
lastMacro = 0;

function OnEvent(event, arg)
if (event=="G_PRESSED" and arg ~=1) then
pushKey(arg);
end
end

function pushKey(gkey)
-- gets key name
-- we check if the last gkey used was the same, if yes, cycle
if(lastGkey > 0 and lastGkey == gkey) then
indexes[profile][gkey] = indexes[profile][gkey] + 1;
if(indexes[profile][gkey] > table.getn(keyArray[profile][gkey])) then
indexes[profile][gkey] = 1;
end
end
lastGkey = gkey;
i = indexes[profile][gkey];
keyString = keyArray[profile][gkey][i];

-- we get modifiers to use
toCtrl = 0;
toAlt = 0;
toShift = 0;
if(string.find(keyString, "ctrl")) then
toCtrl = 1;
end
if(string.find(keyString, "alt")) then
toAlt = 1;
end
if(string.find(keyString, "shift")) then
toShift = 1;
end

-- now, we clean the key string to extract only the key
keyString = string.gsub(keyString, "ctrl", "");
keyString = string.gsub(keyString, "alt", "");
keyString = string.gsub(keyString, "shift", "");
keyString = string.gsub(keyString, "\+", "");
key = string.gsub(keyString, " ", "");
-- check if shift is already pushed
isSprint = IsModifierPressed("shift");

-- if needed release or press shift key
if((toCtrl == 1 or toAlt == 1) and isSprint and toShift == 0) then
ReleaseKey("lshift");
elseif(not isSprint and toShift == 1) then
PressKey("lshift");
end

-- press modifiers
if toCtrl == 1 then
PressKey("lctrl");
end
if toAlt == 1 then
PressKey("lalt");
end

-- press and release key
PressAndReleaseKey(key);

-- release modifiers
if toCtrl == 1 then
ReleaseKey("lctrl");
end
if toAlt == 1 then
ReleaseKey("lalt");
end

-- release or press shift if it was pressed before
if((toCtrl == 1 or toAlt == 1) and isSprint and toShift == 0) then
PressKey("lshift");
elseif(not isSprint and toShift == 1) then
ReleaseKey("lshift");
end
end
Posted By: Tasorin Re: Debug Ligitech script help - 03/04/10 12:57 AM
Are you getting a compile error, or is it not running, or are you getting an error script when you run it?

If your getting an error script, screen shot it and paste it in here.

Also I noticed, maybe its because of the paste, but no indentation, no nested "if" with corrisdoponding "EndIf" just "End", and if your trying to complete multiple functions in a boolean string you want to be using "ElseIf" or "Else"

Like conceptually, Do this, if this is done, else then do that, else that is done, then go back to this.
Posted By: Ictinike Re: Debug Ligitech script help - 03/04/10 02:13 AM
Yea Tas it wasn't working however I found he typo'ed on the binding at the top and used "crtl-P" instead of "ctrl+P" however while that fixed the script it still wasn't working..

Jet had an older version of the software too and others had issues with the scripts working on old version so he was updating before I had to leave vent.

Hopefully it worked out and be back ingame/vent soon.
Posted By: JetStar Re: Debug Ligitech script help - 03/04/10 10:10 PM
I upgraded and still nothing :-(

HELP
© The KGB Oracle