added set_background function

This commit is contained in:
Timothy GFO 2023-09-28 13:49:36 -04:00
parent 389623b3c0
commit dc64b4ed6e
4 changed files with 32 additions and 365559 deletions

View file

@ -40,7 +40,8 @@ aliases = {
"music" : "1m", "music" : "1m",
"track_id" : "1l", "track_id" : "1l",
"spike_subtype" : "l", "spike_subtype" : "l",
"object_type" : "d" "object_type" : "d",
"bg" : "2d"
} }
weapons = { weapons = {
@ -104,7 +105,14 @@ tile_names = {
} }
object_names = { object_names = {
"energy_element" : "15" "energy_element" : "15",
"party_ball" : "16"
} }
background_names = {
"cut" : "115"
}
block_with_coordinates = ["a", "k", "j", "i","e"] block_with_coordinates = ["a", "k", "j", "i","e"]

View file

@ -4,23 +4,24 @@ 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. 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. 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.
""" """
### check if dependencies are met
try: try:
import configparser, os, definitions import configparser, os, definitions
import requests import requests
except ModuleNotFoundError: except ModuleNotFoundError:
print("module not found, please install configparser, requests, os and have the definitions.py in the same folder as mmlv_library.py") print("module not found, please install configparser, requests, os and have the definitions.py in the same folder as mmlv_library.py")
Exception(ModuleNotFoundError) Exception(ModuleNotFoundError)
### init global variables
section = "Level" section = "Level"
config = configparser.ConfigParser() config = configparser.ConfigParser()
#filename = "blank.mmlv"
#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. Todo: Enable Modifying of levels, not just creating.
alias = definitions.aliases alias = definitions.aliases
supported_values = definitions.supported_values supported_values = definitions.supported_values
max_x = 799 max_x = 799
max_y = 279 max_y = 279
max_room_x = 49 max_room_x = 49
max_room_y = 19 max_room_y = 19
###
# converts from multiples of 16 to normal x and y values. for use in reading # converts from multiples of 16 to normal x and y values. for use in reading
def conv_coordinates(x16, y16): def conv_coordinates(x16, y16):
@ -59,6 +60,9 @@ def write_changes(filename="sample.mmlv"):
with open(filename, 'w') as configfile: with open(filename, 'w') as configfile:
config.write(configfile, space_around_delimiters=False) config.write(configfile, space_around_delimiters=False)
def set_global(option, value):
config.set(section, option, value)
#done. returns what is available in the file. without values. So far unneeded #done. returns what is available in the file. without values. So far unneeded
def get_options(): def get_options():
options = config.options(section) options = config.options(section)
@ -253,6 +257,16 @@ def set_object(x, y, object_name="energy_element", setting="9999", object_type="
else: else:
value = "1" value = "1"
config.set(section, f"{key}{x16},{y16}", value) #< I'll maybe add the set_player function here, because they are sort of objects. That way everything can be made through here.' config.set(section, f"{key}{x16},{y16}", value) #< I'll maybe add the set_player function here, because they are sort of objects. That way everything can be made through here.'
def set_background(roomX, roomY, bg_id):
bg_id = str(bg_id)
coor = room_coordinates(roomX, roomY)
x = str(coor[0])
y = str(coor[1])
bg = alias["bg"]
if bg_id in definitions.background_names:
bg_id = definitions.background_names[bg_id]
config.set(section, f"{bg}{x},{y}", bg_id)
""" """
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 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

365555
sample.mmlv

File diff suppressed because it is too large Load diff

View file

@ -28,7 +28,7 @@ mmlv.set_user("Python")
# print(count) # print(count)
mmlv.connect_screen("v", 2, 1) mmlv.connect_screen("v", 2, 1)
mmlv.set_room_active(2, 0) mmlv.set_background(0,0, 115)
mmlv.set_room_active(2, 1) mmlv.set_background(1,0, "cut")
mmlv.write_changes("sample.mmlv") mmlv.write_changes("sample.mmlv")
#del_tile(1,1) #del_tile(1,1)