Functions and Actions
Utility Functions
The following functions, variables and Actions are defined in the phone namespace.
def format_date(month, day, year)Returns a formatted string using
phone.config.date_format.def format_time(hour, minute)Returns a formatted string using
phone.config.time_format.def show_layer_at(at_list, layer="master", camera=True, reset=False)A wrapper around
renpy.show_layer_at. Ifat_listis a string (orNone), it is looked up inphone.config.layer_at_transform. The transform or list of transforms is then passed torenpy.show_layer_atalong with the other parameters.def short_name(s, length)Shortens the string
safter translating it. The string is sliced tolength - 3and"..."is appended to it.def path_join(*args)A wrapper around
os.path.join, replacing backslashes if needed.def asset(path)Computes path_join(phone.config.basedir, path)
def execute_default(f, id)Mimics the behavior of the
defaultstatement by callingfif a function with the unique valueidhas never been called before. The function is added toconfig.start_callbacksandconfig.after_load_callbacks, and in the latter case, if the function is called, rollback will be blocked. A good unique value, for instance, is a tuple where the first component is a string describing what the function does, and where the remaining components are the actual unique value related to whatever the function does. For example, when callingphone.calendar.add_calendarduring init phase, this function is called with the unique value("_phone_add_calendar", month, year, key), wheremonth,yearandkeyare the values passed tophone.calendar.add_calendar.data = {...}The dictionnary that’s storing all of the phone’s in-game data. Each
*character*has an entry (their key) in this dict and will return another dictionnary as described inphone.config.data.NoValue = ...A unique object that’s used when no value is passed to a callable.
Screen Functions and Actions
class PhoneMenu(Action)The framework’s equivalent of the
ShowMenuaction. Arguments given are passed to thephone.call_screenfunction.def call_screen(_screen_name, *args, **kwargs)The framework’s equivalent of the
renpy.call_screenfunction. If the_transitionkeyword argument is passed, it’s the transition ran when showing the screen. Otherwise, it’s taken fromphone.config.enter_transitionandphone.config.intra_transition`. Invokes ``renpy.call_screenin a new context, passing all arguments and keyword arguments to it. This ensures a sort of “depths” effect (going to screen A, then screen B, then screen C, returning brings you back to screen B, and so on).def PhoneReturn(value=None, transition=NoValue)The framework’s equvalent of the
Returnaction. It should be used to return from a phone screen.menu = FalseIndicates whether we’re in a phone menu or not. This is useful when a button is used in a phone screen that’s used both in-game and through the
PhoneMenuaction (for instance, theBacktextbutton in thephone_discussionis disabled during a phone discussion). As it is set byphone.call_screen, this variable should be read-only.
The PhoneReturn and PhoneMenu actions are available in the global store. If their values are overridden during init phase, an error is raised.