From 1f2803b1e9eaad1ee1d54c3089af2e50d8f4f3c6 Mon Sep 17 00:00:00 2001 From: Timothy GFO Date: Fri, 1 Sep 2023 23:54:38 -0400 Subject: [PATCH] added set_tile, set_level_name and bug fixes. --- definitions.py | 59 +++++++++++++++++++++++++++- mmlv_library.py | 84 ++++++++++++++++++++++++++++++++-------- sample.mmlv | 100 ++++++++++++++++++++++++------------------------ 3 files changed, 176 insertions(+), 67 deletions(-) diff --git a/definitions.py b/definitions.py index c9bd8ca..dfb7011 100644 --- a/definitions.py +++ b/definitions.py @@ -29,5 +29,62 @@ aliases = { "weapon_slot_9" : "1k9", "weapon_slot_10" : "1k10", "weapon_slot_11" : "1k11", - "level_music" : "1m" + "level_music" : "1m", + "room_active" : "2a" #2aX,Y="1.000" +} + +weapons = { + "M. Buster" : "0", + # 1 = S. Tomahawk + # 2 = W. Storm + # 3 = P. Shot + # 4 = Metal Blade + # 5 = Rush Coil + # 6 = S. Crash + # 7 = Rush Jet + # 8 = Shine + # 9 = Gravity Hold + # 10 = Top Spin + # 11 = Magnet Beam + # 12 = C. Bomber + # 13 = T. Beam + # 14 = R. Cutter + # 15 = F. Stopper + # 16 = Magnet Missile + # 17 = F. Storm + # 18 = S. Snake + # 19 = Quick Boomerang + # 20 = S. Barrier + # 21 = Charge Kick + # 22 = Nado + # 23 = P. Barrier + # 24 = Ring Boomerang + # 25 = Needle Cannon + # 26 = D. Missile + # 27 = Hard Knuckle + # 28 = Atomic Fire + # 29 = P. Freeze + # 30 = T. Slow + # 31 = I. Slasher + # 32 = H. Bomb + # 33 = O. Slider + # 34 = Item-1 + # 35 = Item-2 + # 36 = Item-3 + # 37 = L. Shield + # 38 = A. Shooter + # 39 = G. Laser + # 40 = B. Drop + # 41 = D. Bomb + # 42 = S. Arrow + # 43 = Power Stone + # 44 = W. Wave + # 45 = C. Eye + + +} + +supported_values = { + "weapon_slot" : weapons, + } diff --git a/mmlv_library.py b/mmlv_library.py index d80f4c9..28b6af7 100644 --- a/mmlv_library.py +++ b/mmlv_library.py @@ -8,8 +8,9 @@ import configparser, os, definitions section = "Level" config = configparser.ConfigParser() filename = "sample.mmlv" -config.read(filename) +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. alias = definitions.aliases +supported_values = definitions.supported_values #done. converts from multiples of 16 to normal x and y values. for use in reading @@ -53,32 +54,82 @@ def get_user(): current_username = config.get(section, alias["user_name"]) return current_username - -def set_tile(tilename, x , y, tile=0): +def set_tile(x, y, tilename="mm1cuttile", block_type="normal", 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. for letter in "kjiea": #tile = letter + x16 + "," + y16 #print(type(tile)) - if letter is "k": - #something - elif letter is "j": - #something - elif letter is "i": - #something - elif letter is "e": - #something + option = 0 + if letter == "k": + #unknown, so sample for now + print("working k") + option = '"106.000"' + elif letter == "j": + #unknown + print("working j") + option = '"71.000"' + elif letter == "i": + #according to https://gist.github.com/freem/03d6c1832299e8d8a32f64361380920d this is block type + if block_type == "ladder": + option = '"3.000"' + elif block_type == "spike": + option = '"2.000"' + else: + 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. + temp_tilenames = {"mm1cuttile" : '"3.000"'} + if tilename in temp_tilenames: + option = temp_tilenames[tilename] + return + #print("working e") + #option = '"3.000"' else: - #something + #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...) + print("working a") + option = '"1.000"' - config.set(section,letter + x16 + "," + y16, "0") + config.set(section,letter + x16 + "," + y16, option) + +def set_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_player(x, y,type="mm", allow_duplicates=0): + by16 = conv_coordinates_x16(x, y) + x16 = str(by16[0]) + y16 = str(by16[1]) #Every function that has something like all this should be a funcion. + for letter in "oda": + option = 0 + if letter == "o": + #Unknown + option = '"9999.000"' + elif letter == "d": + #unknown + option = '"4.000"' + else: + option = '"1.000"' + config.set(section,letter + x16 + "," + y16, option) + + + + + + + +#def set_object(object_name): +# 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 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 set_name +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_active @@ -89,12 +140,13 @@ _|_ _ __|_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.. + print(get_options()) print(get_user()) #set_user("Game FEverOnline") #write_changes() -print(get_user()) -set_tile("test",2,2) write_changes() +print(set_player(3, 3)) diff --git a/sample.mmlv b/sample.mmlv index 851ad8e..7ad22f5 100644 --- a/sample.mmlv +++ b/sample.mmlv @@ -1,50 +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" +[Level] +1t="0.000" +o0,16="9999.000" +d0,16="4.000" +a0,16="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" +2b0,0="0.000" +2a0,0="1.000" +1s="352.000" +1r="0.000" +1q="288.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" +