added set_tile, set_level_name and bug fixes.

This commit is contained in:
Timothy GFO 2023-09-01 23:54:38 -04:00
parent caf0c975a2
commit 1f2803b1e9
3 changed files with 176 additions and 67 deletions

View file

@ -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))