help with logic ect...

  1. keypress1 - keypress1 + 1
  2. if keypress1 = 1 then highkey1()
  3.         elseif keypress = 2 then highkey2()
  4. end
  5.  
  6. highkey1()
  7.         if keypress1 == 1 and high == 1 then
  8.         sendAll("clearqueue all",
  9.         "queue add eqbal combination " .. target .. " slice left leg larkspur smash high")
  10.                
  11.                 elseif keypress1 == 1 and trip == 1 then
  12.                 sendAll("clearqueue all",
  13.                 "queue add eqbal combination " .. target .. " slice left leg epteth trip")
  14.                
  15.                 elseif keypress1 == 1 and low == 1 then
  16.                 sendAll("clearqueue all",
  17.         "queue add eqbal combination " .. target .. " slice left leg curare smash low")
  18.                
  19.                 elseif keypress1 == 1 and mid == 1 then
  20.         sendAll("clearqueue all",
  21.                 "queue add eqbal combination " .. target .. " slice left leg smash mid")
  22.                
  23.                 elseif keypress1 == 1 and drive == 1 then
  24.                 sendAll("clearqueue all",
  25.                 "queue add eqbal combination " .. target .. " slice left leg curare drive")
  26.        
  27.         else
  28.         sendAll("clearqueue all",
  29.     "queue add eqbal combination " .. target .. " slice left leg smash mid")
  30.  
  31. end
  32. end
  33.  
  34. highkey2()
  35.  
  36. if keypress1 == 2 and high == 1 then
  37.         sendAll("clearqueue all",
  38.         "queue add eqbal combination " .. target .. " slice left leg aconite smash high")
  39.                
  40.                 elseif keypress1 == 2 and trip == 1 then
  41.                 sendAll("clearqueue all",
  42.                 "queue add eqbal combination " .. target .. " slice left leg epteth trip")
  43.  
  44.                 elseif keypress1 == 2 and low == 1 then
  45.                 sendAll("clearqueue all",
  46.                 "queue add eqbal combination " .. target .. " slice left leg prefarar smash low")
  47.  
  48.                 elseif keypress1 == 2 and mid == 1 then
  49.                 sendAll("clearqueue all",
  50.                 "queue add eqbal combination " .. target .. " slice left leg smash mid")
  51.  
  52.                 elseif keypress1 == 2 and drive == 1 then
  53.                 sendAll("clearqueue all",
  54.                 "queue add eqbal combination " .. target .. " slice left leg prefarar drive")
  55.  
  56.         else
  57.         sendAll("clearqueue all",
  58.         "queue add eqbal combination " .. target .. " slice left leg smash mid")
  59. end
  60. end
  61.  
  62. ect
  63. ect
  64. ect

