View difference between Paste ID: UytKL9ze and i0J0kVAx
SHOW: | | - or go back to the newest paste.
1
# Author: Garthog
2
# You need to download gamh's pyWMO, then create a new file where you paste this code.
3
# Don't forget to create a folder "output" where you run this file.
4
# Also, you need Python 3.3
5
6
import sys
7
from pywmo import Wmo
8
9
wmo_name = input('Enter WMO Filename : ');
10
building = Wmo(wmo_name);
11
12-
	command = input("What do you want to do ?\n\"a\" - Add a light\n\"i\" - Get informations about a light\n\"q\" - Exit\n")
12+
13-
	
13+
14-
	if(command == "q"):
14+
15-
		
15+
16-
		while(1):
16+
17-
			save = input("Do you want to save (yes/no) ? ")
17+
    command = input("What do you want to do ?\n\"a\" - Add a light\n\"i\" - Get informations about a light\n\"q\" - Exit\n")
18-
			
18+
    
19-
			if save.upper() == "YES":
19+
    if(command == "q"):
20-
				print("Saving file")
20+
        
21-
				building.write_file("./output/" + wmo_name)
21+
        while(1):
22-
				break;
22+
            save = input("Do you want to save (yes/no) ? ")
23-
			elif save.upper() == "NO":
23+
            
24-
				print("Exiting without saving")
24+
            if save.upper() == "YES":
25-
				break;
25+
                print("Saving file")
26-
			else:
26+
                building.write_file("./output/" + wmo_name)
27-
				print("You have to write \"yes\" or \"no\"");
27+
                break;
28-
				
28+
            elif save.upper() == "NO":
29-
		print("See ya later");	
29+
                print("Exiting without saving")
30-
		sys.exit();
30+
                break;
31-
	elif(command == "a"):
31+
            else:
32-
		print("Light definition")
32+
                print("You have to write \"yes\" or \"no\"");
33-
		
33+
                
34-
		light = { }
34+
        print("See ya later");    
35-
		
35+
        sys.exit();
36-
		light["flag1"] = int(input("LightType : "))
36+
    elif(command == "a"):
37-
		light["flag2"] = int(input("type : "))
37+
        print("Light definition")
38-
		light["flag3"] = int(input("useAtten : "))
38+
        
39-
		light["flag4"] = int(input("pad : "))
39+
        light = { }
40-
		
40+
        
41-
		light["color"] = (float(input("R : ")), float(input("G : ")), float(input("B : ")), float(input("A : ")))
41+
        light["flag1"] = int(input("LightType : "))
42-
		light["position"] = (float(input("X : ")), float(input("Y : ")), float(input("Z : ")))
42+
        light["flag2"] = int(input("type : "))
43-
		
43+
        light["flag3"] = int(input("useAtten : "))
44-
		light["intensity"] = float(input("intensity : "))
44+
        light["flag4"] = int(input("pad : "))
45-
		
45+
        
46-
		light["attenuation_start"] = float(input("attenuation_start : "))
46+
        light["color"] = (int(input("B : ")), int(input("G : ")), int(input("R : ")), int(input("A : ")))
47-
		light["attenuation_stop"] = float(input("attenuation_stop : "))
47+
        light["position"] = (float(input("X : ")), float(input("Y : ")), float(input("Z : ")))
48-
		
48+
        
49-
		light["unknown1"] = float(input("Unknown 1 : "))
49+
        light["intensity"] = float(input("intensity : "))
50-
		light["unknown2"] = float(input("Unknown 2 : "))
50+
        
51-
		light["unknown3"] = float(input("Unknown 3 : "))
51+
        light["attenuation_start"] = float(input("attenuation_start : "))
52-
		light["unknown4"] = float(input("Unknown 4 : "))
52+
        light["attenuation_stop"] = float(input("attenuation_stop : "))
53-
		
53+
        
54-
		building.num_lights += 1;
54+
        light["unknown1"] = float(input("Unknown 1 : "))
55-
		building.lights.append(light);
55+
        light["unknown2"] = float(input("Unknown 2 : "))
56-
			
56+
        light["unknown3"] = float(input("Unknown 3 : "))
57-
		print("There are " + str(len(building.groups)) + " groups")
57+
        light["unknown4"] = float(input("Unknown 4 : "))
