More functions for engine.Level.spots?

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
yufra
Perspiring Physicist
Posts: 1332
Joined: Tue Jul 13, 2010 2:53 pm

More functions for engine.Level.spots?

#1 Post 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
<DarkGod> lets say it's intended

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: More functions for engine.Level.spots?

#2 Post 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.
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

yufra
Perspiring Physicist
Posts: 1332
Joined: Tue Jul 13, 2010 2:53 pm

Re: More functions for engine.Level.spots?

#3 Post 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?
<DarkGod> lets say it's intended

Post Reply