Comments

  • i know its supposed to be keypress1 = keypress + 1 then I also need something to reset it like if keypress1 > 5 then keypress1 = 0 

  • edited May 2015
    This is profoundly opaque. You should probably explain what it should do (ideally in detail). You should also probably say what client you're using - I'm guessing this is supposed to be LUA, but it's easier if you just say so, and it can be hard to tell what language it's supposed to be when there are significant syntax errors.

    Even without knowing what this is actually supposed to do precisely, there are a number of pretty serious problems here.
    1. 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 ()".
    2. 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.
    3. You have a number of simple syntax errors, like on line 2 where you have = instead of ==.
    4. 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/spTm2Uha

    This is still a pretty poor design in a lot of ways.
    1. 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.
    2. 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.
    3. 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.
    4. These variable names, like "keypress1" and "highkey1" are pretty terrible.
    5. 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.
  • oh I seriously put that together in the time it took to copy and paste 2 keybindings I already have and add an if statement.  I was more or less wondering how to go about doing it the most efficient way. Basically I'm thinking about rewriting my snb offensive. just throwing around ideas heh

  • edited May 2015
    I really don't like this code for a variety of reasons.

    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:

    function combination(type, limb, venom, shield)
    send("clearqueue eqbal")
    send("queue add eqbal combination "..target.." "..type.." "..limb.." "..venom.." "..shield)
    end

    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

    keybind1 
    if situation1 then
    combination("slice", limb, "curare", "high")
    elseif situation2 then
    combination("slice", limb, "prefarer", "low")
    end

    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.

  • Amranu said:
    I really don't like this code for a variety of reasons.

    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:

    function combination(type, limb, venom, shield)
    send("clearqueue eqbal")
    send("queue add eqbal combination "..target.." "..type.." "..limb.." "..venom.." "..shield)
    end

    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

    keybind1 
    if situation1 then
    combination("slice", limb, "curare", "high")
    elseif situation2 then
    combination("slice", limb, "prefarer", "low")
    end

    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.

    Yeah, a combination function like that is definitely a better solution.

    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.
  • edited May 2015
    I don't have a convenient text editor right now, but the gist of the idea is this:

    You have a script with the following:
    1. 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"").
    2. 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".
    3. A global variable to save which attack you're on. Something like attackNumber = attackNumber or 1.
    4. A global variable to save which shield strike you're set to. Something like shieldStrike = shieldStrike or "mid".
    5. 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".)
    1. keypress6 = keypress6 + 1
    2.  
    3. if keypress6 == 1 and high == 1 then
    4.  
    5.                 venom = venomTree["dizziness"]
    6.                 attack = attackTree[1]
    7.         elseif
    8.  
    9.                 keypress6 == 2 and high == 1 then
    10.  
    11.                 venom = venomTree["stupidity"]
    12.                 attack = attackTree[1]
    13.                 elseif
    14.  
    15.                 keypress6 == 2 and low == 1 then
    16.  
    17.                 venom = venomTree["paralysis"]
    18.                 attack = attackTree[2]
    19.         else
    20.                 send("combination "..target.." slice smash")
    21.        end
    22. else
    23.      
    24.        venomTree = {
    25.                stupidity      = "aconite",                               --focus/goldenseal
    26.                dizziness      = "larkspur",                              --focus/lobelia
    27.                sensitivity     = "prefarar",                             --hawthorn/kelp
    28.                 asthma         = "kalmia",                                    -- kelp
    29.                 paralysis       = "curare",    
    30.                
    31.        
    32.                 attackTree = {
    33.                                 1 = send("combination "..target.." slice "" ..venom.. "" "right leg"  "smash high")
    34.                                 2 = send("combination "..target.." slice "" ..venom.. "" "right leg"  "smash low")
    35.                                 3
    36.                                 4
    37.                                 5
    38.                                 6
    39.                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. 

    1. keyCounter = {} -- Key Counting Variable
    2.  
    3.  
    4. function keyCounter(num) -- Function for updating the key counting variable
    5.         keyCounter(num) = 0
    6.         keyCounter(num) = keyCounter(num) + 1
    7.         if keyCounter(num) >= 5
    8.                                 then keyCounter(num) = 0
    9.                                 end
    10.                 return keyCounter(num)
    11. end
    12.  
    13. Function leftLeg() -- Function for selection venoms based on keypress
    14.  
    15. if keyCounter(4) == 1 and high == 1
    16.                 then venom = "curare"
    17.         elseif keyCounter(4) == 2 and high == 1
    18.                 then venom = "aconite"
    19.         elseif keyCounter(4) == 3 and high == 1
    20.                 then venom = "larkspur"
    21.         elseif keyCounter(4) == 4 and high == 1
    22.                 then venom = "larkspur"
    23.         elseif keyCounter(4) == 5 and high == 1
    24.                 then venom = "aconite"
    25.         end
    26. end
    27. ------------------------------------------------------------------
    28. keyCounterFunction(4)
    29. leftLeg()
    30. sendAll("clearqueue all",
    31. "queue add eqbal combination " .. target .. " slice left leg " ..venom..  " smash high")


    current version, totally not even close to being finished. 




  • edited May 2015
    Remove keyCounter[num] = 0 from the start of your keyCounter function - this will always make the function return 1

    Replace it with:

    keyCounter[num] = keyCounter[num] or 0

    need to be using square brackets when referring to the keyCounter table, not parenthesis
  • I know the code is ugly, but everything works. 

    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. 


Sign In or Register to comment.