A little cleanup and staged blank.mmlv

This commit is contained in:
Timothy GFO 2023-09-04 01:15:58 -04:00
parent 1f2803b1e9
commit b52228eeb4
5 changed files with 186 additions and 77 deletions

44
blank.mmlv Normal file
View file

@ -0,0 +1,44 @@
[Level]
2b0,4256="0.000"
2b0,4032="0.000"
2b0,3808="0.000"
2b0,3584="0.000"
2b0,3360="0.000"
2b0,3136="0.000"
2b0,2912="0.000"
2b0,2688="0.000"
2b0,2464="0.000"
2b0,2240="0.000"
2b0,2016="0.000"
2b0,1792="0.000"
2b0,1568="0.000"
2b0,1344="0.000"
2b0,1120="0.000"
2b0,896="0.000"
2b0,672="0.000"
2b0,448="0.000"
2b0,224="0.000"
2b0,0="0.000"
1s="64.000"
1r="32.000"
1q="48.000"
1p="32.000"
1m="10.000"
1l="6.000"
1k0="0.000"
1bc="0.000"
1f="-1.000"
1e="29.000"
1d="6.000"
1cc="1.000"
1cb="1.000"
1bb="0.000"
1ca="0.000"
1ba="0.000"
1c="1.000"
1b="1.000"
4b="75.000"
4a="game fever online yt"
1a="sample"
0v="1.8.4.1"
0a="386743.000"

View file

