diff --git a/game/mods_example/template/chapter2_redo.rpy b/game/mods_example/template/chapter2_redo.rpy index f3fa1275..571d44bd 100644 --- a/game/mods_example/template/chapter2_redo.rpy +++ b/game/mods_example/template/chapter2_redo.rpy @@ -1,13 +1,16 @@ - label chapter_2_new: - show template_sample at scenter + + python: + mine = mod_loader.get(myid) + renpy.show(mine['template_sample']) "Sample Text" - hide template_sample + $ renpy.hide(mine['template_sample']) play music 'audio/OST/Those Other Two Weirdos.ogg' show anon neutral flip at aright with dissolve A "Sample Text" + F "Sample Text" Lucy "Sample Text" Ro "Sample Text" diff --git a/game/mods_example/template/storyline_ex.rpy b/game/mods_example/template/storyline_ex.rpy index ab3f492a..b48b90ea 100644 --- a/game/mods_example/template/storyline_ex.rpy +++ b/game/mods_example/template/storyline_ex.rpy @@ -1,15 +1,18 @@ -init python: + +init 100 python: # Modding Support variables # All mod rpy files must have title of their mod (this shows up on a button) # and finally the label that controls the flow of dialogue - mod_menu_access += [{ - 'Name': "Example Mod Name", - 'Label': "storyline_ex" - }]; + myid = mod_loader.add_mod("Example Mod Name", "storyline_ex") + mod_loader.add_image('template_sample', "mods_example/template/img/sample.png") -image template_sample = Image("mods_example/template/img/sample.png") + #renpy.image('template_sample', mod_dir+"template/img/sample.png") + +#mod_variable[0]["template_sample"] + +#image template_sample = Image("mods_example/template/img/sample.png") label storyline_ex: call chapter_2_new diff --git a/game/script.rpy b/game/script.rpy index 6db6302d..d059ea7f 100644 --- a/game/script.rpy +++ b/game/script.rpy @@ -13,11 +13,43 @@ #Why yes all my code was formerly in one massive file called "script" thats 28k lines long, how could you tell? #Licensed under the GNU AGPL v3, for more information check snootgame.xyz or the LICENSE file that should have came with this work. -init -1 python: +init -3 python: # Modding Support variables # All mod rpy files must run a small init python script - mod_dir = "mods/"; - mod_menu_access = []; + class ModLoader(): + def __init__(self): + self.mod_dir = "mods/" + self.mod_menu_access = [] + self.mod_id = -1 + self.mod_variables = [] + + def add_mod(self, name, label): + self.mod_menu_access += [{ + 'Name': name, + 'Label': label + }] + self.mod_id += 1 + self.mod_variables.append({}) + return self.mod_id + + # name, filename + def add_image(self, name, filename): + s = str(self.mod_id)+name + renpy.image(s, Image(filename)) +#z = renpy.get_registered_image(s) +#self.mod_variables[self.mod_id][name] = z + self.mod_variables[self.mod_id][name] = s + print(self.mod_variables[self.mod_id]) + + def add_variable(name, default): + self.mod_variables[self.mod_id][name] = default + + def get(self, _id): + return self.mod_variables[_id] + + + mod_loader = ModLoader() + init python: import random diff --git a/game/src/mod_menu.rpy b/game/src/mod_menu.rpy index 6085dc67..826f577a 100644 --- a/game/src/mod_menu.rpy +++ b/game/src/mod_menu.rpy @@ -67,7 +67,7 @@ screen mod_menu(): #buttons are messed up but that's ok use mod_menu_button("gui/button/menubuttons/template_idle.png", "Return", ShowMenu("main_menu")) - if len(mod_menu_access) is not 0: - use mod_menu_buttons("gui/button/menubuttons/template_idle.png", mod_menu_access ) + if len(mod_loader.mod_menu_access) is not 0: + use mod_menu_buttons("gui/button/menubuttons/template_idle.png", mod_loader.mod_menu_access ) else: use mod_menu_button("gui/button/menubuttons/template_idle.png", "You have no mods", None)