Page 1 of 1

More functions for engine.Level.spots?

Posted: Wed Aug 04, 2010 6:53 pm
by yufra
I am starting to use the addSpots function in engine.generators.maps.Static quite a bit, and I know that all map generators are expected to return spots which is then put into the level table (engine.Zone line 522-529). Do you think it would be worth adding spots and some helper functions to engine.Level at initialization time? The specific function I had in mind is for filtering:

Code: Select all

function _M:getSpots(type, subtype)
    if not type and not subtype then return self.spots end
    local matched = {}
    for i, v in pairs(self.spots) do
        if (not type or type and v.type == type) and (not subtype or subtype and v.subtype == subtype) then
            table.insert(matched, v)
        end
    end
    return matched
end

Re: More functions for engine.Level.spots?

Posted: Wed Aug 04, 2010 7:14 pm
by darkgod
I could see a use yes, although you could probably make it use the Zone:checkFilter framework to make it more flexible and in line with the rest of the code.

Re: More functions for engine.Level.spots?

Posted: Wed Aug 04, 2010 7:47 pm
by yufra
Zone.checkFilter, I knew I had seen a similar function somewhere! :D So drop that in instead of my if-and-or magic, right?