Jump to content

Loop through java array


Kenneth

Recommended Posts

I want to loop through the values of IsoFlagType[]

IsoFlagType:values() --This returns a userdata 

Since that returns lua userdata how would I go about looping through array since the IsoFlagType.lua says it returns array of IsoFlagType[]

 

---@public
---@return IsoFlagType[]
function IsoFlagType:values() end
Link to comment
Share on other sites

I still don't know how to loop through IsoFlagType:values() but I did found a workaround.

local function getIsoFlag(propertyContainer)
    for i, value in pairs(IsoFlagType) do
        if value and type(value) == "userdata" and value.index and propertyContainer:Is(value) then
            print("Found IsoFlagType->")
            print("IsoFlagType: ",value , " type: ",type(value), " index: ",value:index())
            return true
        end
    end
end
print(getIsoFlag(getPlayer():getSprite():getProperties()))
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...