Forums » Community Projects
It's annoying when your turbo shuts off, but your bind stays on "ON" mode. If you tell your guy to turbo, this plugin rapidly checks to see if your energy suddenly starts increasing. In such a situation, it turns off, because you probably ran out of energy, and the game forced you to stop turboing. Since it tweaks with your wgaf.cfg, it has options to reinstall all the aliases it uses, uninstall any aliases, or "deinstall", which involves writing it to be the same as Eldrad's original bind. Credit to Eldrad for the original bind which I shamelessly edited.
Megaupload
MyntX=Timer();declare("ttog",{...});function reinstallttog() gkinterface.GKProcessCommand("alias mt '+turbo 0';alias -t 'mt';alias +t '+turbo; alias -t mt';alias acti 'Activate';alias ttog 'ttog1';alias ttog5 '+turbo 0;ttog4';alias ttog6 'Activate; ttog2';alias ttog0 ' ';alias ttog2 'ttog5; alias ttog ttog1; alias acti Activate; alias -t mt; alias mt ttog5; echo Turbo OFF';alias ttog1 'ttog3;+turbo; alias ttog ttog2; alias acti ttog6; alias -t ttog0; alias mt ttog2; echo Turbo ON'") end;reinstallttog();function deinstallttog() gkinterface.GKProcessCommand("alias ttog1 '+turbo; alias ttog ttog2; alias acti ttog6; alias -t ttog0; alias mt ttog2; echo Turbo ON';alias ttog2 '+turbo 0; alias ttog ttog1; alias acti Activate; alias -t mt; alias mt ttog2; echo Turbo OFF';") end;function uninstallttog() gkinterface.GKProcessCommand("alias ttog ' ';alias ttog1 ' ';alias ttog2 ' ';alias ttog5 ' ';alias ttog6 ' ';alias ttog0 ' ';alias +t ' ';alias -t ' ';alias mt ' ';alias acti ' '") end;function TurboOn() if ttog[1]~=nil then MyntX:SetTimeout(50, function() TurboOn() end); if ttog[2]<GetActiveShipEnergy() then gkinterface.GKProcessCommand("ttog2") end end;ttog[2]=GetActiveShipEnergy() end;RegisterUserCommand("ttog3", function() ttog[1]=1;ttog[2]=GetActiveShipEnergy();TurboOn() end);function ttoghelp() print("reinstallttog - Rewrites your binds for automatic shut off.");print("deinstallttog - Returns your binds to the default turbo lock settings.");print("uninstallttog - Removes all binds used for turbo lock.");print("+t - Normal Turbo.");print("ttog - Toggle turbo lock.");print("acti - Activate. Default key is enter.") end;RegisterUserCommand("ttog4", function() ttog[1]=nil end);RegisterUserCommand("reinstallttog", function() reinstallttog() end);RegisterUserCommand("deinstallttog", function() deinstallttog() end);RegisterUserCommand("uninstallttog", function() uninstallttog() end);RegisterUserCommand("ttoghelp", function() ttoghelp() end);print("autottog v1.1 - type /ttoghelp for a list of commands. Original bind by Eldrad.")
Megaupload
MyntX=Timer();declare("ttog",{...});function reinstallttog() gkinterface.GKProcessCommand("alias mt '+turbo 0';alias -t 'mt';alias +t '+turbo; alias -t mt';alias acti 'Activate';alias ttog 'ttog1';alias ttog5 '+turbo 0;ttog4';alias ttog6 'Activate; ttog2';alias ttog0 ' ';alias ttog2 'ttog5; alias ttog ttog1; alias acti Activate; alias -t mt; alias mt ttog5; echo Turbo OFF';alias ttog1 'ttog3;+turbo; alias ttog ttog2; alias acti ttog6; alias -t ttog0; alias mt ttog2; echo Turbo ON'") end;reinstallttog();function deinstallttog() gkinterface.GKProcessCommand("alias ttog1 '+turbo; alias ttog ttog2; alias acti ttog6; alias -t ttog0; alias mt ttog2; echo Turbo ON';alias ttog2 '+turbo 0; alias ttog ttog1; alias acti Activate; alias -t mt; alias mt ttog2; echo Turbo OFF';") end;function uninstallttog() gkinterface.GKProcessCommand("alias ttog ' ';alias ttog1 ' ';alias ttog2 ' ';alias ttog5 ' ';alias ttog6 ' ';alias ttog0 ' ';alias +t ' ';alias -t ' ';alias mt ' ';alias acti ' '") end;function TurboOn() if ttog[1]~=nil then MyntX:SetTimeout(50, function() TurboOn() end); if ttog[2]<GetActiveShipEnergy() then gkinterface.GKProcessCommand("ttog2") end end;ttog[2]=GetActiveShipEnergy() end;RegisterUserCommand("ttog3", function() ttog[1]=1;ttog[2]=GetActiveShipEnergy();TurboOn() end);function ttoghelp() print("reinstallttog - Rewrites your binds for automatic shut off.");print("deinstallttog - Returns your binds to the default turbo lock settings.");print("uninstallttog - Removes all binds used for turbo lock.");print("+t - Normal Turbo.");print("ttog - Toggle turbo lock.");print("acti - Activate. Default key is enter.") end;RegisterUserCommand("ttog4", function() ttog[1]=nil end);RegisterUserCommand("reinstallttog", function() reinstallttog() end);RegisterUserCommand("deinstallttog", function() deinstallttog() end);RegisterUserCommand("uninstallttog", function() uninstallttog() end);RegisterUserCommand("ttoghelp", function() ttoghelp() end);print("autottog v1.1 - type /ttoghelp for a list of commands. Original bind by Eldrad.")
Newlines for the win.
What for? So you can reverse engineer it? I already told you precisely how it works;If you have any suggestions and you can't deal with semicolons, let me know and I'll make a v1.1.
So I can actually understand it and maybe help you improve it? :p
Also, your link is broke.
Also, your link is broke.
Heh, 'reverse engineer', more like to rewrite sanely :D
declare("ttog",{...})
function reinstallttog() gkinterface.GKProcessCommand("alias mt '+turbo 0';alias -t 'mt';alias +t '+turbo; alias -t mt';alias acti 'Activate';alias ttog 'ttog1';alias ttog5 '+turbo 0;ttog4';alias ttog6 'Activate; ttog2';alias ttog0 ' ';alias ttog2 'ttog5; alias ttog ttog1; alias acti Activate; alias -t mt; alias mt ttog5; echo Turbo OFF';alias ttog1 'ttog3;+turbo; alias ttog ttog2; alias acti ttog6; alias -t ttog0; alias mt ttog2; echo Turbo ON'") end
reinstallttog()
function deinstallttog() gkinterface.GKProcessCommand("alias ttog1 '+turbo; alias ttog ttog2; alias acti ttog6; alias -t ttog0; alias mt ttog2; echo Turbo ON';alias ttog2 '+turbo 0; alias ttog ttog1; alias acti Activate; alias -t mt; alias mt ttog2; echo Turbo OFF';") end
function uninstallttog() gkinterface.GKProcessCommand("alias ttog ' ';alias ttog1 ' ';alias ttog2 ' ';alias ttog5 ' ';alias ttog6 ' ';alias ttog0 ' ';alias +t ' ';alias -t ' ';alias mt ' ';alias acti ' '") end
function TurboOn() if ttog[1]~=nil then MyntX:SetTimeout(50, function() TurboOn() end); if ttog[2]<GetActiveShipEnergy() then gkinterface.GKProcessCommand("ttog2") end end;ttog[2]=GetActiveShipEnergy() end
RegisterUserCommand("ttog3", function() ttog[1]=1;ttog[2]=GetActiveShipEnergy();TurboOn() end)
function ttoghelp() print("reinstallttog - Rewrites your binds for automatic shut off.");print("deinstallttog - Returns your binds to the default turbo lock settings.");print("uninstallttog - Removes all binds used for turbo lock.");print("+t - Normal Turbo.");print("ttog - Toggle turbo lock.");print("acti - Activate. Default key is enter.") end
RegisterUserCommand("ttog4", function() ttog[1]=nil end)
RegisterUserCommand("reinstallttog", function() reinstallttog() end)
RegisterUserCommand("deinstallttog", function() deinstallttog() end)
RegisterUserCommand("uninstallttog", function() uninstallttog() end)
RegisterUserCommand("ttoghelp", function() ttoghelp() end);print("autottog v1.0 - type /ttoghelp for a list of commands. Original bind by Eldrad.")
function reinstallttog() gkinterface.GKProcessCommand("alias mt '+turbo 0';alias -t 'mt';alias +t '+turbo; alias -t mt';alias acti 'Activate';alias ttog 'ttog1';alias ttog5 '+turbo 0;ttog4';alias ttog6 'Activate; ttog2';alias ttog0 ' ';alias ttog2 'ttog5; alias ttog ttog1; alias acti Activate; alias -t mt; alias mt ttog5; echo Turbo OFF';alias ttog1 'ttog3;+turbo; alias ttog ttog2; alias acti ttog6; alias -t ttog0; alias mt ttog2; echo Turbo ON'") end
reinstallttog()
function deinstallttog() gkinterface.GKProcessCommand("alias ttog1 '+turbo; alias ttog ttog2; alias acti ttog6; alias -t ttog0; alias mt ttog2; echo Turbo ON';alias ttog2 '+turbo 0; alias ttog ttog1; alias acti Activate; alias -t mt; alias mt ttog2; echo Turbo OFF';") end
function uninstallttog() gkinterface.GKProcessCommand("alias ttog ' ';alias ttog1 ' ';alias ttog2 ' ';alias ttog5 ' ';alias ttog6 ' ';alias ttog0 ' ';alias +t ' ';alias -t ' ';alias mt ' ';alias acti ' '") end
function TurboOn() if ttog[1]~=nil then MyntX:SetTimeout(50, function() TurboOn() end); if ttog[2]<GetActiveShipEnergy() then gkinterface.GKProcessCommand("ttog2") end end;ttog[2]=GetActiveShipEnergy() end
RegisterUserCommand("ttog3", function() ttog[1]=1;ttog[2]=GetActiveShipEnergy();TurboOn() end)
function ttoghelp() print("reinstallttog - Rewrites your binds for automatic shut off.");print("deinstallttog - Returns your binds to the default turbo lock settings.");print("uninstallttog - Removes all binds used for turbo lock.");print("+t - Normal Turbo.");print("ttog - Toggle turbo lock.");print("acti - Activate. Default key is enter.") end
RegisterUserCommand("ttog4", function() ttog[1]=nil end)
RegisterUserCommand("reinstallttog", function() reinstallttog() end)
RegisterUserCommand("deinstallttog", function() deinstallttog() end)
RegisterUserCommand("uninstallttog", function() uninstallttog() end)
RegisterUserCommand("ttoghelp", function() ttoghelp() end);print("autottog v1.0 - type /ttoghelp for a list of commands. Original bind by Eldrad.")
Heh, slowly breaking?
Few more days and you'll add all the newlines? :D
Or even *gasp* indent? ;)
Few more days and you'll add all the newlines? :D
Or even *gasp* indent? ;)
I think it's worth asking what the point is of making a plugin that does nothing but gkinterface.GKProcessCommand. It's not worth the effort -- if all you're going to do is use GKProcessCommand without actually using Lua for anything important you would be just as well off sticking with the alias/bind syntax built into VO.
RegisterUserCommand("uninstallttog", function() uninstallttog() end)
This is insane. If you are going to call a function from a function and provide no other code then just assign it to the 2nd function to begin with and not use needless and wasteful constructs.
gkinterface.GKProcessCommand("alias mt '+turbo 0';alias -t 'mt';alias +t '+turbo; alias -t mt';alias acti 'Activate';alias ttog 'ttog1';alias ttog5 '+turbo 0;ttog4';alias ttog6 'Activate; ttog2';alias ttog0 ' ';alias ttog2 'ttog5; alias ttog ttog1; alias acti Activate; alias -t mt; alias mt ttog5; echo Turbo OFF';alias ttog1 'ttog3;+turbo; alias ttog ttog2; alias acti ttog6; alias -t ttog0; alias mt ttog2; echo Turbo ON'")
??WHY?? Lua offers many diverse ways to reach the same goals with out having to pass everything to gki.
This is insane. If you are going to call a function from a function and provide no other code then just assign it to the 2nd function to begin with and not use needless and wasteful constructs.
gkinterface.GKProcessCommand("alias mt '+turbo 0';alias -t 'mt';alias +t '+turbo; alias -t mt';alias acti 'Activate';alias ttog 'ttog1';alias ttog5 '+turbo 0;ttog4';alias ttog6 'Activate; ttog2';alias ttog0 ' ';alias ttog2 'ttog5; alias ttog ttog1; alias acti Activate; alias -t mt; alias mt ttog5; echo Turbo OFF';alias ttog1 'ttog3;+turbo; alias ttog ttog2; alias acti ttog6; alias -t ttog0; alias mt ttog2; echo Turbo ON'")
??WHY?? Lua offers many diverse ways to reach the same goals with out having to pass everything to gki.
it's obfuscated lua! leave it the way it is!
First of, thankyou all for your excellent commments and questions about my (yes MY mwahahaha!) lil' plugin.
To maq, I don't understand new lines, or indenting or any of that crap. What I do understand is scripting, i.e. do this, then this then this etc. Thus. Additionally, I'm loathe to include copious 'wasteful constructs', as so elegantly described by our resident Lua expert, blacknet.
Miharu, that is an superb question. I'm sorry that I don't have an answer, as a plugin that strictly used methods which could be duplicated by binding could of course be more simply done with a bind. I fail to see how that is related to this plugin however, which utilizes the mighty power of Lua to GetActiveShipEnergy() and the more accurate timer.
blacknet, you might note that "uninstalltog" is not a function, as opposed to uninstalltog(). "uninstalltog" is a string, that when input calls the function by the same name, which does Lua stuff. Thus, the purpose is to do Lua stuff with slash commands, which would be explained to you in not so many words if you ran it up, noticed the "type /ttoghelp for a list of commands" on your chat log, and went ahead and followed those directions.
As for the drawn out gkinterface block I used, I'm interested in how I could attain that same goal, but am skeptical that you actually know what you're talking about when you thought that stuff inside quotes denoted functions. Please prove me wrong.
firsm; obfuscated it may be, but it is solid. (Again, please prove me wrong via trying it, and reporting bugs, feedback and that sort of thing.)
To maq, I don't understand new lines, or indenting or any of that crap. What I do understand is scripting, i.e. do this, then this then this etc. Thus. Additionally, I'm loathe to include copious 'wasteful constructs', as so elegantly described by our resident Lua expert, blacknet.
Miharu, that is an superb question. I'm sorry that I don't have an answer, as a plugin that strictly used methods which could be duplicated by binding could of course be more simply done with a bind. I fail to see how that is related to this plugin however, which utilizes the mighty power of Lua to GetActiveShipEnergy() and the more accurate timer.
blacknet, you might note that "uninstalltog" is not a function, as opposed to uninstalltog(). "uninstalltog" is a string, that when input calls the function by the same name, which does Lua stuff. Thus, the purpose is to do Lua stuff with slash commands, which would be explained to you in not so many words if you ran it up, noticed the "type /ttoghelp for a list of commands" on your chat log, and went ahead and followed those directions.
As for the drawn out gkinterface block I used, I'm interested in how I could attain that same goal, but am skeptical that you actually know what you're talking about when you thought that stuff inside quotes denoted functions. Please prove me wrong.
firsm; obfuscated it may be, but it is solid. (Again, please prove me wrong via trying it, and reporting bugs, feedback and that sort of thing.)
oh, there's nothing to understand. It's just to make it easier to read and all.
Personally i don't care how you write your plugins.
If you got it to do what you wanted to, that's fine.
Personally i don't care how you write your plugins.
If you got it to do what you wanted to, that's fine.
local function stuff(unused, blah)
if not blah then print("you suck") return end
local cmd = blah[1]:lower()
if cmd == "stop" then
stopfunc()
elseif cmd == "go" then
startfunc()
else
print("you suck")
end
end
RegisterUserCommand("blah", stuff)
if not blah then print("you suck") return end
local cmd = blah[1]:lower()
if cmd == "stop" then
stopfunc()
elseif cmd == "go" then
startfunc()
else
print("you suck")
end
end
RegisterUserCommand("blah", stuff)
I would really like to understand it though, because it limits my ability to read other people's work. Basically, I get that ; = new line. What does the indenting represent? Is it just there for style, or does it have some effect on the mechanics? As I try and decipher slime's incredibly witty insult, I see that it might be either/or. I can't decide because I don't know what that script does.
If you could explain things with an operationlist mind set, that would be a large help.
If you could explain things with an operationlist mind set, that would be a large help.
It's about 100000000000x easier to understand the code and insert/delete things.
By the way, that code makes 2 commands: /blah go and /blah stop.
By the way, that code makes 2 commands: /blah go and /blah stop.
ok assuming you aren't playing stupid and hoping answering won't make me look stupid:
newline is just enter in the code, it's not equivalent to ;
in fact lua doesn't require using ;'s. (or newlines for that matter, but it's much easier to read the code with them.)
so generally you put one command per line. sometimes more, like slimes first 'if'.
as for indent it's putting tabs or spaces in front of some parts of the code, generally the ones that are inside other statements.
it also makes it much easier to read, as you can easily see for example what is inside a function and where it ends.
and no it doesn't directly affect how it'll run, tho it'll make it easier to find errors so, you might say it does affect things indirectly.
newline is just enter in the code, it's not equivalent to ;
in fact lua doesn't require using ;'s. (or newlines for that matter, but it's much easier to read the code with them.)
so generally you put one command per line. sometimes more, like slimes first 'if'.
as for indent it's putting tabs or spaces in front of some parts of the code, generally the ones that are inside other statements.
it also makes it much easier to read, as you can easily see for example what is inside a function and where it ends.
and no it doesn't directly affect how it'll run, tho it'll make it easier to find errors so, you might say it does affect things indirectly.
Long story short -- if you want help on your code from other people, you need to make it so that they can read it. Most people who you ask to help will not spend their time wading through a single block of prose-like code trying to piece it out, nor are they normally going to go to the effort of copypasting the code and adding linebreaks on their own. If you want help, you need to make an effort to make your code accessible to those you want help from.
Thankyou maq.
And I hope new users aren't intimidated by insane coding style; I've used this exact plugin since day one, and have had no errors, or heard of any thus far. I assure you that if Miharu, slime or anybody else can't read it, the computer and I, at least, are just dandy on the issue. ;)
And I hope new users aren't intimidated by insane coding style; I've used this exact plugin since day one, and have had no errors, or heard of any thus far. I assure you that if Miharu, slime or anybody else can't read it, the computer and I, at least, are just dandy on the issue. ;)
Heh, they can read it, prolly.
They just can't be arsed to ;P
They just can't be arsed to ;P