diff --git a/blank.mmlv b/blank.mmlv index 48a9b50..c5152e7 100644 --- a/blank.mmlv +++ b/blank.mmlv @@ -1,24 +1,4 @@ [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" diff --git a/definitions.py b/definitions.py index 959a19f..931d24d 100644 --- a/definitions.py +++ b/definitions.py @@ -40,6 +40,7 @@ aliases = { "music" : "1m", "track_id" : "1l", "spike_subtype" : "l" + "" } weapons = { diff --git a/mmlv_library.py b/mmlv_library.py index 7a543d4..cbce599 100644 --- a/mmlv_library.py +++ b/mmlv_library.py @@ -4,7 +4,12 @@ The goal is to create a library that reads a mmlv file, and then creates variabl and just give it for example, mm1iceman = [1, 2, 3] , the 1 meaning that it's active and the 2 and 3 it's position in space. In the future there will be more inputs for settings of objects. It could also work by calling a function, say place_tile(tilename, x, y) and then do that for every tile placement call. That would separate the placing of tiles from the placing of objects and more. """ -import configparser, os, definitions + +try: + import configparser, os, definitions + import requests +except ModuleNotFoundError: + print("module not found, please install configparser, requests, os and have the definitions.py in the same folder as mmlv_library.py") section = "Level" config = configparser.ConfigParser() #filename = "blank.mmlv" @@ -63,6 +68,16 @@ def get_items(): items = config.items(section) return items + +def set_setting(alias_or_code,value,code=False): + if not code: + alias_or_code = alias[alias_or_code] + + else: + alias_or_code = str(alias_or_code) + value = set_apos(value) + config.set(section, alias_or_code, value) + #done. Sets level creator's user name def set_user(username): if config.has_option(section, alias["user_name"]): @@ -75,6 +90,19 @@ def get_user(): return current_username +def is_block_used(x, y, details=False): + conv_list = conv_coordinates_x16(x, y) + x = conv_list[0] + y = conv_list[1] + for letter in definitions.block_with_coordinates: + current = letter + str(x) + "," + str(y) + try: + answ_option = config[section][current] + return True + except KeyError: + return False + #this will optionally report WHAT is actually in there. + 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, k_value) config.set(section,letter + posX_16 + "," + posY_16, j_value) @@ -82,13 +110,16 @@ 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, e_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. def set_tile(x, y, tilename="mm1cuttile", block_type="normal", tile_subtype=False, room_active=1): by16 = conv_coordinates_x16(x, y) x16 = str(by16[0]) y16 = str(by16[1]) - #this needs a check to see if the coordinates are already taken, and deal with object-tile conflicts accordingly. + + if is_block_used(x, y): + #this needs a check to see if the coordinates are already taken, and deal with object-tile conflicts accordingly. + opt = get_options() + #WIP option = 0 error = False @@ -163,37 +194,36 @@ def set_player(x, y,type="mm", allow_duplicates=0): option = '"1.000"' config.set(section,letter + x16 + "," + y16, option) - -def is_block_used(x, y, details=False): - conv_list = conv_coordinates_x16(x, y) - x = conv_list[0] - y = conv_list[1] - for letter in definitions.block_with_coordinates: - current = letter + str(x) + "," + str(y) - try: - answ_option = config[section][current] - return True - except KeyError: - return False - #this will optionally report WHAT is actually in there. - def del_tile(x,y,disable=False): for letter in definitions.block_with_coordinates: current = letter + str(x) + ',' + str(y) config.remove_option(section, current) +def set_ver(version=False): + if not version: + api_version = "https://api.megamanmaker.com/version" + ver = requests.get(api_version) + ver_num = ver.json()["version"] + else: + ver_num = version + set_setting(alias["game_version"], ver_num, True) + + #def set_object(x, y, object_name, setting1): # 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.' """ < 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 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_background """ #def set_ver(gamever) < this may support mega maker's api to get current version.' # 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. - +read_file() +print(get_options()) +set_setting("level_name", "does this work?") +set_ver() +write_changes("sample.mmlv") diff --git a/sample.mmlv b/sample.mmlv index 6f878b0..f62ce64 100644 --- a/sample.mmlv +++ b/sample.mmlv @@ -1,45 +1,37 @@ -[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="4480" -1r="0" -1q="12800" -1p="0" -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="python" -1a="sample" -0v="1.8.4.1" -0a="386743.000" - +[Level] +k256,0="141.000" +j256,0="106.000" +i256,0="1.000" +e256,0="3.000" +a256,0="1.000" +k0,0="71.000" +j0,0="71.000" +i0,0="1.000" +e0,0="3.000" +a0,0="1.000" +2b256,0="1.000" +2a256,0="1.000" +2a0,0="1.000" +1s="4464.000" +1r="0.000" +1q="12784.000" +1p="0.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.5" +0a="386743.000"