Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- mapfolder = "C:\Program Files (x86)\Steam\steamapps\common\Momentum Mod\momentum\maps"
- mapname = input("Enter map name: ")
- filedir = "%s\%s.zon" % (mapfolder, mapname)
- if not os.path.isfile(filedir):
- print(".zon file does not exist for this map!")
- else:
- with open(filedir) as zonefile:
- for linecount, line in enumerate(zonefile):
- if linecount+1 == 7:
- xpos = float(line.lstrip().lstrip('"xpos"').lstrip().rstrip('\n').strip('""'))
- if linecount+1 == 8:
- ypos = float(line.lstrip().lstrip('"ypos"').lstrip().rstrip('\n').strip('""'))
- if linecount+1 == 9:
- zpos = float(line.lstrip().lstrip('"zpos"').lstrip().rstrip('\n').strip('""'))
- if linecount+1 == 13:
- xScaleMins = float(line.lstrip().lstrip('"xScaleMins"').lstrip().rstrip('\n').strip('""'))
- if linecount+1 == 14:
- yScaleMins = float(line.lstrip().lstrip('"yScaleMins"').lstrip().rstrip('\n').strip('""'))
- if linecount+1 == 15:
- zScaleMins = float(line.lstrip().lstrip('"zScaleMins"').lstrip().rstrip('\n').strip('""'))
- print("%d | %s" % (linecount+1, line.rstrip('\n')))
- print("=====================")
- 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.
- point_top2 = [xpos + xScaleMins + 1, ypos - yScaleMins - 1, zpos - zScaleMins - 1]
- point_top3 = [xpos + xScaleMins + 1, ypos + yScaleMins + 1, zpos - zScaleMins - 1]
- point_top4 = [xpos - xScaleMins - 1, ypos + yScaleMins + 1, zpos - zScaleMins - 1]
- point_bottom1 = [xpos - xScaleMins - 1, ypos - yScaleMins - 1, zpos + zScaleMins + 1]
- point_bottom2 = [xpos + xScaleMins + 1, ypos - yScaleMins - 1, zpos + zScaleMins + 1]
- point_bottom3 = [xpos + xScaleMins + 1, ypos + yScaleMins + 1, zpos + zScaleMins + 1]
- point_bottom4 = [xpos - xScaleMins - 1, ypos + yScaleMins + 1, zpos + zScaleMins + 1]
- point_bottom1_2 = [xpos - xScaleMins - 1, ypos - yScaleMins - 1, zpos + zScaleMins + 1]
- point_bottom2_2 = [xpos + xScaleMins + 1, ypos - yScaleMins - 1, zpos + zScaleMins + 1]
- point_bottom3_2 = [xpos + xScaleMins + 1, ypos + yScaleMins + 1, zpos + zScaleMins + 1]
- point_bottom4_2 = [xpos - xScaleMins - 1, ypos + yScaleMins + 1, zpos + zScaleMins + 1]
- configtext = """
- add:
- {
- "classname" "env_laser"
- "targetname" "laser_top1"
- "LaserTarget" "laser_top2"
- "origin" "%d %d %d"
- "width" "1"
- "TextureScroll" "0"
- "texture" "sprites/laserbeam.vmt"
- "spawnflags" "1"
- "brightness" "255"
- "rendercolor" "255 0 0"
- "renderamt" "255"
- "dissolvetype" "None"
- "damage" "0"
- "NoiseAmplitude" "0"
- }
- {
- "classname" "env_laser"
- "targetname" "laser_top2"
- "LaserTarget" "laser_top3"
- "origin" "%d %d %d"
- "width" "1"
- "TextureScroll" "0"
- "texture" "sprites/laserbeam.vmt"
- "spawnflags" "1"
- "brightness" "255"
- "rendercolor" "255 0 0"
- "renderamt" "255"
- "dissolvetype" "None"
- "damage" "0"
- "NoiseAmplitude" "0"
- }
- {
- "classname" "env_laser"
- "targetname" "laser_top3"
- "LaserTarget" "laser_top4"
- "origin" "%d %d %d"
- "width" "1"
- "TextureScroll" "0"
- "texture" "sprites/laserbeam.vmt"
- "spawnflags" "1"
- "brightness" "255"
- "rendercolor" "255 0 0"
- "renderamt" "255"
- "dissolvetype" "None"
- "damage" "0"
- "NoiseAmplitude" "0"
- }
- {
- "classname" "env_laser"
- "targetname" "laser_top4"
- "LaserTarget" "laser_top1"
- "origin" "%d %d %d"
- "width" "1"
- "TextureScroll" "0"
- "texture" "sprites/laserbeam.vmt"
- "spawnflags" "1"
- "brightness" "255"
- "rendercolor" "255 0 0"
- "renderamt" "255"
- "dissolvetype" "None"
- "damage" "0"
- "NoiseAmplitude" "0"
- }
- {
- "classname" "env_laser"
- "targetname" "laser_bottom1"
- "LaserTarget" "laser_bottom2"
- "origin" "%d %d %d"
- "width" "1"
- "TextureScroll" "0"
- "texture" "sprites/laserbeam.vmt"
- "spawnflags" "1"
- "brightness" "255"
- "rendercolor" "255 0 0"
- "renderamt" "255"
- "dissolvetype" "None"
- "damage" "0"
- "NoiseAmplitude" "0"
- }
- {
- "classname" "env_laser"
- "targetname" "laser_bottom2"
- "LaserTarget" "laser_bottom3"
- "origin" "%d %d %d"
- "width" "1"
- "TextureScroll" "0"
- "texture" "sprites/laserbeam.vmt"
- "spawnflags" "1"
- "brightness" "255"
- "rendercolor" "255 0 0"
- "renderamt" "255"
- "dissolvetype" "None"
- "damage" "0"
- "NoiseAmplitude" "0"
- }
- {
- "classname" "env_laser"
- "targetname" "laser_bottom3"
- "LaserTarget" "laser_bottom4"
- "origin" "%d %d %d"
- "width" "1"
- "TextureScroll" "0"
- "texture" "sprites/laserbeam.vmt"
- "spawnflags" "1"
- "brightness" "255"
- "rendercolor" "255 0 0"
- "renderamt" "255"
- "dissolvetype" "None"
- "damage" "0"
- "NoiseAmplitude" "0"
- }
- {
- "classname" "env_laser"
- "targetname" "laser_bottom4"
- "LaserTarget" "laser_bottom1"
- "origin" "%d %d %d"
- "width" "1"
- "TextureScroll" "0"
- "texture" "sprites/laserbeam.vmt"
- "spawnflags" "1"
- "brightness" "255"
- "rendercolor" "255 0 0"
- "renderamt" "255"
- "dissolvetype" "None"
- "damage" "0"
- "NoiseAmplitude" "0"
- }
- {
- "classname" "env_laser"
- "targetname" "laser_bottom1_2"
- "LaserTarget" "laser_top1"
- "origin" "%d %d %d"
- "width" "1"
- "TextureScroll" "0"
- "texture" "sprites/laserbeam.vmt"
- "spawnflags" "1"
- "brightness" "255"
- "rendercolor" "255 0 0"
- "renderamt" "255"
- "dissolvetype" "None"
- "damage" "0"
- "NoiseAmplitude" "0"
- }
- {
- "classname" "env_laser"
- "targetname" "laser_bottom2_2"
- "LaserTarget" "laser_top2"
- "origin" "%d %d %d"
- "width" "1"
- "TextureScroll" "0"
- "texture" "sprites/laserbeam.vmt"
- "spawnflags" "1"
- "brightness" "255"
- "rendercolor" "255 0 0"
- "renderamt" "255"
- "dissolvetype" "None"
- "damage" "0"
- "NoiseAmplitude" "0"
- }
- {
- "classname" "env_laser"
- "targetname" "laser_bottom3_2"
- "LaserTarget" "laser_top3"
- "origin" "%d %d %d"
- "width" "1"
- "TextureScroll" "0"
- "texture" "sprites/laserbeam.vmt"
- "spawnflags" "1"
- "brightness" "255"
- "rendercolor" "255 0 0"
- "renderamt" "255"
- "dissolvetype" "None"
- "damage" "0"
- "NoiseAmplitude" "0"
- }
- {
- "classname" "env_laser"
- "targetname" "laser_bottom4_2"
- "LaserTarget" "laser_top4"
- "origin" "%d %d %d"
- "width" "1"
- "TextureScroll" "0"
- "texture" "sprites/laserbeam.vmt"
- "spawnflags" "1"
- "brightness" "255"
- "rendercolor" "255 0 0"
- "renderamt" "255"
- "dissolvetype" "None"
- "damage" "0"
- "NoiseAmplitude" "0"
- }
- """ % (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], point_bottom1_2[0], point_bottom1_2[1], point_bottom1_2[2], point_bottom2_2[0], point_bottom2_2[1], point_bottom2_2[2], point_bottom3_2[0], point_bottom3_2[1], point_bottom3_2[2], point_bottom4_2[0], point_bottom4_2[1], point_bottom4_2[2])
- print(configtext)
- with open("%s\%s_lasers.cfg" % (mapfolder, mapname), "w") as outputfile:
- outputfile.write(configtext)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement