keypress1 - keypress1 + 1
if keypress1 = 1 then highkey1()
elseif keypress = 2 then highkey2()
end
highkey1()
if keypress1 == 1 and high == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg larkspur smash high")
elseif keypress1 == 1 and trip == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg epteth trip")
elseif keypress1 == 1 and low == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg curare smash low")
elseif keypress1 == 1 and mid == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg smash mid")
elseif keypress1 == 1 and drive == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg curare drive")
else
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg smash mid")
end
end
highkey2()
if keypress1 == 2 and high == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg aconite smash high")
elseif keypress1 == 2 and trip == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg epteth trip")
elseif keypress1 == 2 and low == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg prefarar smash low")
elseif keypress1 == 2 and mid == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg smash mid")
elseif keypress1 == 2 and drive == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg prefarar drive")
else
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg smash mid")
end
end
ect
ect
ect
Comments
Even without knowing what this is actually supposed to do precisely, there are a number of pretty serious problems here.
- You look like you're trying to define functions on lines 6 and 34, but what you're actually doing is calling those functions. Rather than "highkey1()", you need "function highkey1 ()".
- LUA doesn't hoist function definitions, so having a call to highkey1() in line 2 is just going to result in the interpreter saying "I have no idea what highkey1 is yet", since your definition for highkey1 hasn't happened yet.
- You have a number of simple syntax errors, like on line 2 where you have = instead of ==.
- Your indentation is very nonstandard, which makes this a lot harder to read and understand.
Here's a pastebin of what I think you were trying to do, maintaining most of your program organization: http://pastebin.com/spTm2UhaThis is still a pretty poor design in a lot of ways.
- You're using a ton of global variables with short, generic names that might cause name collisions down the road when you write something new and forget you're already using the "high" global variable for something.
- I'm not sure why you're checking to see if keypress1 == 1 or keypress1 == 2 in the if-clauses since this script only calls highkey1 when keypress1 == 1 and only calls highkey2 when keypress1 == 2 anyway. Unless you're calling those functions in some other script, those tests are redundant.
- Whenever you have a ton of elseifs like this, you're basically just implementing a particularly clumsy table. Here, your highkey1 and highkey2 functions are basically implementing an even uglier table too.
- These variable names, like "keypress1" and "highkey1" are pretty terrible.
- This is going to redefine highkey1 and highkey2 every single time it's run. You probably want to put those function definitions in a script and only put the last seven lines into your actual alias/keybind.
What I imagine you actually want, ultimately, is something more like a table that relates attack number (your "keypress1") and high/low/etc (and maybe limb if you want to automate limb selection too) to a venom. Then you just have a function that adds 1 to your attack number, looks at the table to figure out what to do given that number and the high/low/etc, and concatenates the result onto the rest of the command that's always the same (the "clearqueue eqbal" and "queue add eqbal combination[...]"). If you want to see what a solution like that would look like, I'd be happy to show you.For one thing, I think the majority of the logic should be placed in a script seperate from your keybindings.
Something that does combination attacks for you.
Something like:
Where type would be slice or rend, limb would be the limb, venom the venom and shield would be high/low etc.
You'd then integrate this into keypresses using if statements to change shield/venom/shield based on the situation
Which is significantly cleaner, and easier to change whatever logic in all your keybindings/aliases when it comes to combination attacks. For instance you could prepend sending stand before every combination attack you simply modify that function instead of your 50 aliases.
But if you want to implement this sort of preprogrammed queue and automatically associate strikes with particular venoms, you ultimately want to use a table rather than using if statements like this. That'll be significantly easier to modify and extend too. I'll cook something up tomorrow and post it to give an idea of what that would look like.
You have a script with the following:
- Amranu's function (you might want to add defaults for the arguments, you can do that by adding a line before the send lines that looks like "type = type or "slice"").
- A table for your preprogrammed attack routine. To implement what you have here, the table will have two elements: one for the first keypress and one for the second. Each of those elements will be a table. Each of those subtables will contain five elements. Those five elements will be named high, trip, low, mid, and drive. The value of each element will be yet another table. Those subsubtables will have four elements each (or potentially less, if you go with defaults in the function in #1). The names of those elements will be type, limb, venom, shield and their values will be the values you want for that attack (e.g., "shield = "smash high"" or "venom = "larkspur""). So if your big table is called combinationRoutine, then combinationRoutine[1].low.venom will be "curare".
- A global variable to save which attack you're on. Something like attackNumber = attackNumber or 1.
- A global variable to save which shield strike you're set to. Something like shieldStrike = shieldStrike or "mid".
- A second function (with no arguments) that uses attackNumber and shieldStrike to get values from the table, then feeds them to Amranu's function. So, for instance it'll look at combinationRoutine[attackNumber].shieldStrike.venom" to find the appropriate venom to pass to Amranu's combination function. Then the last thing this function does is increment attackNumber and then test whether the combinationRoutine table has that element, otherwise set it back to 1 to reset the counter ("if not combinationRoutine[attackNumber] then attackNumber = 1 end").
Then you have aliases or keybinds that change the value of shieldStrike.Then you have an alias or keybind that calls the function in #5 to do the actual attack.
This way you keep all the logic in a script and your attack routine is actually just a very straightforward table (composed of nested tables). When you want to change the routine or extend it to a third attack or whatever, all you have to do is add to the table, rather than having to worry about the logic of if statements or messing with any of the functions. And if you want to have more than one routine, all you need is another table and another function like in 5.
You could clean this up even more, for instance by doing things in a slightly more object-oriented way, but that gets substantially more complicated if you're unfamiliar with the slightly deeper features of Lua.
(Also, just as a simple matter of courtesy, if you're asking people to help with something like this, which is inevitably going to be pretty complicated and time-consuming, maybe you should consider putting more effort into your question than "the time it took to copy and paste 2 keybindings I already have and add an if statement".)
keypress6 = keypress6 + 1 if keypress6 == 1 and high == 1 then venom = venomTree["dizziness"] attack = attackTree[1] elseif keypress6 == 2 and high == 1 then venom = venomTree["stupidity"] attack = attackTree[1] elseif keypress6 == 2 and low == 1 then venom = venomTree["paralysis"] attack = attackTree[2] else send("combination "..target.." slice smash") end else venomTree = { stupidity = "aconite", --focus/goldenseal dizziness = "larkspur", --focus/lobelia sensitivity = "prefarar", --hawthorn/kelp - asthma = "kalmia", -- kelp
paralysis = "curare", attackTree = { 1 = send("combination "..target.." slice "" ..venom.. "" "right leg" "smash high") 2 = send("combination "..target.." slice "" ..venom.. "" "right leg" "smash low") 3 4 5 6 ect ect ect
I figure something about like that should work, for the function, obviously it's not finished, but that's what did after I got home from the hospital last night. I'll probably work on it more this week some too.current version, totally not even close to being finished.
Replace it with:
keyCounter[num] = keyCounter[num] or 0
need to be using square brackets when referring to the keyCounter table, not parenthesis
the functions
function keyCounterFunction4()
keyCounter4 = keyCounter4 + 1
if keyCounter4 > 5
then keyCounter4 = 1
end
return keyCounter4
end
function keyCounterReset4()
keyCounter4 = 0
return keyCounter4
end
function keyCounterFunction6()
keyCounter6 = keyCounter6 + 1
if keyCounter6 > 5
then keyCounter6 = 1
end
return keyCounter6
end
function keyCounterReset6()
keyCounter6 = 0
return keyCounter6
end
function leftLeg()
if keyCounter4 == 1 and high == 1
then venom = vTab["c"]
elseif keyCounter4 == 2 and high == 1
then venom = vTab["a"]
elseif keyCounter4 == 3 and high == 1
then venom = vTab["k"]
elseif keyCounter4 == 4 and high == 1
then venom = vTab["k"]
elseif keyCounter4 == 5 and high == 1
then venom = vTab["a"]
elseif keyCounter4 == 1 and low == 1
then venom = vTab["c"]
elseif keyCounter4 == 2 and low == 1
then venom = vTab["h"]
elseif keyCounter4 == 3 and low == 1
then venom = vTab["i"]
elseif keyCounter4 == 4 and low == 1
then venom = vTab["c"]
elseif keyCounter4 == 5 and low == 1
then venom = vTab["i"]
elseif keyCounter4 == 1 and drive == 1
then venom = vTab["c"]
elseif keyCounter4 == 2 and drive == 1
then venom = vTab["a"]
elseif keyCounter4 == 3 and drive == 1
then venom = vTab["n"]
elseif keyCounter4 == 4 and drive == 1
then venom = vTab["n"]
elseif keyCounter4 == 5 and drive == 1
then venom = vTab["c"]
elseif keyCounter4 == 1 and trip == 1
then venom = vTab["m"]
elseif keyCounter4 == 2 and trip == 1
then venom = vTab["f"]
elseif keyCounter4 == 3 and trip == 1
then venom = vTab["m"]
elseif keyCounter4 == 4 and trip == 1
then venom = vTab["f"]
elseif keyCounter4 == 5 and trip == 1
then venom = vTab["m"]
elseif mid == 1
then venom = ""
else
vTab = {
a = "aconite",
b = "epseth",
c = "curare",
d = "darkshade",
e = "digitalis", --shyness
f = "gecko", --slickness
g = "euphorbia", --vomitting
h = "eurypteria", --recklessness
i = "vernalius", --weakness
j = "kalmia", --asthma
k = "larkspur", --dizziness
l = "monkshood", --disloyalty
m = "epteth", --shivel arms
n = "prefarar", --sensitivity
o = "notechis", --haemophilia
p = "vardrax", --addiction
q = "slike", --anorexia
r = "selarnia", --animal spirit disruption
s = "xentio", --clumsiness
}
end
end
function rightLeg()
if keyCounter6 == 1 and high == 1
then venom = vTab["c"]
elseif keyCounter6 == 2 and high == 1
then venom = vTab["k"]
elseif keyCounter6 == 3 and high == 1
then venom = vTab["a"]
elseif keyCounter6 == 4 and high == 1
then venom = vTab["a"]
elseif keyCounter6 == 5 and high == 1
then venom = vTab["k"]
elseif keyCounter6 == 1 and low == 1
then venom = vTab["c"]
elseif keyCounter6 == 2 and low == 1
then venom = vTab["h"]
elseif keyCounter6 == 3 and low == 1
then venom = vTab["c"]
elseif keyCounter6 == 4 and low == 1
then venom = vTab["i"]
elseif keyCounter6 == 5 and low == 1
then venom = vTab["c"]
elseif keyCounter6 == 1 and drive == 1
then venom = vTab["c"]
elseif keyCounter6 == 2 and drive == 1
then venom = vTab["a"]
elseif keyCounter6 == 3 and drive == 1
then venom = vTab["n"]
elseif keyCounter6 == 4 and drive == 1
then venom = vTab["n"]
elseif keyCounter6 == 5 and drive == 1
then venom = vTab["c"]
elseif keyCounter6 == 1 and trip == 1
then venom = vTab["m"]
elseif keyCounter6 == 2 and trip == 1
then venom = vTab["f"]
elseif keyCounter6 == 3 and trip == 1
then venom = vTab["m"]
elseif keyCounter6 == 4 and trip == 1
then venom = vTab["f"]
elseif keyCounter6 == 5 and trip == 1
then venom = vTab["m"]
elseif mid == 1
then venom = ""
else
vTab = {
a = "aconite",
b = "epseth",
c = "curare",
d = "darkshade",
e = "digitalis", --shyness
f = "gecko", --slickness
g = "euphorbia", --vomitting
h = "eurypteria", --recklessness
i = "vernalius", --weakness
j = "kalmia", --asthma
k = "larkspur", --dizziness
l = "monkshood", --disloyalty
m = "epteth", --shivel arms
n = "prefarar", --sensitivity
o = "notechis", --haemophilia
p = "vardrax", --addiction
q = "slike", --anorexia
r = "selarnia", --animal spirit disruption
s = "xentio", --clumsiness
}
end
end
function leftLegAttack()
if high == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg " ..venom.. " smash high")
elseif trip == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg " ..venom.. " trip")
elseif low == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg " ..venom.. " smash low")
elseif mid == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg smash mid")
elseif drive == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg " ..venom.. " drive")
else
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice left leg smash mid")
end
end
function rightLegAttack()
if high == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice right leg " ..venom.. " smash high")
elseif trip == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice right leg " ..venom.. " trip")
elseif low == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice right leg " ..venom.. " smash low")
elseif mid == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice right leg smash mid")
elseif drive == 1 then
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice right leg " ..venom.. " drive")
else
sendAll("clearqueue all",
"queue add eqbal combination " .. target .. " slice right leg smash mid")
end
end
and then what gets sent when I press like keypad+4 or keypad+6
keyCounterFunction4()
keyCounterReset6()
leftLeg()
leftLegAttack()
if trip == 0 then
trip = 1
high = 0
mid = 0
drive = 0
low = 0
cecho("<green>\nShield Trip Toggled On\n")
elseif
trip == 1 then
trip = 0
high = 0
mid = 0
drive = 0
low = 0
cecho("<red>\nShield Trip Toggled Off\n")
end
keyCounterReset4()
keyCounterReset6()
one of the toggles. just c/p and change the number if you want to remake it.