58-
		
58+
        
59-
		while(1):
59+
        building.num_lights += 1;
60-
			group = input("In which group do you want to reference that light ( type \"s\" to return the main menu ) ? ")
60+
        building.lights.append(light);
61-
			
61+
            
62-
			if(group == "s"):
62+
        print("There are " + str(len(building.groups)) + " groups")
63-
				break;
63+
        
64-
			
64+
        while(1):
65-
			group = int(group)
65+
            group = input("In which group do you want to reference that light ( type \"m\" to return the main menu ) ? ")
66-
			
66+
            
67-
			if(group >= 0 and group < len(building.groups)):
67+
            if(group == "s"):
68-
			
68+
                break;
69-
				if not building.groups[group].flags & 0x200:
69+
            
70-
					building.groups[group].flags &= 0x200
70+
            group = int(group)
71-
					building.groups[group].light_refs = []
71+
            
72-
					
72+
            if(group >= 0 and group < len(building.groups)):
73-
				building.groups[group].light_refs.append(building.num_lights)
73+
            
74-
				print("Light ref added to group " + str(group))
74+
                if not building.groups[group].flags & 0x200:
75-
			else:
75+
                    building.groups[group].flags &= 0x200
76-
				print("Bad group.")
76+
                    building.groups[group].light_refs = []
77-
		
77+
                    
78-
		
78+
                building.groups[group].light_refs.append(building.num_lights - 1)
79-
		print("Light succefully added. There are now " + str(building.num_lights) + " lights.")
79+
                print("Light ref added to group " + str(group))
80-
		
80+
            else:
81-
		
81+
                print("Bad group.")
82-
	else:
82+
        
83-
		print("Unknown command")
83+
        
84
        print("Light succefully added. There are now " + str(building.num_lights) + " lights.")
85
        
86
    elif(command == "i"):
87
        while(1):
88
            subcommand = input("Type \"l\" to list all lights, or just type a number to print info of that specific light\n( type \"m\" to return the main menu )\n")
89
            
90
            if(subcommand == "m"):
91
                break;
92
            elif(subcommand == "l"):
93
                i = 0;
94
                while i < building.num_lights:
95
                    print("Light " + str(i) + " X: " + str(building.lights[i]["position"][0]) + " Y: " 
96
                    + str(building.lights[i]["position"][1]) + " Z:" + str(building.lights[i]["position"][2]));
97
                    i += 1
98
            elif(subcommand.isdigit()):
99
                light_index = int(subcommand)
100
                if light_index >= 0 and light_index < building.num_lights:
101
                    print("Informations of light " + subcommand)
102
                    print("Flags " + str(building.lights[light_index]["flag1"]) + " " + str(building.lights[light_index]["flag2"]) 
103
                    + "  " + str(building.lights[light_index]["flag3"]) + " " + str(building.lights[light_index]["flag4"]))
104
                    print("Color ( BGRA ) " + str(building.lights[light_index]["color"][0]) + " "+ str(building.lights[light_index]["color"][1]) + " "
105
                        + str(building.lights[light_index]["color"][2]) + " "+ str(building.lights[light_index]["color"][3]))
106
                    print("Position X:" + str(building.lights[light_index]["position"][0]) + " Y: " 
107
                    + str(building.lights[light_index]["position"][1]) + " Z:" + str(building.lights[light_index]["position"][2]));
108
                    print("Intensity " + str(building.lights[light_index]["intensity"]))
109
                    print("Attenuation Start " + str(building.lights[light_index]["attenuation_start"]))
110
                    print("Attenuation Stop " + str(building.lights[light_index]["attenuation_stop"]))
111
                    print("Unknown floats " + str(building.lights[light_index]["unknown1"]) + " " + str(building.lights[light_index]["unknown2"]) + " "
112
                    + str(building.lights[light_index]["unknown3"]) + " " + str(building.lights[light_index]["unknown4"]))
113
                    
114
                    for i in range(len(building.groups)):
115
                        if building.groups[i].flags & 0x200:
116
                            if light_index in building.groups[i].light_refs:
117
                                print("Referenced in group " + str(i))
118
                                
119
                else:
120
                    print("This light doesn't exist.")
121
    else:
122
        print("Unknown command")