How do I pass multiple parameters into a Variable?



  • I am trying to use one units position to get the enemies in AoE range of the tank (8 yards).

    I have tried a few different methods but can't seem to understand how to interpret the documentation I have looked on github on the API and on the framework docs but I can't seem to find any examples or enough information on how to use them. Here is what I am trying:

                function get_enemy_count()
                    --env:execute_action("move", {-157.9, -497.3, 15.8}) --this works fine
                    local count
                    local tank_x, tank_y, tank_z = wmbapi.ObjectPosition(main_tank)
                    --print("Tank at position :[", tank_x, ",", tank_y, ",", tank_z, "]") -- this also works fine
    
                    -- Which of these methods should I use?
                    local position = "{" .. tank_x .. "," .. tank_y .. "," .. tank_z .. "}"
                    local position = "[" .. tank_x .. "," .. tank_y .. "," .. tank_z .. "]"
                    local position = ""..tank_x..","..tank_y..","..tank_z..""
                    local position = {tank_x, tank_y, tank_z}
                    local position = ""..tank_x..".center_"..tank_y..".center_"..tank_z..""
                    local enemies = env:evaluate_variable("npcs.attackable.range_8.center_" .. position) -- Find everyone within 8 yards of tank
                    if (enemies == nil) then
                        count = 0
                    else
                        -- print(enemies)
                        count = tonumber(enemies)
                    end
                    return count
                end
    

    If anyone has any ideas please let me know 🙂

    For reference here is the variable I'm trying to read:

    variable: npcs.[attackable|assistable|all].[center_X,Y,Z]
    returns: number
    description: NPC filter by distance of D yards from the center {X,Y,Z}. Use myself by default.

    and
    variable: npcs.[attackable|assistable|all].[range_D]
    returns: number
    description: NPC filter by distance of D yards.



  • From my testing I believe it might actually just be:

     local position = {tank_x, tank_y, tank_z}
    

    but I still don't have it working. I'll post back when it is.



  • Yes I feel the documentation is a tad bit lost in translation at times but I'm sure titan can explain.



  • The syntax is very straightforward:

    npcs.[attackable|assistable|all].[FILTER1].[FILTER2]...
    npcs.[attackable|assistable|all].[range_D]
    npcs.[attackable|assistable|all].[center_X,Y,Z]
    npcs.[attackable|assistable|all].[models_ID1,ID2]
    npcs.[attackable|assistable|all].[is_attacking_me]
    

    So you can combine the 4 filters as you wish. Such as:

    npcs.attackable.models_123,456.range_15.center_123,456,789 means that you are searching for attackable NPCs within 15 yards of the center position {123,456,789}, whose model IDs are either 123 or 456. You can add/remove any filter of the four as you wish.

    As for your Lua, it is all a matter of combining the string which is totally up to you.

    Under the hood, these framework variables are all based on GetNpcCount and GetNpcWithIndex API, along with some BLZ API to check those filter properties. You can always use raw API to achieve the same and even more results.



  • Ah right! Thanks, I was confused by the sudden switch from . to ,
    I thought [center_X,Y,Z] meant something like "an optional center_X, an optional center_Y or an optional center_Z" not that you could combine , and . in the same argument.

    Thanks for the explanation too, I am still trying to work out how to get information about who I am in combat with, and those methods should be really helpful for solving that too.