Page 1 of 1

Map Extensions+ [UPDATED]

Posted: Fri Apr 12, 2013 11:18 pm
by Influx
Download Map Extensions+
UPDATED: 3rd August 2013

This is just a quick little script I whipped up which adds a couple of new features to the map extensions script that comes with PySnip/PySpades, since I'd noticed a few people asking how to do them. I am aware that there are other ways of achieving the features I've added, but they're now located in one handy script.

The features it adds are;

- Custom spawns
- Block Protection
- 'No Build' Protection
- 'No Destroy' Protection

For the protection zones, admins can still bypass the protection by entering God mode and building/destroying in the protected zone.

To use these features, add the following commands to your map.txt file (as applicable)

'blue_spawn': [(x, y, (z))] - z value is optional, will spawn at the map's ground height if not included
'blue_spawn_offset': (value) - Max offset in any direction from the location provided above. Optional, if not included, defaults to 50.
'green_spawn': same as blue_spawn
'green_spawn_offset': same as blue_spawn_offset
'protected': [ [ (x, y, z), (x, y, z) ] ] - NOTE: 2 square brackets must be used before the very first set of co-ordinates and after the very last set. First set of co-ordinates are one corner of the protection box, the second set are the opposite corner
'nobuild':[ [(x, y, z), (x, y, z)] ] - Same as above - forbids building only
'nodestroy':[ [(x, y, z), (x, y, z)] ] - Same as above - forbids destroying blocks only

Here's an example of a map.txt;
Code: Select all
extensions = {
'blue_spawn': [(0, 0)], #Spawns blues at 0, 0
'blue_spawn_offset': 10, #Blues can spawn a maximum of 10 blocks from 0, 0
'green_spawn':[(512, 0), (512, 512, 20)] #Greens have two spawns which they can randomly spawn at. Second one will force players to spawn at height 20
#No green_spawn_offset. The script will default to 50 blocks in all directions.
'protected': [ [(0, 0, 0), (10, 10, 63)], [(10, 20, 0), (0, 10, 63)] ] #This contains two protected areas; One goes from (0, 0, 0) to (10, 10, 63), and the second one goes from (10, 20, 0) to (0, 10, 63). 
#Note that the values in the second bracket can be lower than the first bracket
'nobuild': [ [250, 250, 0], [260, 260, 63] ]
'nodestroy': [ [280, 250, 0], [220, 250, 0] ]
}
Now I've only done the slightest of testing to confirm it works on localhost. I can't imagine there being anything in there to crash your game, but if there is, let me know and I'll get on it ASAP. Also, if there's any other feature you'd like to see added, let me know and I'll see what I can do!

Other than that, have fun.

UPDATE: Fixed bug Lostmotel pointed out, added new feature requested.

Re: Map Extensions+

Posted: Sat Apr 13, 2013 2:54 pm
by rakiru
Would it be possible to set the spawn rotation in there, as well as location?

Re: Map Extensions+

Posted: Sat Apr 13, 2013 3:16 pm
by Lostmotel
Thank you, Influx. Blue_Happy1
That's exactly what I've been looking for.
Gonna do some testing on it right now.

EDIT: I think I found a bug. The block protection works perfectly fine when I choose a map with the map metadata which has the extension "protected", but after advancing to a map without this extension I am unable to place or destroy blocks and I get the following error:
Spoiler:
2013-04-16 17:13:42+0200 [-] File "C:\Dokumente und Einstellungen\Andy\Desktop\aos\maptestserver\scripts\map_extensions.py", line 126, in on_block_build_attempt
2013-04-16 17:13:42+0200 [-] UnboundLocalError: local variable 'protected' referenced before assignment

Re: Map Extensions+

Posted: Fri Aug 02, 2013 8:32 pm
by Lostmotel
bump!
A second map extension which only enables building but no destruction in a certain area would also be nice Blue_Wink1

Re: Map Extensions+

Posted: Sat Aug 03, 2013 8:00 pm
by Influx
rakiru wrote:
Would it be possible to set the spawn rotation in there, as well as location?
I've looked into changing the spawn orientation but I just couldn't seem to get it working no matter how hard I tried. It's beyond my comprehension, although someone more talented *cough* thepolm3 *cough* may have a better chance.
Lostmotel wrote:
Thank you, Influx. Blue_Happy1
That's exactly what I've been looking for.
Gonna do some testing on it right now.

EDIT: I think I found a bug. The block protection works perfectly fine when I choose a map with the map metadata which has the extension "protected", but after advancing to a map without this extension I am unable to place or destroy blocks and I get the following error:
Spoiler:
2013-04-16 17:13:42+0200 [-] File "C:\Dokumente und Einstellungen\Andy\Desktop\aos\maptestserver\scripts\map_extensions.py", line 126, in on_block_build_attempt
2013-04-16 17:13:42+0200 [-] UnboundLocalError: local variable 'protected' referenced before assignment
I've fixed that. It was caused by some code that hadn't been properly indented.
Lostmotel wrote:
bump!
A second map extension which only enables building but no destruction in a certain area would also be nice Blue_Wink1
Done, and also implemented destruction but no building.

Also, I've allowed admins to be able to enter God Mode and break things or build things in the protected zones, so block spamming and wanton destruction can be cleared.

(They have to enter God Mode so they don't innocently start building where they shouldn't if they are playing the game normally)

Re: Map Extensions+ [UPDATED]

Posted: Mon Aug 05, 2013 8:31 pm
by Lostmotel
thank you Influx, great work as always Blue_BigSmile
There should be a pysnip update so we can get people to use all these imroved scripts like this one or the new votekick script.

Re: Map Extensions+ [UPDATED]

Posted: Sun Mar 16, 2014 2:24 am
by Jdrew
should be included in default pysnip