Results 1 to 7 of 7

Thread: Whats wrong with this action?

  1. #1
    Normal User jesusz0r's Avatar
    Join Date
    Jun 2012
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    17
    Rep Power
    5

    Whats wrong with this action?

    PHP Code:
    local players getcreatures("pfs")
    local random math.random(1,3)

    for 
    i=0#players do
        
    if (target.hppc <= 30 and target.id ~= 0then
            
    if (players[i].posx == posx-1) and players[i].count 0 then
                
    if random == 1 then turn('w')
                elseif 
    random == 2 then turn('s')
                elseif 
    random == 3 then turn('n'end
            
    elseif (players[i].posx == posx+1) and players[i].count 0 then
                
    if random == 1 then turn('e')
                elseif 
    random == 2 then turn('s')
                elseif 
    random == 3 then turn('n'end
            
    elseif (players[i].posy == posy-1) and players[i].count 0 then
                
    if random == 1 then turn('w')
                elseif 
    random == 2 then turn('e')
                elseif 
    random == 3 then turn('n'end
            
    elseif (players[i].posy == posy+1) and players[i].count 0 then
                
    if random == 1 then turn('w')
                elseif 
    random == 2 then turn('s')
                elseif 
    random == 3 then turn('e'end
            end
        end
    end 
    It's suppose to turn to a different direction if someoen is in front of you while your target is 30% hp or less!
    Last edited by jesusz0r; 08-23-2012 at 10:12 PM.

  2. #2
    Focus Group mexicowss's Avatar
    Join Date
    May 2012
    Location
    Brasil
    Posts
    440
    Mentioned
    20 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    59 Post(s)
    Reputation
    128
    Rep Power
    6
    Well im not sure but last time i tried to do this hotkey filters like 'pfs' was not working fine
    so i gave up using filters and finished with this
    works poorly, also kinda bugged

    PHP Code:
    if paround(2) and target.hppc 50 then
    if iscreatureontile(posx+1posyposz) == true then
    turn
    ("w")
    elseif 
    iscreatureontile(posx-1posyposz) == true then
    turn
    ("e")
    elseif 
    iscreatureontile(posxposy-1posz) == true then
    turn
    ("s")
    elseif 
    iscreatureontile(posxposy+1posz) == true then
    turn
    ("n")
    elseif 
    iscreatureontile(posxposy+1posz) == true then
    turn
    ("n")
    elseif 
    iscreatureontile(posx+1posy-1posz) == true then
    turn
    ("w")
    elseif 
    iscreatureontile(posx+1posy+1posz) == true then
    turn
    ("w")
    elseif 
    iscreatureontile(posx-1posy+1posz) == true then
    turn
    ("e")
    elseif 
    iscreatureontile(posx-1posy-1posz) == true then
    turn
    ("e")
    end
    end 
    Last edited by mexicowss; 08-22-2012 at 09:16 PM.
    click the image below to see my thread.



  3. #3
    Normal User jesusz0r's Avatar
    Join Date
    Jun 2012
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    17
    Rep Power
    5
    That will turn to the other side even if the creature is a monster :S

  4. #4
    Focus Group mexicowss's Avatar
    Join Date
    May 2012
    Location
    Brasil
    Posts
    440
    Mentioned
    20 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    59 Post(s)
    Reputation
    128
    Rep Power
    6
    yes it was a lot of time ago, thats why i said filters didnt work for me(i failed) when i tried
    aswell im not dat good with lua, maybe some improvement?
    Last edited by mexicowss; 08-22-2012 at 09:27 PM.
    click the image below to see my thread.



  5. #5
    Focus Group mexicowss's Avatar
    Join Date
    May 2012
    Location
    Brasil
    Posts
    440
    Mentioned
    20 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    59 Post(s)
    Reputation
    128
    Rep Power
    6
    btw, this is what i got as error on debug

    21:19 : LUA:PersistentAction - LuaInterface.LuaScriptException: [string "chunk"]:5: 'then' expected near ')'

    its strange, because looks like all 'then' and 'end' are correctly placed

    @edit just noticed its missing one '(' on 5th line
    and now the error is this
    21:30 : LUA:PersistentAction - LuaInterface.LuaScriptException: [string "chunk"]:4: attempt to get length of local 'players' (a userdata value)
    maybe its not recognize the filter as counting numbers to use inside for
    Last edited by mexicowss; 08-22-2012 at 09:34 PM.
    click the image below to see my thread.



  6. #6
    Normal User jesusz0r's Avatar
    Join Date
    Jun 2012
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    17
    Rep Power
    5
    yea my bad, thats not the one im using in my script, is one i created while making the post XD

  7. #7
    Focus Group mexicowss's Avatar
    Join Date
    May 2012
    Location
    Brasil
    Posts
    440
    Mentioned
    20 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    59 Post(s)
    Reputation
    128
    Rep Power
    6
    If you finish it and maybe u want to share with us.
    let me know please.
    thanks in advance
    click the image below to see my thread.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •