mirror of
https://gitlab.com/GameFeverOnline/py-mmlv.git
synced 2025-12-18 17:57:42 -04:00
88 lines
2.7 KiB
Python
88 lines
2.7 KiB
Python
# A Mega Man Maker MMLV Library/Module By Timothy J. (GameFeverOnline, www.youtube.com/@GameFeverOnline)
|
|
"""
|
|
The goal is to create a library that reads a mmlv file, and then creates variables for each object, tile, background, etc... So that you could on another program import this as a module
|
|
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
|
|
section = "Level"
|
|
config = configparser.ConfigParser()
|
|
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
|
|
y = y16 / 16
|
|
else:
|
|
x = 0
|
|
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 read_tile
|
|
def set_name
|
|
def set_setting
|
|
def set_background
|
|
def set_active
|
|
"""
|
|
#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()
|
|
|