Note: This forum is merely an archive. It is no longer possible to register or post. - StackOverflow
New Ace of Spades Forums: http://buildandshoot.com/

Map-Specific Building/Damage Script

Finished a script? Pop it in here.

Map-Specific Building/Damage Script

Postby Influx » Tue Aug 14, 2012 11:32 pm

Thanks to Dany0 for this better version which removes a lot of redundant stuff from my original one;

Code: Select all
def apply_script(protocol, connection, config):
    class NobuildProtocol(protocol):
        def on_map_change(self, map):
            extensions = self.map_info.extensions
            if extensions.has_key('nobuild'):
                self.building = False
            else:
                self.building = True
            return protocol.on_map_change(self, map)

    return NobuildProtocol, connection


Save as nobuild.py

Basically, this enables mapmakers to toggle whether building and damage is enabled on their maps by adding this in the map extensions;
Code: Select all
extensions = {
'nobuild': True
}


It can be disabled by either changing the boolean to False, or by deleting the whole thing.
Last edited by Influx on Sat Aug 18, 2012 12:13 pm, edited 2 times in total.
User avatar
Influx
Member
 
Posts: 115
Joined: Thu Jan 12, 2012 11:05 pm
Location: Not France.

Re: Map-Specific Building/Damage Script

Postby Dany0 » Wed Aug 15, 2012 9:06 pm

Or just add the is_indestructable exten..funct... that thing doesn't work! Mathias power of 2 :|

Here's an easier way to do it (didn't test):

Code: Select all
def apply_script(protocol, connection, config):
    class NobuildProtocol(protocol):
        def on_map_change(self, map):
            extensions = self.map_info.extensions
            if extensions.has_key('nobuild'):
                self.building = False
            else:
                self.building = True
            return protocol.on_map_change(self, map)

    return NobuildProtocol, connection
Image
User avatar
Dany0
Member
 
Posts: 358
Joined: Mon Dec 26, 2011 7:29 pm

Re: Map-Specific Building/Damage Script

Postby Influx » Sat Aug 18, 2012 12:11 pm

I've just tested that code and it works fine, and also neatly condenses my gangly script into one neat function.
User avatar
Influx
Member
 
Posts: 115
Joined: Thu Jan 12, 2012 11:05 pm
Location: Not France.


Return to Script releases



Who is online

Users browsing this forum: No registered users and 6 guests