Advertisement
WayGroovy

RandomSpawn shift

Feb 12th, 2012
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #/usr/bin/python2.4
  2.  
  3. import random
  4. import math
  5. import re
  6.  
  7. direction = random.randint(1,360)
  8.  
  9. distance = random.randint(200,500)
  10.  
  11. xshift = int(round (distance * math.sin(direction)))
  12. yshift = int(round (distance * math.cos(direction)))
  13.  
  14. fob=open('/home/minecraft/Minecraft/plugins/RandomSpawn/worlds.yml','r')
  15. config = fob.readlines()
  16. fob.close()
  17.  
  18. for i, linedata in enumerate(config) :
  19. if i == 8 :
  20. xmin = re.findall(r"[-+]?\d*\.\d+|[-+]?\d+", linedata)
  21. if i == 9 :
  22. xmax = re.findall(r"[-+]?\d*\.\d+|[-+]?\d+", linedata)
  23. if i == 10 :
  24. ymin = re.findall(r"[-+]?\d*\.\d+|[-+]?\d+", linedata)
  25. if i == 11 :
  26. ymax = re.findall(r"[-+]?\d*\.\d+|[-+]?\d+", linedata)
  27.  
  28. xmin = int(xmin[0]) + xshift
  29. xmax = int(xmax[0]) + xshift
  30. ymin = int(ymin[0]) + yshift
  31. ymax = int(ymax[0]) + yshift
  32.  
  33. config[8] = ' x-min: ' + str(xmin) + '\n'
  34. config[9] = ' x-max: ' + str(xmax) + '\n'
  35. config[10] = ' y-min: ' + str(ymin) + '\n'
  36. config[11] = ' y-max: ' + str(ymax) + '\n'
  37.  
  38. fob=open('/home/minecraft/Minecraft/plugins/RandomSpawn/worlds.yml','w')
  39. fob.writelines(config)
  40. fob.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement