diff --git a/definitions.py b/definitions.py new file mode 100644 index 0000000..c9bd8ca --- /dev/null +++ b/definitions.py @@ -0,0 +1,33 @@ +aliases = { + "user_name" : "4a", + "user_id" : "0a", + "level_name" : "1a", + "user_icon" : "4b", + "slide" : "1b", + "charge" : "1d", + "double_damage" : "1ba", + "proto_strike" : "1ca", + "double_jump" : "1bb", + "charge_type" : "1d", + "default_bg_color" : "1e", + "boss_icon" : "1f", + "boss_weak_1_active" : "1ga", + "boss_weak_1" : "1g", + "boss_weak_2_active" : "1ha", + "boss_weak_2" : "1h", + "boss_immunity_active" : "1i", + "boss_immunity" : "1j", + "weapon_slot_0" : "1k0", + "weapon_slot_1" : "1k1", + "weapon_slot_2" : "1k2", + "weapon_slot_3" : "1k3", + "weapon_slot_4" : "1k4", + "weapon_slot_5" : "1k5", + "weapon_slot_6" : "1k6", + "weapon_slot_7" : "1k7", + "weapon_slot_8" : "1k8", + "weapon_slot_9" : "1k9", + "weapon_slot_10" : "1k10", + "weapon_slot_11" : "1k11", + "level_music" : "1m" +} diff --git a/mmlv_library.py b/mmlv_library.py index 37d89d2..0fb5a5c 100644 --- a/mmlv_library.py +++ b/mmlv_library.py @@ -4,12 +4,15 @@ 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 - +import configparser, os, definitions +section = "Level" config = configparser.ConfigParser() -filename = "mmlv.mmlv" +filename = "sample.mmlv" config.read(filename) +alias = definitions.aliases + +#done. converts from multiples of 16 to normal x and y values. for use in reading def conv_coordinates(x16, y16): if x16 < 1 or y16 < 1: x = x16 / 16 @@ -19,23 +22,67 @@ def conv_coordinates(x16, y16): y = 0 return [x, y] +#done. converts from normal x and y values to multiples of 16. for use in writing def conv_coordinates_x16(x, y): x16 = x * 16 y16 = y * 16 return [x16, y16] +#done. writes the changes to file specified in global variable filename. +def write_changes(filename=filename): + with open(filename, 'w') as configfile: + config.write(configfile, space_around_delimiters=False) + +#done. returns what is available in the file. without values. +def get_options(): + options = config.options(section) + return options + +def get_items(): + items = config.items(section) + return items + +#done. +def set_user(username): + if config.has_option(section, alias["user_name"]): + username = '"' + str(username) + '"' + config.set(section, alias["user_name"],username.lower()) +#done +def get_user(): + if config.has_option(section, alias["user_name"]): + current_username = config.get(section, alias["user_name"]) + return current_username + + +def set_tile(tilename, x , y, tile=0): + by16 = conv_coordinates_x16(x, y) + x16 = str(by16[0]) + y16 = str(by16[1]) + for letter in "kjiea": + #tile = letter + x16 + "," + y16 + #print(type(tile)) + config.set(section,letter + x16 + "," + y16, "0") + + """ -def set_tile def read_tile def set_name def set_setting def set_background def set_active """ - -def get_options(): - filename("mmlv.mmlv") - options = config.options("Level") - return options +#def set_ver(gamever) < this may support mega maker's api to get current version.' +""" +_|_ _ __|_o._ _ _ .__ ._ _| _ + |_(/__> |_|| |(_| (_||(_)|_|| |(_|_> + _| _| +""" print(get_options()) +print(get_user()) +#set_user("Game FEverOnline") +#write_changes() +print(get_user()) +set_tile("test",2,2) +write_changes() + diff --git a/sample.mmlv b/sample.mmlv new file mode 100644 index 0000000..851ad8e --- /dev/null +++ b/sample.mmlv @@ -0,0 +1,50 @@ +[Level] +k16,320="106.000" +j16,320="71.000" +i16,320="1.000" +e16,320="3.000" +a16,320="1.000" +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" +2a0,224="1.000" +2b0,0="0.000" +1s="352.000" +1r="288.000" +1q="48.000" +1p="0.000" +1m="9.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"