I've Added ZIPs no not those zips. Used zip()

This commit is contained in:
Timothy GFO 2023-09-28 18:36:23 -04:00
parent dc64b4ed6e
commit c6be529e06
3 changed files with 93 additions and 63 deletions

View file

@ -50,13 +50,16 @@ def read_file(filename="blank.mmlv"):
def write_changes(filename="sample.mmlv"): def write_changes(filename="sample.mmlv"):
#Well well well... this for loop is here to make every thing work. I'm not sure for what the 1s, 1q,1r and 1p keys are, but if they are the same as a blank mmlv created by mmm, it just doesn't work. It's weird.' #Well well well... this for loop is here to make every thing work. I'm not sure for what the 1s, 1q,1r and 1p keys are, but if they are the same as a blank mmlv created by mmm, it just doesn't work. It's weird.'
for letter in "srqp":
if letter == "q": for key,value in zip("srqp", [set_apos(4480), set_apos(0), set_apos(12800), set_apos(0)]):
config.set(section,"1"+letter, set_apos(12800) ) config.set(section,f"1{key}", value)
elif letter == "s": # for letter in "srqp":
config.set(section,"1"+letter, set_apos(4480) ) # if letter == "q":
else: # config.set(section,"1"+letter, set_apos(12800) )
config.set(section,"1"+letter, set_apos(0) ) # elif letter == "s":
# config.set(section,"1"+letter, set_apos(4480) )
# else:
# config.set(section,"1"+letter, set_apos(0) )
with open(filename, 'w') as configfile: with open(filename, 'w') as configfile:
config.write(configfile, space_around_delimiters=False) config.write(configfile, space_around_delimiters=False)
@ -116,7 +119,7 @@ def set_tile_value(k_value, j_value, i_value, e_value, a_value, posX_16, posY_16
config.set(section,letter + posX_16 + "," + posY_16, a_value) config.set(section,letter + posX_16 + "," + posY_16, a_value)
#Needs work for choosing specific version of tilename (subtypes?), other versions of tiles (e.g. mm1electile1), and it also needs optional automatic room activator. #Needs work for choosing specific version of tilename (subtypes?), other versions of tiles (e.g. mm1electile1), and it also needs optional automatic room activator.
def set_tile(x, y, tilename="mm1cuttile", block_type="normal", tile_subtype=False, room_active=1): def set_tile(x, y, tilename="mm1cuttile", tile_type="normal", tile_subtype=False, room_active=1):
by16 = conv_coordinates_x16(x, y) by16 = conv_coordinates_x16(x, y)
x16 = str(by16[0]) x16 = str(by16[0])
y16 = str(by16[1]) y16 = str(by16[1])
@ -127,42 +130,57 @@ def set_tile(x, y, tilename="mm1cuttile", block_type="normal", tile_subtype=Fals
#WIP #WIP
option = 0 option = 0
error = False error = False
tile_types = {
"normal" : '"1"',
"spike" : '"2"',
"ladder" : '"3"'
}
for letter in "kjiea": try:
if letter == "k": tilename = int(tilename)
#unknown, so sample for now. Related to tile sub type tilename_value = set_apos(tilename)
#print("working k") except ValueError:
option = '"106.000"' if tilename in definitions.tile_names:
elif letter == "j": tilename_value = definitions.tile_names[tilename]
#unknown Related to tile subtype. maybe this and k are x and y? This is x, not y. else:
#print("working j") error = True
option = '"71.000"'
elif letter == "i": for key,value in zip("kjiea", ['"106"', '"71"', tile_types[tile_type], tilename_value, '"1"']):
#according to https://gist.github.com/freem/03d6c1832299e8d8a32f64361380920d this is block type # for letter in "kjiea":
if block_type == "ladder": # if letter == "k":
option = '"3.000"' # #unknown, so sample for now. Related to tile sub type
elif block_type == "spike": # #print("working k")
option = '"2.000"' # option = '"106.000"'
else: # elif letter == "j":
option = '"1.000"' # #unknown Related to tile subtype. maybe this and k are x and y? This is x, not y.
elif letter == "e": # #print("working j")
#supposedly this is item sub-type. Leaving default for now. Need to implement a method to have an index of all the tiles. # option = '"71.000"'
try: # elif letter == "i":
tilename = int(tilename) # #according to https://gist.github.com/freem/03d6c1832299e8d8a32f64361380920d this is block type
option = set_apos(tilename) # if block_type == "ladder":
except ValueError: # option = '"3.000"'
if tilename in definitions.tile_names: # elif block_type == "spike":
option = definitions.tile_names[tilename] # option = '"2.000"'
else: # else:
error = True # option = '"1.000"'
# elif letter == "e":
# #supposedly this is item sub-type. Leaving default for now. Need to implement a method to have an index of all the tiles.
# try:
# tilename = int(tilename)
# option = set_apos(tilename)
# except ValueError:
# if tilename in definitions.tile_names:
# option = definitions.tile_names[tilename]
# else:
# error = True
#print("working e") #print("working e")
#option = '"3.000"' #option = '"3.000"'
else: # else:
#enabled? Well, of course! Cheap way to remove a tile. Not ideal though, increases load time, proper removing of the keys will be implemented. ALERT, THIS APPLIES TO EVERYTHING NOT JUST TILES(objects, etc...) # #enabled? Well, of course! Cheap way to remove a tile. Not ideal though, increases load time, proper removing of the keys will be implemented. ALERT, THIS APPLIES TO EVERYTHING NOT JUST TILES(objects, etc...)
#print("working a") # #print("working a")
option = '"1.000"' # option = '"1.000"'
if error == False: if error == False:
config.set(section,letter + x16 + "," + y16, option) config.set(section,key + x16 + "," + y16, value)
else: else:
return "error in " + str(letter) return "error in " + str(letter)
@ -194,17 +212,18 @@ def set_player(x, y,type="mm", allow_duplicates=0):
by16 = conv_coordinates_x16(x, y) by16 = conv_coordinates_x16(x, y)
x16 = str(by16[0]) x16 = str(by16[0])
y16 = str(by16[1]) #Every function that has something like all this should be a funcion. y16 = str(by16[1]) #Every function that has something like all this should be a funcion.
for letter in "oda": for key,value in zip("oda", ['"9999"', '"4"', '"1"']):
option = 0 # for letter in "oda":
if letter == "o": # option = 0
#Unknown # if letter == "o":
option = '"9999.000"' # #Unknown
elif letter == "d": # option = '"9999.000"'
#unknown # elif letter == "d":
option = '"4.000"' # #unknown
else: # option = '"4.000"'
option = '"1.000"' # else:
config.set(section,letter + x16 + "," + y16, option) # option = '"1.000"'
config.set(section,key + x16 + "," + y16, value)
def del_tile(x,y,disable=False): def del_tile(x,y,disable=False):
for letter in definitions.block_with_coordinates: for letter in definitions.block_with_coordinates:
@ -229,7 +248,6 @@ def connect_screen(h_or_v, roomX, roomY):
if h_or_v == "h".lower(): if h_or_v == "h".lower():
config.remove_option(section, f"2b{x},{y}") config.remove_option(section, f"2b{x},{y}")
else: else:
print(x)
config.set(section, f"2c{x},{y}", "1") config.set(section, f"2c{x},{y}", "1")
def disconnect_screen(h_or_v, x, y): def disconnect_screen(h_or_v, x, y):
@ -245,17 +263,18 @@ def set_object(x, y, object_name="energy_element", setting="9999", object_type="
by16 = conv_coordinates_x16(x, y) by16 = conv_coordinates_x16(x, y)
x16 = str(by16[0]) x16 = str(by16[0])
y16 = str(by16[1]) y16 = str(by16[1])
for key in "oeda": for key,value in zip("oeda", [setting, definitions.object_names[object_name], object_type, "1"]):
if key == "o": # for key in "oeda":
#mysteries continue. Maybe setting? # if key == "o":
value = setting # #mysteries continue. Maybe setting?
elif key == "e": # value = setting
value = definitions.object_names[object_name] # elif key == "e":
elif key == "d": # value = definitions.object_names[object_name]
#this is like the object_type? # elif key == "d":
value = object_type # #this is like the object_type?
else: # value = object_type
value = "1" # else:
# value = "1"
config.set(section, f"{key}{x16},{y16}", value) #< I'll maybe add the set_player function here, because they are sort of objects. That way everything can be made through here.' config.set(section, f"{key}{x16},{y16}", value) #< I'll maybe add the set_player function here, because they are sort of objects. That way everything can be made through here.'
def set_background(roomX, roomY, bg_id): def set_background(roomX, roomY, bg_id):

View file

@ -25,4 +25,13 @@
2c512,224=1 2c512,224=1
2d0,0=115 2d0,0=115
2d256,0=115 2d256,0=115
o16,16=9999
e16,16=15
d16,16=8
a16,16=1
k16,32="106"
j16,32="71"
i16,32="1"
e16,32="3.000"
a16,32="1"

View file

@ -30,5 +30,7 @@ mmlv.set_user("Python")
mmlv.connect_screen("v", 2, 1) mmlv.connect_screen("v", 2, 1)
mmlv.set_background(0,0, 115) mmlv.set_background(0,0, 115)
mmlv.set_background(1,0, "cut") mmlv.set_background(1,0, "cut")
mmlv.set_object(1,1, "energy_element")
mmlv.set_tile(1,2)
mmlv.write_changes("sample.mmlv") mmlv.write_changes("sample.mmlv")
#del_tile(1,1) #del_tile(1,1)