mirror of
https://gitlab.com/GameFeverOnline/py-mmlv.git
synced 2025-12-19 02:08:04 -04:00
Added set object
This commit is contained in:
parent
a894caba0a
commit
e55abe2c92
4 changed files with 365644 additions and 59 deletions
|
|
@ -39,8 +39,8 @@ aliases = {
|
|||
"boss_count" : "1bc",
|
||||
"music" : "1m",
|
||||
"track_id" : "1l",
|
||||
"spike_subtype" : "l"
|
||||
""
|
||||
"spike_subtype" : "l",
|
||||
"object_type" : "d"
|
||||
}
|
||||
|
||||
weapons = {
|
||||
|
|
@ -103,4 +103,8 @@ tile_names = {
|
|||
"mm1cuttile" : '"3.000"'
|
||||
}
|
||||
|
||||
object_names = {
|
||||
"energy_element" : "15"
|
||||
}
|
||||
|
||||
block_with_coordinates = ["a", "k", "j", "i","e"]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ try:
|
|||
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)
|
||||
section = "Level"
|
||||
config = configparser.ConfigParser()
|
||||
#filename = "blank.mmlv"
|
||||
|
|
@ -46,7 +47,7 @@ def set_apos(object):
|
|||
def read_file(filename="blank.mmlv"):
|
||||
config.read(filename)
|
||||
|
||||
def write_changes(filename="blank.mmlv"):
|
||||
def write_changes(filename="sample.mmlv"):
|
||||
#Well well well... this for loop is here to make every thing work. I'm not sure for what the 1s, 1q,1r and 1p keys are, but if they are the same as a blank mmlv created by mmm, it just doesn't work. It's weird.'
|
||||
for letter in "srqp":
|
||||
if letter == "q":
|
||||
|
|
@ -164,6 +165,13 @@ def set_tile(x, y, tilename="mm1cuttile", block_type="normal", tile_subtype=Fals
|
|||
def set_level_name(levelname):
|
||||
config.set(section, alias["level_name"],set_apos(levelname))
|
||||
|
||||
def room_coordinates(roomX, roomY):
|
||||
x = int(roomX) * 256
|
||||
y = int(roomY) * 224
|
||||
x = str(x)
|
||||
y = str(y)
|
||||
return [x, y]
|
||||
|
||||
def set_room_active(roomX, roomY,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.
|
||||
|
||||
roomX = int(roomX) * 256
|
||||
|
|
@ -199,6 +207,7 @@ def del_tile(x,y,disable=False):
|
|||
current = letter + str(x) + ',' + str(y)
|
||||
config.remove_option(section, current)
|
||||
|
||||
#sets version variable in mmlv file. If 'version' argument is False it will reach for MMM's api to get current version.'
|
||||
def set_ver(version=False):
|
||||
if not version:
|
||||
api_version = "https://api.megamanmaker.com/version"
|
||||
|
|
@ -208,22 +217,47 @@ def set_ver(version=False):
|
|||
ver_num = version
|
||||
set_setting(alias["game_version"], ver_num, True)
|
||||
|
||||
#this needs the same calculations of the room active function
|
||||
def connect_screen(h_or_v, roomX, roomY):
|
||||
coord = room_coordinates(roomX, roomY)
|
||||
x = coord[0]
|
||||
y = coord[1]
|
||||
if h_or_v == "h".lower():
|
||||
config.remove_option(section, f"2b{x},{y}")
|
||||
else:
|
||||
print(x)
|
||||
config.set(section, f"2c{x},{y}", "1")
|
||||
|
||||
def disconnect_screen(h_or_v, x, y):
|
||||
coord = room_coordinates(roomX, roomY)
|
||||
x = coord[0]
|
||||
y = coord[1]
|
||||
if h_or_v == "h".lower():
|
||||
config.set(section, f"2b{x},{y}", "0")
|
||||
else:
|
||||
config.remove_option(section, f"2c{x},{y}")
|
||||
|
||||
#def set_object(x, y, object_name, setting1):
|
||||
# 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 set_object(x, y, object_name="energy_element", setting="9999", object_type="8"):
|
||||
by16 = conv_coordinates_x16(x, y)
|
||||
x16 = str(by16[0])
|
||||
y16 = str(by16[1])
|
||||
for key in "oeda":
|
||||
if key == "o":
|
||||
#mysteries continue. Maybe setting?
|
||||
value = setting
|
||||
elif key == "e":
|
||||
value = definitions.object_names[object_name]
|
||||
elif key == "d":
|
||||
#this is like the object_type?
|
||||
value = 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.'
|
||||
"""
|
||||
< this will erase the entry for the tile, not just disable it. Maybe optional disable.
|
||||
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 set_background
|
||||
"""
|
||||
#def set_ver(gamever) < this may support mega maker's api to get current version.'
|
||||
|
||||
# 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 1s, 1q,1p and 1r entries. I set the max value that works but on MMLV Editor the value changes if a tile is more torward the top left. Maybe an algorithm is needed to count every tile from the level and update those values accordingly.
|
||||
read_file()
|
||||
print(get_options())
|
||||
set_setting("level_name", "does this work?")
|
||||
set_ver()
|
||||
write_changes("sample.mmlv")
|
||||
|
||||
|
|
|
|||
365580
sample.mmlv
365580
sample.mmlv
File diff suppressed because it is too large
Load diff
|
|
@ -12,16 +12,23 @@ mmlv.read_file()
|
|||
print(mmlv.get_user())
|
||||
mmlv.set_level_name("sample")
|
||||
mmlv.set_user("Python")
|
||||
count = 0
|
||||
#for column in range(max_y+1):
|
||||
# count = 0
|
||||
# four = 0
|
||||
# for column in range(mmlv.max_y+1):
|
||||
# four += 1
|
||||
# count += 1
|
||||
#
|
||||
# for tile in range(max_x+1):
|
||||
# print(column)
|
||||
# if four == 4:
|
||||
# four = 0
|
||||
# for tile in range(mmlv.max_x+1):
|
||||
# count += 1
|
||||
# set_tile(tile,column)
|
||||
#set_room_active(max_room_x,max_room_y)
|
||||
#set_tile(1,1)
|
||||
# #print(str(tile)+"tile")
|
||||
# mmlv.set_tile(tile,column)
|
||||
#mmlv.set_room_active(mmlv.max_room_x,mmlv.max_room_y)
|
||||
|
||||
print(count)
|
||||
# print(count)
|
||||
mmlv.connect_screen("v", 2, 1)
|
||||
mmlv.set_room_active(2, 0)
|
||||
mmlv.set_room_active(2, 1)
|
||||
mmlv.write_changes("sample.mmlv")
|
||||
#del_tile(1,1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue