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

@ -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.
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:
import configparser, os, definitions
import requests
except ModuleNotFoundError:
print("module not found, please install configparser, requests, os and have the definitions.py in the same folder as mmlv_library.py")
Exception(ModuleNotFoundError)
### init global variables
section = "Level"
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
supported_values = definitions.supported_values
max_x = 799
max_y = 279
max_room_x = 49
max_room_y = 19
###
# converts from multiples of 16 to normal x and y values. for use in reading
def conv_coordinates(x16, y16):
@ -59,6 +60,9 @@ def write_changes(filename="sample.mmlv"):
with open(filename, 'w') as configfile:
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
def get_options():
options = config.options(section)
@ -253,6 +257,16 @@ def set_object(x, y, object_name="energy_element", setting="9999", object_type="
else:
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.'
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