Custom screen changing a flag past a certain point.
Hello! I’ve been working on a game heavily relying on an inventory system for the past year or 2, and just when I thought I finally had everything in order, there’s one more glitch plaguing it.
This glitch involves a flag called the AltArrow. Essentially, the AltArrow determines the behaviour of the inventory system’s cancel button. If you cancel with AltArrow off, the game just returns to where you were. If you cancel with AltArrow on, the game sends you to what I call The TimeRoom, where a bunch of flags determine where you should jump to next based on what other flags or variables are active. It's a situational flag, but it works for what I need it for.
screen hud():
modal False
imagebutton auto "bg_hud_thoughtinventory_%s.png":
focus_mask True
hovered SetVariable("screen_tooltip", "Thought_Inventory")
unhovered SetVariable("screen_tooltip", "")
action Show("thought_inventory"), Hide("hud"), SetVariable("quick_menu", False)
screen thought_inventory():
default hovered_thought = None
add "bg_thoughtinventory":
align (0.5, 1.0)
modal True
frame:
#(This is just some debug stuff I have in here just in case)
vbox:
xalign 0.895 yalign 0.20
xysize 0.06,0.05
if AltArrow == True:
text "AltArrow is On"
else:
text "AltArrow Is Off"
vbox:
xalign 0.895 yalign 0.40
xysize 0.06,0.05
if player.is_alone:
text "You're Alone"
else:
text "Someone's Here"
align (0.2, 0.6)
xysize (800,700)
viewport:
scrollbars "vertical"
mousewheel True
draggable True
side_yfill True
vbox:
for thought in thought_inventory.thoughts:
button:
text "[thought.name]\n" style "button_text"
if player.is_alone:
action Function(player.show_thought, thought) pos 0.1, 0.5
hovered SetScreenVariable("hovered_thought", thought)
else:
action SetVariable("quick_menu", True), Function(player.show_thought, thought) pos 0.1, 0.5
hovered SetScreenVariable("hovered_thought", thought)
if hovered_thought:
frame:
align (0.845, 0.944)
xysize (550, 535)
text "{size=*0.80}[hovered_thought.description]{/size}"
add hovered_thought.icon pos -0.0054, -0.5927
imagebutton auto "thoughtinventoryscreen_return_%s.png":
focus_mask True
hovered SetVariable("screen_tooltip", "Return")
unhovered SetVariable("screen_tooltip", "")
#THIS IS WHERE THE PROBLEM ACTUALLY STARTS.
if AltArrow == True:
action SetVariable("quick_menu", True), Hide("thought_inventory"), Jump("TimeRoom"), Show("hud"), Return()
else:
action SetVariable("quick_menu", True), Hide("thought_inventory"), Show("hud")
Everything works out, except when you pass this point in the script:
label Mary_TalkSession1:
$ AltArrow = True
$ Session_Active = True
show screen UnfinishedBar
show screen hud
show screen calender
show mary neutral
$ player.add_person(m_obj)
if mm <= -30:
show mary sad
menu:
"{i}{color=#2731c2}Ask Her A Question{/color}{/i}":
jump Mary_AskSession1
"{i}{color=#2731c2}Bring Up A Thought{/color}{/i}":
$ quick_menu = False
hide screen hud
call screen thought_inventory
"{i}{color=#2731c2}Think For A Bit{/color}{/i}":
jump Your_AskSession1
"{i}{color=#2731c2}End Session{/color}{/i}":
jump Mary_AreYouSure1
label Mary_AreYouSure1:
n "{i}{color=#9c2cdd}(...I think I have nothing left to ask.){/color}{/i}"
Qm "You sure?"
menu:
"Yeah.":
jump Concluding_Session1
"On second thought...":
jump NotDoneSession1
label NotDoneSession1:
n "On second thought, there is something I should ask."
jump Mary_TalkSession1
This is the set-up for the conversation menu, where you can control what you bring up with characters.
When the game passes this point, the HUD changes. Whenever you click the hud button, AltArrow is switched on automatically no matter what, and you can’t exit the menu without transporting to the timeroom, which softlocks the game.
There is no part of any screen code which controls when AltArrow is switched on and off. It only detects when AltArrow is flicked on by the script itself.
And everything works perfectly before that point. AltArrow is getting shut off and staying off no matter how many times I open the inventory. Hell, if I put a shortcut that skips this section entirely, the code still works!
For clarification, I did once try to have AltArrow’s flag be triggered by the menu buttons, but that code is long gone. I don't even remember the details. I’ve recomplied since then, and even if it was still somehow being read, I can’t figure out why it would only activate after that point. I have tried putting hashtags in front of each line at the beginning, and the glitch still stays.
I have absolutely no idea what’s going on. I’m hoping somebody else might. I don't know if it will help, but here's some additional relevant inventory code if you need that context.
init python:
class Thought_Inventory():
def __init__(self, thoughts=None):
self.thoughts = thoughts if thoughts else []
self.no_of_thoughts = len(self.thoughts)
def add_thought(self, thought):
if thought not in self.thoughts:
self.thoughts.append(thought)
self.no_of_thoughts += 1
def remove_thought(self, thought):
if thought in self.thoughts:
self.thoughts.remove(thought)
self.no_of_thoughts -= 1
class Thought():
def __init__(self, name, description, icon):
self.name = name
self.description = description
self.icon = icon
def __str__(self):
return self.name
def __eq__(self, other):
if isinstance(other, Thought):
return self.name == other.name
else:
return False
init python:
class Actor:
def __init__(self, name, character, thoughts=[]):
self.name = name
self.character = character
self.thoughts = thoughts
def __str__(self):
return self.name
def react_on_thought(self, thought_name):
for thought in self.thoughts:
if thought[0] == thought_name:
return [self.character, thought[1]]
class Player():
def __init__(self, name):
self.name = name
self.is_with_list = []
def __str__(self):
return self.name
u/property
def is_alone(self):
return not self.is_with_list
def add_person(self, person):
if person not in self.is_with_list:
self.is_with_list.append(person)
def remove_person(self, person):
if person in self.is_with_list:
self.is_with_list.remove(person)
def show_thought(self, thought_name, label=False):
reactions = []
for char in self.is_with_list:
character_reaction = char.react_on_thought(thought_name)
if character_reaction:
if renpy.has_label(character_reaction[1]):
renpy.call(character_reaction[1])
else:
reactions.append(character_reaction)
if reactions:
renpy.show_screen("reaction_screen", reactions)