Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.56 KB | None | 0 0
  1. import os
  2.  
  3. mapfolder = "C:\Program Files (x86)\Steam\steamapps\common\Momentum Mod\momentum\maps"
  4. mapname = input("Enter map name: ")
  5. filedir = "%s\%s.zon" % (mapfolder, mapname)
  6.  
  7. if not os.path.isfile(filedir):
  8.     print(".zon file does not exist for this map!")
  9. else:
  10.     with open(filedir) as zonefile:
  11.         for linecount, line in enumerate(zonefile):
  12.             if linecount+1 == 7:
  13.                 xpos = float(line.lstrip().lstrip('"xpos"').lstrip().rstrip('\n').strip('""'))
  14.             if linecount+1 == 8:
  15.                 ypos = float(line.lstrip().lstrip('"ypos"').lstrip().rstrip('\n').strip('""'))
  16.             if linecount+1 == 9:
  17.                 zpos = float(line.lstrip().lstrip('"zpos"').lstrip().rstrip('\n').strip('""'))
  18.             if linecount+1 == 13:
  19.                 xScaleMins = float(line.lstrip().lstrip('"xScaleMins"').lstrip().rstrip('\n').strip('""'))
  20.             if linecount+1 == 14:
  21.                 yScaleMins = float(line.lstrip().lstrip('"yScaleMins"').lstrip().rstrip('\n').strip('""'))
  22.             if linecount+1 == 15:
  23.                 zScaleMins = float(line.lstrip().lstrip('"zScaleMins"').lstrip().rstrip('\n').strip('""'))
  24.             print("%d | %s" % (linecount+1, line.rstrip('\n')))
  25. print("=====================")
  26. point_top1 = [xpos - xScaleMins - 1, ypos - yScaleMins - 1, zpos - zScaleMins - 1]          #The +/- 1 on each value is to shrink the laser box by 1 unit in each direction, to make sure the lasers are visible when touching up against a wall.
  27. point_top2 = [xpos + xScaleMins + 1, ypos - yScaleMins - 1, zpos - zScaleMins - 1]
  28. point_top3 = [xpos + xScaleMins + 1, ypos + yScaleMins + 1, zpos - zScaleMins - 1]
  29. point_top4 = [xpos - xScaleMins - 1, ypos + yScaleMins + 1, zpos - zScaleMins - 1]
  30. point_bottom1 = [xpos - xScaleMins - 1, ypos - yScaleMins - 1, zpos + zScaleMins + 1]
  31. point_bottom2 = [xpos + xScaleMins + 1, ypos - yScaleMins - 1, zpos + zScaleMins + 1]
  32. point_bottom3 = [xpos + xScaleMins + 1, ypos + yScaleMins + 1, zpos + zScaleMins + 1]
  33. point_bottom4 = [xpos - xScaleMins - 1, ypos + yScaleMins + 1, zpos + zScaleMins + 1]
  34.  
  35. configtext = """
  36. add:
  37. {
  38.    "classname" "env_laser"
  39.    "targetname" "laser_top1"
  40.    "LaserTarget" "laser_top2"
  41.    "origin" "%d %d %d"
  42.    "width" "1"
  43.    "TextureScroll" "0"
  44.    "texture" "sprites/laserbeam.vmt"
  45.    "spawnflags" "1"
  46.    "brightness" "255"
  47.    "rendercolor" "255 0 0"
  48.    "renderamt" "255"
  49.    "dissolvetype" "None"
  50.    "damage" "0"
  51.    "NoiseAmplitude" "0"
  52. }
  53. {
  54.    "classname" "env_laser"
  55.    "targetname" "laser_top2"
  56.    "LaserTarget" "laser_top3"
  57.    "origin" "%d %d %d"
  58.    "width" "1"
  59.    "TextureScroll" "0"
  60.    "texture" "sprites/laserbeam.vmt"
  61.    "spawnflags" "1"
  62.    "brightness" "255"
  63.    "rendercolor" "255 0 0"
  64.    "renderamt" "255"
  65.    "dissolvetype" "None"
  66.    "damage" "0"
  67.    "NoiseAmplitude" "0"
  68. }
  69. {
  70.    "classname" "env_laser"
  71.    "targetname" "laser_top3"
  72.    "LaserTarget" "laser_top4"
  73.    "origin" "%d %d %d"
  74.    "width" "1"
  75.    "TextureScroll" "0"
  76.    "texture" "sprites/laserbeam.vmt"
  77.    "spawnflags" "1"
  78.    "brightness" "255"
  79.    "rendercolor" "255 0 0"
  80.    "renderamt" "255"
  81.    "dissolvetype" "None"
  82.    "damage" "0"
  83.    "NoiseAmplitude" "0"
  84. }
  85. {
  86.    "classname" "env_laser"
  87.    "targetname" "laser_top4"
  88.    "LaserTarget" "laser_top1"
  89.    "origin" "%d %d %d"
  90.    "width" "1"
  91.    "TextureScroll" "0"
  92.    "texture" "sprites/laserbeam.vmt"
  93.    "spawnflags" "1"
  94.    "brightness" "255"
  95.    "rendercolor" "255 0 0"
  96.    "renderamt" "255"
  97.    "dissolvetype" "None"
  98.    "damage" "0"
  99.    "NoiseAmplitude" "0"
  100. }
  101. {
  102.    "classname" "env_laser"
  103.    "targetname" "laser_bottom1"
  104.    "LaserTarget" "laser_bottom2"
  105.    "origin" "%d %d %d"
  106.    "width" "1"
  107.    "TextureScroll" "0"
  108.    "texture" "sprites/laserbeam.vmt"
  109.    "spawnflags" "1"
  110.    "brightness" "255"
  111.    "rendercolor" "255 0 0"
  112.    "renderamt" "255"
  113.    "dissolvetype" "None"
  114.    "damage" "0"
  115.    "NoiseAmplitude" "0"
  116. }
  117. {
  118.    "classname" "env_laser"
  119.    "targetname" "laser_bottom2"
  120.    "LaserTarget" "laser_bottom3"
  121.    "origin" "%d %d %d"
  122.    "width" "1"
  123.    "TextureScroll" "0"
  124.    "texture" "sprites/laserbeam.vmt"
  125.    "spawnflags" "1"
  126.    "brightness" "255"
  127.    "rendercolor" "255 0 0"
  128.    "renderamt" "255"
  129.    "dissolvetype" "None"
  130.    "damage" "0"
  131.    "NoiseAmplitude" "0"
  132. }
  133. {
  134.    "classname" "env_laser"
  135.    "targetname" "laser_bottom3"
  136.    "LaserTarget" "laser_bottom4"
  137.    "origin" "%d %d %d"
  138.    "width" "1"
  139.    "TextureScroll" "0"
  140.    "texture" "sprites/laserbeam.vmt"
  141.    "spawnflags" "1"
  142.    "brightness" "255"
  143.    "rendercolor" "255 0 0"
  144.    "renderamt" "255"
  145.    "dissolvetype" "None"
  146.    "damage" "0"
  147.    "NoiseAmplitude" "0"
  148. }
  149. {
  150.    "classname" "env_laser"
  151.    "targetname" "laser_bottom4"
  152.    "LaserTarget" "laser_bottom1"
  153.    "origin" "%d %d %d"
  154.    "width" "1"
  155.    "TextureScroll" "0"
  156.    "texture" "sprites/laserbeam.vmt"
  157.    "spawnflags" "1"
  158.    "brightness" "255"
  159.    "rendercolor" "255 0 0"
  160.    "renderamt" "255"
  161.    "dissolvetype" "None"
  162.    "damage" "0"
  163.    "NoiseAmplitude" "0"
  164. }
  165. """ % (point_top1[0], point_top1[1], point_top1[2], point_top2[0], point_top2[1], point_top2[2], point_top3[0], point_top3[1], point_top3[2], point_top4[0], point_top4[1], point_top4[2], point_bottom1[0], point_bottom1[1], point_bottom1[2], point_bottom2[0], point_bottom2[1], point_bottom2[2], point_bottom3[0], point_bottom3[1], point_bottom3[2], point_bottom4[0], point_bottom4[1], point_bottom4[2])
  166. print(configtext)
  167.  
  168. with open("%s\%s_lasers.cfg" % (mapfolder, mapname), "w") as outputfile:
  169.     outputfile.write(configtext)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement