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_list
is a string (orNone
), it is looked up inphone.config.layer_at_transform
. The transform or list of transforms is then passed torenpy.show_layer_at
along with the other parameters.def short_name(s, length)
Shortens the string
s
after translating it. The string is sliced tolength - 3
and"..."
is appended to it.def path_join(*args)
Computes os.path.join(*args).replace(”\\”, “/”)
def asset(path)
Computes path_join(phone.config.basedir, path)
def execute_default(f, id)
Mimics the behavior of the
default
statement by callingf
if a function with the unique valueid
has never been called before. The function is added toconfig.start_callbacks
andconfig.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_calendar
during init phase, this function is called with the unique value("_phone_add_calendar", month, year, key)
, wheremonth
,year
andkey
are 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
.
Screen Functions and Actions
class PhoneMenu(Action)
The framework’s equivalent of the
ShowMenu
action. Arguments given are passed to thephone.call_screen
function.def call_screen(_screen_name, *args, **kwargs)
The framework’s equivalent of the
renpy.call_screen
function. Invokesrenpy.call_screen
in 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)
The framework’s equvalent of the
Return
action. It should be used to return from a phone screen.menu = False
Indicates 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
PhoneMenu
action (for instance, theBack
textbutton in thephone_discussion
is 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.