Skip to content


David Roberts edited this page Dec 19, 2015 · 8 revisions

The level variable can be accessed anywhere, from any object. It returns a variety of values accessible via the dot operator. For example, to get a list of objects in the level, we might ask for level.chars. Here is a list of all the data in level:

name description
active_chars r A list of every active object in the level. An inactive object doesn't have (engine?) events fired on it and doesn't draw to screen.
camera_position rw Returns list containing the upper-left corner x/y coordinates of the screen and the width/height of the screen. It may be set to a two-element list containing an x/y pair to instantly snap the camera to a position. Note that, unlike most variables, the value you set it to is different than the value it returns.
chars_immune_from_freeze w Deprecated. Pause and resume individual objects and the level instead. An object in this list will not have time frozen when level.time_freeze is set.
chars r Contains a list of every object in the level. (History: The name 'chars' is a holdover from the earliest days of Anura, when we did not have custom objects at all.)
cycle rw An integer value telling how many frames have passed since the level was loaded. If you've paused the level, you can increment this manually if you need to.
debug_properties rw A list of variables of each object to print on-screen, in front of the object. Example: In the debug console, try set(level.debug_properties, ['type', 'x', 'y', 'hitpoints']).
dimensions rw A list in the format of xyxy describing the level boundaries.
editor_selection r A list containing the currently selected objects in the editor.
focus rw Set to an object, such as Berd, to have the engine camera look at it. There is also an object-based camera controller you can use for finer-grained control.
gui r Obsolete. Originally used to set properties for the engine-powered GUI. (It's much easier to make a gui with normal in-level objects. Use use_absolute_screen_coordinates: true to make them display in screen-space as opposed to level-space.)
id r The id of the level. (Must be its file name or the editor will write to the wrong file.)
in_dialog rw true if an engine-powered speech dialog is in progress.
in_editor r true if engine editor is open
is_paused r true if the game is currently paused. Useful in some cases in the editor.
local_player r In a multiplayer game, returns the local player. Since multiplayer was removed, however, this variable is equivalent to player.
lock_screen w Set to lock the level camera somewhere. For fine-grained control, use instead the camera_controller object.
num_active r Probably related to arcade mode level segments.
num_segments r Probably related to arcade mode level segments.
player rw The player object.
segment_height r The height, in world coordinates, of arcade mode level segments.
segment_width r The width, in world coordinates, of arcade mode level segments.
suspended_level rw The victim of the most recently suspend_level('level.cfg') call. Effectively the top of a stack of levels. Reading this stops anura with an error if there is no suspended level.
time_freeze rw Deprecated. Pause and resume individual objects and the level instead. Setting this to a number greater than 1000 pauses objects not in the chars_immune_from_freeze list. Decrements by 1000 each frame if greater than 1000.
zoom rw How zoomed in on the level we are. Default 1. Set to 2 for a double-sized level, and to 0.5 for a half-sized level. Note that objects' animations have a default scale of 2, which is why they appear pixelated by default.
Something went wrong with that request. Please try again.