@ -87,4 +87,12 @@ weapons = {
supported_values = { supported_values = {
"weapon_slot" : weapons, "weapon_slot" : weapons,
}
tile_names = {
"mm1cuttile" : '"3.000"'
} }

28
everyprobleminonefile.txt Normal file
View file

@ -0,0 +1,28 @@
1s="1600"
1r="0"
1q="1600"
1p="0"
1m="10"
1l="6"
1k11="-1"
1k10="-1"
1k9="-1"
1k8="-1"
1k7="-1"
1k6="-1"
1k5="-1"
1k4="-1"
1k3="-1"
1k2="-1"
1k1="-1"
1k0="0"
1bc="0"
1f="-1"
1e="29"
1d="6"
1bb="0"
1ca="0"
1ba="0"
1c="1"
1b="1"
4b="75"

View file

@ -7,11 +7,14 @@ It could also work by calling a function, say place_tile(tilename, x, y) and the
import configparser, os, definitions import configparser, os, definitions
section = "Level" section = "Level"
config = configparser.ConfigParser() config = configparser.ConfigParser()
filename = "sample.mmlv" filename = "blank.mmlv"
config.read(filename) #this must be changed to support writing ONLY the changes when giving and argument in write_changes(), and not filename PLUS the changes. config.read(filename) #this must be changed to support writing ONLY the changes when giving and argument in write_changes(), and not filename PLUS the changes. Todo: Enable Modifying of levels, not just creating.
alias = definitions.aliases alias = definitions.aliases
supported_values = definitions.supported_values supported_values = definitions.supported_values
max_x = 799
max_y = 279
max_room_x = 49
max_room_y = 19
#done. converts from multiples of 16 to normal x and y values. for use in reading #done. converts from multiples of 16 to normal x and y values. for use in reading
def conv_coordinates(x16, y16): def conv_coordinates(x16, y16):
@ -31,45 +34,53 @@ def conv_coordinates_x16(x, y):
#done. writes the changes to file specified in global variable filename. #done. writes the changes to file specified in global variable filename.
def write_changes(filename=filename): def write_changes(filename=filename):
#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":
config.set(section,"1"+letter, '"12800"' )
elif letter == "s":
config.set(section,"1"+letter, '"4480"' )
else:
config.set(section,"1"+letter, '"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)
#done. returns what is available in the file. without values. #done. returns what is available in the file. without values. So far unneeded
def get_options(): def get_options():
options = config.options(section) options = config.options(section)
return options return options
#so far unneeded
def get_items(): def get_items():
items = config.items(section) items = config.items(section)
return items return items
#done. #done. Sets level creator's user name
def set_user(username): def set_user(username):
if config.has_option(section, alias["user_name"]): if config.has_option(section, alias["user_name"]):
username = '"' + str(username) + '"' username = '"' + str(username) + '"'
config.set(section, alias["user_name"],username.lower()) config.set(section, alias["user_name"],username.lower())
#done #done. Not tested
def get_user(): def get_user():
if config.has_option(section, alias["user_name"]): if config.has_option(section, alias["user_name"]):
current_username = config.get(section, alias["user_name"]) current_username = config.get(section, alias["user_name"])
return current_username return current_username
def set_tile(x, y, tilename="mm1cuttile", block_type="normal", room_active=1): #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):
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])
#this needs a check to see if the coordinates are already taken, and deal with object-tile conflicts accordingly. #this needs a check to see if the coordinates are already taken, and deal with object-tile conflicts accordingly.
option = 0
error = False
for letter in "kjiea": for letter in "kjiea":
#tile = letter + x16 + "," + y16
#print(type(tile))
option = 0
if letter == "k": if letter == "k":
#unknown, so sample for now #unknown, so sample for now
print("working k") #print("working k")
option = '"106.000"' option = '"106.000"'
elif letter == "j": elif letter == "j":
#unknown #unknown
print("working j") #print("working j")
option = '"71.000"' option = '"71.000"'
elif letter == "i": elif letter == "i":
#according to https://gist.github.com/freem/03d6c1832299e8d8a32f64361380920d this is block type #according to https://gist.github.com/freem/03d6c1832299e8d8a32f64361380920d this is block type
@ -81,24 +92,36 @@ def set_tile(x, y, tilename="mm1cuttile", block_type="normal", room_active=1):
option = '"1.000"' option = '"1.000"'
elif letter == "e": 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. #supposedly this is item sub-type. Leaving default for now. Need to implement a method to have an index of all the tiles.
temp_tilenames = {"mm1cuttile" : '"3.000"'} if tilename in definitions.tile_names:
if tilename in temp_tilenames: option = definitions.tile_names[tilename]
option = temp_tilenames[tilename] else:
return 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, 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:
config.set(section,letter + x16 + "," + y16, option) config.set(section,letter + x16 + "," + y16, option)
else:
return "error in " + str(letter)
def set_level_name(levelname): def set_level_name(levelname):
config.set(section, alias["level_name"],'"' + levelname + '"') config.set(section, alias["level_name"],'"' + levelname + '"')
#def set_room_active(x, y,status=True): #the x and y values have to be the 0,0 relative to the room, so just the one where the tile on the top left corner of a room goes. I'll add this on set tile as a argument. def set_room_active(roomX, roomY,status=True): #the x and y values have to be the 0,0 relative to the room, so just the one where the tile on the top left corner of a room goes. I'll add this on set tile as a argument.
roomX = int(roomX) * 256
roomY = int(roomY) * 224
roomX = str(roomX)
roomY = str(roomY)
room_active = str(alias["room_active"])
if status == True:
status = '"1.000"'
else:
status = '"0.000"'
config.set(section,room_active + roomX + "," + roomY, status)
def set_player(x, y,type="mm", allow_duplicates=0): def set_player(x, y,type="mm", allow_duplicates=0):
@ -127,8 +150,9 @@ def set_player(x, y,type="mm", allow_duplicates=0):
# config.set(section, ) < 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, ) < I'll maybe add the set_player function here, because they are sort of objects. That way everything can be made through here.'
""" """
def del_tile < this will erase the entry for the tile, not just disable it. Maybe optional disable.
def list_tiles < this will return a list of tiles already on the level as a list each one with every of the 5 values for the 5 letters def list_tiles < this will return a list of tiles already on the level as a list each one with every of the 5 values for the 5 letters
def read_tile def is_block_used < this will tell you what is on that coordinate
def default_blank < this is to give a blank canvas for every action. Maybe this will only be used for if a mmlv is blank (example: custom filename on write_changes()) def default_blank < this is to give a blank canvas for every action. Maybe this will only be used for if a mmlv is blank (example: custom filename on write_changes())
def set_setting def set_setting
def set_background def set_background
@ -140,13 +164,23 @@ _|_ _ __|_o._ _ _ .__ ._ _| _
|_(/__> |_|| |(_| (_||(_)|_|| |(_|_> |_(/__> |_|| |(_| (_||(_)|_|| |(_|_>
_| _| _| _|
""" """
# A problem that has to be fixed some day is that EVERY TILE WILL NOT APPEAR ON EDITOR TILL A PLAY TEST. It has something to do with the order in the mmlv file, something that goes beyond the scope of the python configparser. Let's see what happens.. # A problem that has to be fixed some day is that EVERY TILE WILL NOT APPEAR ON EDITOR TILL A PLAY TEST. It has something to do with the 1s, 1q,1p and 1r entries. I set the max value that works but on MMLV Editor the value changes if a tile is more torward the top left. Maybe an algorithm is needed to count every tile from the level and update those values accordingly.
print(get_options()) print(get_options())
print(get_user()) print(get_user())
#set_user("Game FEverOnline") #set_user("Game FEverOnline")
#write_changes() set_level_name("sample")
write_changes() set_user("Python")
count = 0
for column in range(max_y+1):
count += 1
for tile in range(max_x+1):
count += 1
set_tile(tile,column)
set_room_active(max_room_x,max_room_y)
print(count)
write_changes("sample.mmlv")
print(set_player(3, 3))

View file

@ -1,8 +1,5 @@
[Level] [Level]
1t="0.000" 2a12544,4256="1.000"
o0,16="9999.000"
d0,16="4.000"
a0,16="1.000"
2b0,4256="0.000" 2b0,4256="0.000"
2b0,4032="0.000" 2b0,4032="0.000"
2b0,3808="0.000" 2b0,3808="0.000"
@ -23,12 +20,11 @@ a0,16="1.000"
2b0,448="0.000" 2b0,448="0.000"
2b0,224="0.000" 2b0,224="0.000"
2b0,0="0.000" 2b0,0="0.000"
2a0,0="1.000" 1s="4480.000"
1s="352.000"
1r="0.000" 1r="0.000"
1q="288.000" 1q="12800.000"
1p="0.000" 1p="0.000"
1m="9.000" 1m="10.000"
1l="6.000" 1l="6.000"
1k0="0.000" 1k0="0.000"
1bc="0.000" 1bc="0.000"
@ -47,4 +43,3 @@ a0,16="1.000"
1a="sample" 1a="sample"
0v="1.8.4.1" 0v="1.8.4.1"
0a="386743.000" 0a="386743.000"