_bascenev1 module¶
A dummy stub module for the real _bascenev1.
The real _bascenev1 is a compiled extension module and only available in the live engine. This dummy-module allows Pylint/Mypy/etc. to function reasonably well outside of that environment.
Make sure this file is never included in dirs seen by the engine!
In the future perhaps this can be a stub (.pyi) file, but we will need to make sure that it works with all our tools (mypy, pylint, pycharm).
NOTE: This file was autogenerated by batools.dummymodule; do not edit by hand.
- class _bascenev1.ActivityData[source]¶
Bases:
object
(internal)
- context() bascenev1.ContextRef [source]¶
Return a context-ref pointing to the activity.
- class _bascenev1.BaseTimer(time: float, call: Callable[[], Any], repeat: bool = False)[source]¶
Bases:
object
Timers are used to run code at later points in time.
Category: General Utility Classes
This class encapsulates a base-time timer in the current scene context. The underlying timer will be destroyed when either this object is no longer referenced or when its Context (Activity, etc.) dies. If you do not want to worry about keeping a reference to your timer around, you should use the bascenev1.basetimer() function instead.
###### time (float) > Length of time in seconds that the timer will wait before firing.
###### call (Callable[[], Any]) > A callable Python object. Remember that the timer will retain a strong reference to the callable for as long as it exists, so you may want to look into concepts such as babase.WeakCall if that is not desired.
###### repeat (bool) > If True, the timer will fire repeatedly, with each successive firing having the same delay as the first.
##### Example
Use a BaseTimer object to print repeatedly for a few seconds: >>> import bascenev1 as bs … def say_it(): … bs.screenmessage(‘BADGER!’) … def stop_saying_it(): … global g_timer … g_timer = None … bs.screenmessage(‘MUSHROOM MUSHROOM!’) … # Create our timer; it will run as long as we have the self.t ref. … g_timer = bs.BaseTimer(0.3, say_it, repeat=True) … # Now fire off a one-shot timer to kill it. … bs.basetimer(3.89, stop_saying_it)
- class _bascenev1.CollisionMesh[source]¶
Bases:
object
A reference to a collision-mesh.
Category: Asset Classes
Use bascenev1.getcollisionmesh() to instantiate one.
- class _bascenev1.Data[source]¶
Bases:
object
A reference to a data object.
Category: Asset Classes
Use bascenev1.getdata() to instantiate one.
- getvalue() Any [source]¶
Return the data object’s value.
This can consist of anything representable by json (dicts, lists, numbers, bools, None, etc). Note that this call will block if the data has not yet been loaded, so it can be beneficial to plan a short bit of time between when the data object is requested and when it’s value is accessed.
- class _bascenev1.InputDevice[source]¶
Bases:
object
An input-device such as a gamepad, touchscreen, or keyboard.
Category: Gameplay Classes
- allows_configuring: bool¶
Whether the input-device can be configured in the app.
- allows_configuring_in_system_settings: bool¶
Whether the input-device can be configured in the system. setings app. This can be used to redirect the user to go there if they attempt to configure the device.
- client_id: int¶
The numeric client-id this device is associated with. This is only meaningful for remote client inputs; for all local devices this will be -1.
- detach_from_player() None [source]¶
Detach the device from any player it is controlling.
This applies both to local players and remote players.
- get_axis_name(axis_id: int) str [source]¶
Given an axis ID, return the name of the axis on this device.
Can return an empty string if the value is not meaningful to humans.
- get_button_name(button_id: int) babase.Lstr [source]¶
Given a button ID, return a human-readable name for that key/button.
Can return an empty string if the value is not meaningful to humans.
- get_default_player_name() str [source]¶
(internal)
Returns the default player name for this device. (used for the ‘random’ profile)
- get_v1_account_name(full: bool) str [source]¶
Returns the account name associated with this device.
(can be used to get account names for remote players)
- has_meaningful_button_names: bool¶
Whether button names returned by this instance match labels on the actual device. (Can be used to determine whether to show them in controls-overlays, etc.).
- id: int¶
The unique numeric id of this device.
- instance_number: int¶
The number of this device among devices of the same type.
- is_attached_to_player() bool [source]¶
Return whether this device is controlling a player of some sort.
This can mean either a local player or a remote player.
- is_controller_app: bool¶
Whether this input-device represents a locally-connected controller-app.
- is_remote_client: bool¶
Whether this input-device represents a remotely-connected client.
- is_test_input: bool¶
Whether this input-device is a dummy device for testing.
- name: str¶
The name of the device.
- player: bascenev1.SessionPlayer | None¶
The player associated with this input device.
- unique_identifier: str¶
A string that can be used to persistently identify the device, even among other devices of the same type. Used for saving prefs, etc.
- class _bascenev1.Material(label: str | None = None)[source]¶
Bases:
object
An entity applied to game objects to modify collision behavior.
Category: Gameplay Classes
A material can affect physical characteristics, generate sounds, or trigger callback functions when collisions occur.
Materials are applied to ‘parts’, which are groups of one or more rigid bodies created as part of a bascenev1.Node. Nodes can have any number of parts, each with its own set of materials. Generally materials are specified as array attributes on the Node. The spaz node, for example, has various attributes such as materials, roller_materials, and punch_materials, which correspond to the various parts it creates.
Use bascenev1.Material to instantiate a blank material, and then use its babase.Material.add_actions() method to define what the material does.
- add_actions(actions: tuple, conditions: tuple | None = None) None [source]¶
Add one or more actions to the material, optionally with conditions.
##### Conditions Conditions are provided as tuples which can be combined to form boolean logic. A single condition might look like (‘condition_name’, cond_arg), or a more complex nested one might look like ((‘some_condition’, cond_arg), ‘or’, (‘another_condition’, cond2_arg)).
‘and’, ‘or’, and ‘xor’ are available to chain together 2 conditions, as seen above.
##### Available Conditions ###### (‘they_have_material’, material) > Does the part we’re hitting have a given bascenev1.Material?
###### (‘they_dont_have_material’, material) > Does the part we’re hitting not have a given bascenev1.Material?
###### (‘eval_colliding’) > Is ‘collide’ true at this point in material evaluation? (see the modify_part_collision action)
###### (‘eval_not_colliding’) > Is ‘collide’ false at this point in material evaluation? (see the modify_part_collision action)
###### (‘we_are_younger_than’, age) > Is our part younger than age (in milliseconds)?
###### (‘we_are_older_than’, age) > Is our part older than age (in milliseconds)?
###### (‘they_are_younger_than’, age) > Is the part we’re hitting younger than age (in milliseconds)?
###### (‘they_are_older_than’, age) > Is the part we’re hitting older than age (in milliseconds)?
###### (‘they_are_same_node_as_us’) > Does the part we’re hitting belong to the same bascenev1.Node as us?
###### (‘they_are_different_node_than_us’) > Does the part we’re hitting belong to a different bascenev1.Node?
##### Actions In a similar manner, actions are specified as tuples. Multiple actions can be specified by providing a tuple of tuples.
##### Available Actions ###### (‘call’, when, callable) > Calls the provided callable; when can be either ‘at_connect’ or ‘at_disconnect’. ‘at_connect’ means to fire when the two parts first come in contact; ‘at_disconnect’ means to fire once they cease being in contact.
###### (‘message’, who, when, message_obj) > Sends a message object; who can be either ‘our_node’ or ‘their_node’, when can be ‘at_connect’ or ‘at_disconnect’, and message_obj is the message object to send. This has the same effect as calling the node’s babase.Node.handlemessage() method.
###### (‘modify_part_collision’, attr, value) > Changes some characteristic of the physical collision that will occur between our part and their part. This change will remain in effect as long as the two parts remain overlapping. This means if you have a part with a material that turns ‘collide’ off against parts younger than 100ms, and it touches another part that is 50ms old, it will continue to not collide with that part until they separate, even if the 100ms threshold is passed. Options for attr/value are: ‘physical’ (boolean value; whether a physical response will occur at all), ‘friction’ (float value; how friction-y the physical response will be), ‘collide’ (boolean value; whether any collision will occur at all, including non-physical stuff like callbacks), ‘use_node_collide’ (boolean value; whether to honor modify_node_collision overrides for this collision), ‘stiffness’ (float value, how springy the physical response is), ‘damping’ (float value, how damped the physical response is), ‘bounce’ (float value; how bouncy the physical response is).
###### (‘modify_node_collision’, attr, value) > Similar to modify_part_collision, but operates at a node-level. collision attributes set here will remain in effect as long as anything from our part’s node and their part’s node overlap. A key use of this functionality is to prevent new nodes from colliding with each other if they appear overlapped; if modify_part_collision is used, only the individual parts that were overlapping would avoid contact, but other parts could still contact leaving the two nodes ‘tangled up’. Using modify_node_collision ensures that the nodes must completely separate before they can start colliding. Currently the only attr available here is ‘collide’ (a boolean value).
###### (‘sound’, sound, volume) > Plays a bascenev1.Sound when a collision occurs, at a given volume, regardless of the collision speed/etc.
###### (‘impact_sound’, sound, targetImpulse, volume) > Plays a sound when a collision occurs, based on the speed of impact. Provide a bascenev1.Sound, a target-impulse, and a volume.
###### (‘skid_sound’, sound, targetImpulse, volume) > Plays a sound during a collision when parts are ‘scraping’ against each other. Provide a bascenev1.Sound, a target-impulse, and a volume.
###### (‘roll_sound’, sound, targetImpulse, volume) > Plays a sound during a collision when parts are ‘rolling’ against each other. Provide a bascenev1.Sound, a target-impulse, and a volume.
##### Examples Example 1: create a material that lets us ignore collisions against any nodes we touch in the first 100 ms of our existence; handy for preventing us from exploding outward if we spawn on top of another object: >>> m = bascenev1.Material() … m.add_actions( … conditions=((‘we_are_younger_than’, 100), … ‘or’, (‘they_are_younger_than’, 100)), … actions=(‘modify_node_collision’, ‘collide’, False))
Example 2: send a bascenev1.DieMessage to anything we touch, but cause no physical response. This should cause any bascenev1.Actor to drop dead: >>> m = bascenev1.Material() … m.add_actions( … actions=((‘modify_part_collision’, ‘physical’, False), … (‘message’, ‘their_node’, ‘at_connect’, … bascenev1.DieMessage())))
Example 3: play some sounds when we’re contacting the ground: >>> m = bascenev1.Material() … m.add_actions( … conditions=(‘they_have_material’, shared.footing_material), … actions=(
(‘impact_sound’, bascenev1.getsound(‘metalHit’), 2, 5), (‘skid_sound’, bascenev1.getsound(‘metalSkid’), 2, 5)))
- label: str¶
A label for the material; only used for debugging.
- class _bascenev1.Mesh[source]¶
Bases:
object
A reference to a mesh.
Category: Asset Classes
Meshes are used for drawing. Use bascenev1.getmesh() to instantiate one.
- class _bascenev1.Node[source]¶
Bases:
object
Reference to a Node; the low level building block of a game.
Category: Gameplay Classes
At its core, a game is nothing more than a scene of Nodes with attributes getting interconnected or set over time.
A bascenev1.Node instance should be thought of as a weak-reference to a game node; not the node itself. This means a Node’s lifecycle is completely independent of how many Python references to it exist. To explicitly add a new node to the game, use bascenev1.newnode(), and to explicitly delete one,
use bascenev1.Node.delete().
babase.Node.exists() can be used to determine if a Node still points to a live node in the game.
You can use ba.Node(None) to instantiate an invalid Node reference (sometimes used as attr values/etc).
- add_death_action(action: Callable[[], None]) None [source]¶
Add a callable object to be called upon this node’s death. Note that these actions are run just after the node dies, not before.
- allow_kick_idle_players: bool = False¶
- always_show_health_bar: bool = False¶
- ambient_color: Sequence[float] = (1.0, 1.0, 1.0)¶
- area_of_interest_bounds: Sequence[float] = (-1, -1, -1, 1, 1, 1)¶
- billboard_cross_out: bool = False¶
- billboard_opacity: float = 0.0¶
- billboard_texture: bascenev1.Texture | None = None¶
- bomb_pressed: bool = False¶
- boxing_gloves: bool = False¶
- boxing_gloves_flashing: bool = False¶
- camera_mode: str = 'rotate'¶
- client_only: bool = False¶
- color: Sequence[float] = (0.0, 0.0, 0.0)¶
- connectattr(srcattr: str, dstnode: Node, dstattr: str) None [source]¶
Connect one of this node’s attributes to an attribute on another node. This will immediately set the target attribute’s value to that of the source attribute, and will continue to do so once per step as long as the two nodes exist. The connection can be severed by setting the target attribute to any value or connecting another node attribute to it.
##### Example Create a locator and attach a light to it: >>> light = bascenev1.newnode(‘light’) … loc = bascenev1.newnode(‘locator’, attrs={‘position’: (0, 10, 0)}) … loc.connectattr(‘position’, light, ‘position’)
- counter_text: str = ''¶
- counter_texture: bascenev1.Texture | None = None¶
- curse_death_time: int = 0¶
- damage: int = 0¶
- damage_smoothed: float = 0.0¶
- dead: bool = False¶
- debris_friction: float = 0.0¶
- debris_kill_height: float = 0.0¶
- delete(ignore_missing: bool = True) None [source]¶
Delete the node. Ignores already-deleted nodes if ignore_missing is True; otherwise a bascenev1.NodeNotFoundError is thrown.
- exists() bool [source]¶
Returns whether the Node still exists. Most functionality will fail on a nonexistent Node, so it’s never a bad idea to check this.
Note that you can also use the boolean operator for this same functionality, so a statement such as “if mynode” will do the right thing both for Node objects and values of None.
- extras_material: Sequence[bascenev1.Material] = ()¶
- flashing: bool = False¶
- floor_reflection: bool = False¶
- fly_pressed: bool = False¶
- frozen: bool = False¶
- getdelegate(type: type[_T], doraise: Literal[False] = False) _T | None [source]¶
- getdelegate(type: type[_T], doraise: Literal[True]) _T
Return the node’s current delegate object if it matches a certain type.
If the node has no delegate or it is not an instance of the passed type, then None will be returned. If ‘doraise’ is True, then an babase.DelegateNotFoundError will be raised instead.
- getnodetype() str [source]¶
Return the type of Node referenced by this object as a string. (Note this is different from the Python type which is always
bascenev1.Node)
- gravity_scale: float = 1.0¶
- handlemessage(*args: Any) None [source]¶
General message handling; can be passed any message object.
All standard message objects are forwarded along to the bascenev1.Node’s delegate for handling (generally the bascenev1.Actor that made the node).
bascenev1.Node-s are unique, however, in that they can be passed a second form of message; ‘node-messages’. These consist of a string type-name as a first argument along with the args specific to that type name as additional arguments. Node-messages communicate directly with the low-level node layer and are delivered simultaneously on all game clients, acting as an alternative to setting node attributes.
- happy_thoughts_mode: bool = False¶
- hockey: bool = False¶
- hold_body: int = 0¶
- hold_node: bascenev1.Node | None = None¶
- hold_position_pressed: bool = False¶
- host_only: bool = False¶
- hurt: float = 0.0¶
- input0: float = 0.0¶
- input1: float = 0.0¶
- input2: float = 0.0¶
- input3: float = 0.0¶
- invincible: bool = False¶
- is_area_of_interest: bool = False¶
- jump_pressed: bool = False¶
- knockout: float = 0.0¶
- loop: bool = False¶
- materials: Sequence[bascenev1.Material] = ()¶
- mesh_opaque: bascenev1.Mesh | None = None¶
- mesh_transparent: bascenev1.Mesh | None = None¶
- mini_billboard_1_end_time: int = 0¶
- mini_billboard_1_start_time: int = 0¶
- mini_billboard_1_texture: bascenev1.Texture | None = None¶
- mini_billboard_2_end_time: int = 0¶
- mini_billboard_2_start_time: int = 0¶
- mini_billboard_2_texture: bascenev1.Texture | None = None¶
- mini_billboard_3_end_time: int = 0¶
- mini_billboard_3_start_time: int = 0¶
- mini_billboard_3_texture: bascenev1.Texture | None = None¶
- move_left_right: float = 0.0¶
- move_up_down: float = 0.0¶
- music: str = ''¶
- music_continuous: bool = False¶
- music_count: int = 0¶
- name: str = ''¶
- name_color: Sequence[float] = (0.0, 0.0, 0.0)¶
- offset: float = 0.0¶
- opacity: float = 0.0¶
- paused: bool = False¶
- pickup_materials: Sequence[bascenev1.Material] = ()¶
- pickup_pressed: bool = False¶
- position: Sequence[float] = (0.0, 0.0, 0.0)¶
- position_center: Sequence[float] = (0.0, 0.0, 0.0)¶
- position_forward: Sequence[float] = (0.0, 0.0, 0.0)¶
- premultiplied: bool = False¶
- punch_materials: Sequence[bascenev1.Material] = ()¶
- punch_momentum_angular: float = 0.0¶
- punch_momentum_linear: Sequence[float] = (0.0, 0.0, 0.0)¶
- punch_position: Sequence[float] = (0.0, 0.0, 0.0)¶
- punch_power: float = 0.0¶
- punch_pressed: bool = False¶
- punch_velocity: Sequence[float] = (0.0, 0.0, 0.0)¶
- rate: int = 0¶
- roller_materials: Sequence[bascenev1.Material] = ()¶
- rotate: float = 0.0¶
- run: float = 0.0¶
- scale: float | Sequence[float] = 0.0¶
- shadow_offset: Sequence[float] = (0.0, 0.0)¶
- shadow_ortho: bool = False¶
- shadow_range: Sequence[float] = (0, 0, 0, 0)¶
- shattered: int = 0¶
- size: Sequence[float] = (0.0, 0.0, 0.0)¶
- slow_motion: bool = False¶
- source_player: bascenev1.Player | None = None¶
- stick_to_owner: bool = False¶
- text: babase.Lstr | str = ''¶
- texture: bascenev1.Texture | None = None¶
- time: int = 0¶
- time1: int = 0¶
- time2: int = 0¶
- timemax: int = 0¶
- times: Sequence[int] = (1, 2, 3, 4, 5)¶
- tint: Sequence[float] = (1.0, 1.0, 1.0)¶
- tint2_color: Sequence[float] = (0.0, 0.0, 0.0)¶
- tint_color: Sequence[float] = (0.0, 0.0, 0.0)¶
- tint_texture: bascenev1.Texture | None = None¶
- use_fixed_vr_overlay: bool = False¶
- values: Sequence[float] = (1.0, 2.0, 3.0, 4.0)¶
- velocity: Sequence[float] = (0.0, 0.0, 0.0)¶
- vignette_inner: Sequence[float] = (0.0, 0.0)¶
- vignette_outer: Sequence[float] = (0.0, 0.0)¶
- vr_camera_offset: Sequence[float] = (0.0, 0.0, 0.0)¶
- vr_depth: float = 0.0¶
- vr_near_clip: float = 0.0¶
- vr_overlay_center: Sequence[float] = (0.0, 0.0, 0.0)¶
- vr_overlay_center_enabled: bool = False¶
- class _bascenev1.SessionData[source]¶
Bases:
object
(internal)
- context() bascenev1.ContextRef [source]¶
Return a context-ref pointing to the session.
- class _bascenev1.SessionPlayer[source]¶
Bases:
object
A reference to a player in the bascenev1.Session.
Category: Gameplay Classes
These are created and managed internally and provided to your bascenev1.Session/bascenev1.Activity instances. Be aware that, like `ba.Node`s, bascenev1.SessionPlayer objects are ‘weak’ references under-the-hood; a player can leave the game at
any point. For this reason, you should make judicious use of the
babase.SessionPlayer.exists() method (or boolean operator) to ensure that a SessionPlayer is still present if retaining references to one for any length of time.
- activityplayer: bascenev1.Player | None¶
The current game-specific instance for this player.
- assigninput(type: bascenev1.InputType | tuple[bascenev1.InputType, ...], call: Callable) None [source]¶
Set the python callable to be run for one or more types of input.
- character: str¶
The character this player has selected in their profile.
- color: Sequence[float]¶
The base color for this Player. In team games this will match the bascenev1.SessionTeam’s color.
- get_icon() dict[str, Any] [source]¶
Returns the character’s icon (images, colors, etc contained in a dict.
- get_v1_account_id() str [source]¶
Return the V1 Account ID this player is signed in under, if there is one and it can be determined with relative certainty. Returns None otherwise. Note that this may require an active internet connection (especially for network-connected players) and may return None for a short while after a player initially joins (while verification occurs).
- getname(full: bool = False, icon: bool = True) str [source]¶
Returns the player’s name. If icon is True, the long version of the name may include an icon.
- highlight: Sequence[float]¶
A secondary color for this player. This is used for minor highlights and accents to allow a player to stand apart from his teammates who may all share the same team (primary) color.
- id: int¶
The unique numeric ID of the Player.
Note that you can also use the boolean operator for this same functionality, so a statement such as “if player” will do the right thing both for Player objects and values of None.
- in_game: bool¶
This bool value will be True once the Player has completed any lobby character/team selection.
- inputdevice: bascenev1.InputDevice¶
The input device associated with the player.
- sessionteam: bascenev1.SessionTeam¶
The bascenev1.SessionTeam this Player is on. If the SessionPlayer is still in its lobby selecting a team/etc. then a bascenev1.SessionTeamNotFoundError will be raised.
- set_icon_info(texture: str, tint_texture: str, tint_color: Sequence[float], tint2_color: Sequence[float]) None [source]¶
(internal)
- setactivity(activity: bascenev1.Activity | None) None [source]¶
(internal)
- setdata(team: bascenev1.SessionTeam, character: str, color: Sequence[float], highlight: Sequence[float]) None [source]¶
(internal)
- setname(name: str, full_name: str | None = None, real: bool = True) None [source]¶
Set the player’s name to the provided string. A number will automatically be appended if the name is not unique from other players.
- setnode(node: bascenev1.Node | None) None [source]¶
(internal)
- class _bascenev1.Sound[source]¶
Bases:
object
A reference to a sound.
Category: Asset Classes
Use bascenev1.getsound() to instantiate one.
- class _bascenev1.Texture[source]¶
Bases:
object
A reference to a texture.
Category: Asset Classes
Use bascenev1.gettexture() to instantiate one.
- class _bascenev1.Timer(time: float, call: Callable[[], Any], repeat: bool = False)[source]¶
Bases:
object
Timers are used to run code at later points in time.
Category: General Utility Classes
This class encapsulates a scene-time timer in the current bascenev1.Context. The underlying timer will be destroyed when either this object is no longer referenced or when its Context (Activity, etc.) dies. If you do not want to worry about keeping a reference to your timer around, you should use the bs.timer() function instead.
Scene time maps to local simulation time in bascenev1.Activity or bascenev1.Session Contexts. This means that it may progress slower in slow-motion play modes, stop when the game is paused, etc.
###### time > Length of time (in seconds by default) that the timer will wait before firing. Note that the actual delay experienced may vary depending on the timetype. (see below)
###### call > A callable Python object. Note that the timer will retain a strong reference to the callable for as long as it exists, so you may want to look into concepts such as babase.WeakCall if that is not desired.
###### repeat > If True, the timer will fire repeatedly, with each successive firing having the same delay as the first.
##### Example
Use a Timer object to print repeatedly for a few seconds: >>> import bascenev1 as bs … def say_it(): … bs.screenmessage(‘BADGER!’) … def stop_saying_it(): … global g_timer … g_timer = None … bs.screenmessage(‘MUSHROOM MUSHROOM!’) … # Create our timer; it will run as long as we have the self.t ref. … g_timer = bs.Timer(0.3, say_it, repeat=True) … # Now fire off a one-shot timer to kill it. … bs.timer(3.89, stop_saying_it)
- _bascenev1.basetime() bascenev1.BaseTime [source]¶
Return the base-time in seconds for the current scene-v1 context.
Category: General Utility Functions
Base-time is a time value that progresses at a constant rate for a scene, even when the scene is sped up, slowed down, or paused. It may, however, speed up or slow down due to replay speed adjustments or may slow down if the cpu is overloaded. Note that the value returned here is simply a float; it just has a unique type in the type-checker’s eyes to help prevent it from being accidentally used with time functionality expecting other time types.
- _bascenev1.basetimer(time: float, call: Callable[[], Any], repeat: bool = False) None [source]¶
Schedule a call to run at a later point in scene base-time. Base-time is a value that progresses at a constant rate for a scene,
even when the scene is sped up, slowed down, or paused. It may, however, speed up or slow down due to replay speed adjustments or may slow down if the cpu is overloaded.
Category: General Utility Functions
This function adds a timer to the current scene context. This timer cannot be canceled or modified once created. If you
require the ability to do so, use the bascenev1.BaseTimer class instead.
##### Arguments ###### time (float) > Length of time in seconds that the timer will wait before firing.
###### call (Callable[[], Any]) > A callable Python object. Remember that the timer will retain a strong reference to the callable for the duration of the timer, so you may want to look into concepts such as babase.WeakCall if that is not desired.
###### repeat (bool) > If True, the timer will fire repeatedly, with each successive firing having the same delay as the first.
##### Examples Print some stuff through time: >>> import bascenev1 as bs >>> bs.screenmessage(‘hello from now!’) >>> bs.basetimer(1.0, bs.Call(bs.screenmessage, ‘hello from the future!’)) >>> bs.basetimer(2.0, bs.Call(bs.screenmessage, … ‘hello from the future 2!’))
- _bascenev1.broadcastmessage(message: str | babase.Lstr, color: Sequence[float] | None = None, top: bool = False, image: dict[str, Any] | None = None, log: bool = False, clients: Sequence[int] | None = None, transient: bool = False) None [source]¶
Broadcast a screen-message to clients in the current session.
Category: General Utility Functions
If ‘top’ is True, the message will go to the top message area. For ‘top’ messages, ‘image’ must be a dict containing ‘texture’ and ‘tint_texture’ textures and ‘tint_color’ and ‘tint2_color’ colors. This defines an icon to display alongside the message. If ‘log’ is True, the message will also be submitted to the log. ‘clients’ can be a list of client-ids the message should be sent to, or None to specify that everyone should receive it. If ‘transient’ is True, the message will not be included in the game-stream and thus will not show up when viewing replays. Currently the ‘clients’ option only works for transient messages.
- _bascenev1.camerashake(intensity: float = 1.0) None [source]¶
Shake the camera.
Category: Gameplay Functions
Note that some cameras and/or platforms (such as VR) may not display camera-shake, so do not rely on this always being visible to the player as a gameplay cue.
- _bascenev1.capture_gamepad_input(call: Callable[[dict], None]) None [source]¶
(internal)
Add a callable to be called for subsequent gamepad events. The method is passed a dict containing info about the event.
- _bascenev1.capture_keyboard_input(call: Callable[[dict], None]) None [source]¶
(internal)
Add a callable to be called for subsequent keyboard-game-pad events. The method is passed a dict containing info about the event.
- _bascenev1.chatmessage(message: str | babase.Lstr, clients: Sequence[int] | None = None, sender_override: str | None = None) None [source]¶
(internal)
- _bascenev1.connect_to_party(address: str, port: int | None = None, print_progress: bool = True) None [source]¶
(internal)
- _bascenev1.emitfx(position: Sequence[float], velocity: Sequence[float] | None = None, count: int = 10, scale: float = 1.0, spread: float = 1.0, chunk_type: str = 'rock', emit_type: str = 'chunks', tendril_type: str = 'smoke') None [source]¶
Emit particles, smoke, etc. into the fx sim layer.
Category: Gameplay Functions
The fx sim layer is a secondary dynamics simulation that runs in the background and just looks pretty; it does not affect gameplay. Note that the actual amount emitted may vary depending on graphics settings, exiting element counts, or other factors.
- _bascenev1.get_client_public_device_uuid(client_id: int) str | None [source]¶
(internal)
Category: General Utility Functions
Return a public device UUID for a client. If the client does not exist or is running a version older than 1.6.10, returns None. Public device UUID uniquely identifies the device the client is using in a semi-permanent way. The UUID value will change periodically with updates to the game or operating system.
- _bascenev1.get_collision_info(*args: Any) Any [source]¶
Return collision related values
Category: Gameplay Functions
Returns a single collision value or tuple of values such as location, depth, nodes involved, etc. Only call this in the handler of a collision-triggered callback or message
- _bascenev1.get_configurable_game_pads() list [source]¶
(internal)
Returns a list of the currently connected gamepads that can be configured.
- _bascenev1.get_connection_to_host_info_2() bascenev1.HostInfo | None [source]¶
Return info about the host we are currently connected to.
- _bascenev1.get_foreground_host_activity() bascenev1.Activity | None [source]¶
(internal)
Returns the bascenev1.Activity currently in the foreground, or None if there is none.
- _bascenev1.get_foreground_host_session() bascenev1.Session | None [source]¶
(internal)
Return the bascenev1.Session currently being displayed, or None if there is none.
- _bascenev1.get_package_collision_mesh(package: bascenev1.AssetPackage, name: str) bascenev1.CollisionMesh [source]¶
(internal)
- _bascenev1.get_package_data(package: bascenev1.AssetPackage, name: str) bascenev1.Data [source]¶
(internal).
- _bascenev1.get_package_mesh(package: bascenev1.AssetPackage, name: str) bascenev1.Mesh [source]¶
(internal)
- _bascenev1.get_package_sound(package: bascenev1.AssetPackage, name: str) bascenev1.Sound [source]¶
(internal).
- _bascenev1.get_package_texture(package: bascenev1.AssetPackage, name: str) bascenev1.Texture [source]¶
(internal)
- _bascenev1.get_replay_speed_exponent() int [source]¶
(internal)
Returns current replay speed value. Actual displayed speed is pow(2,speed).
- _bascenev1.get_ui_input_device() bascenev1.InputDevice | None [source]¶
(internal)
Returns the input-device that currently owns the user interface, or None if there is none.
- _bascenev1.getactivity(doraise: Literal[True] = True) bascenev1.Activity [source]¶
- _bascenev1.getactivity(doraise: Literal[False]) bascenev1.Activity | None
Return the current bascenev1.Activity instance.
Category: Gameplay Functions
Note that this is based on context_ref; thus code run in a timer generated in Activity ‘foo’ will properly return ‘foo’ here, even if another Activity has since been created or is transitioning in. If there is no current Activity, raises a babase.ActivityNotFoundError. If doraise is False, None will be returned instead in that case.
- _bascenev1.getcollisionmesh(name: str) bascenev1.CollisionMesh [source]¶
Return a collision-mesh, loading it if necessary.
Category: Asset Functions
Collision-meshes are used in physics calculations for such things as terrain.
Note that this function returns immediately even if the asset has yet to be loaded. To avoid hitches, instantiate your asset objects in advance of when you will be using them, allowing time for them to load in the background if necessary.
- _bascenev1.getdata(name: str) bascenev1.Data [source]¶
Return a data, loading it if necessary.
Category: Asset Functions
Note that this function returns immediately even if the asset has yet to be loaded. To avoid hitches, instantiate your asset objects in advance of when you will be using them, allowing time for them to load in the background if necessary.
- _bascenev1.getinputdevice(name: str, unique_id: str, doraise: Literal[True] = True) bascenev1.InputDevice [source]¶
- _bascenev1.getinputdevice(name: str, unique_id: str, doraise: Literal[False]) bascenev1.InputDevice | None
(internal)
Given a type name and a unique identifier, returns an InputDevice. Throws an Exception if the input-device is not found, or returns None if ‘doraise’ is False.
- _bascenev1.getmesh(name: str) bascenev1.Mesh [source]¶
Return a mesh, loading it if necessary.
Category: Asset Functions
Note that this function returns immediately even if the asset has yet to be loaded. To avoid hitches, instantiate your asset objects in advance of when you will be using them, allowing time for them to
load in the background if necessary.
- _bascenev1.getnodes() list [source]¶
Return all nodes in the current bascenev1.Context.
Category: Gameplay Functions
- _bascenev1.getsession(doraise: Literal[True] = True) bascenev1.Session [source]¶
- _bascenev1.getsession(doraise: Literal[False]) bascenev1.Session | None
Category: Gameplay Functions
Returns the current bascenev1.Session instance. Note that this is based on context_ref; thus code being run in the UI context will return the UI context_ref here even if a game Session also exists, etc. If there is no current Session, an Exception is raised, or if doraise is False then None is returned instead.
- _bascenev1.getsound(name: str) bascenev1.Sound [source]¶
Return a sound, loading it if necessary.
Category: Asset Functions
Note that this function returns immediately even if the asset has yet to be loaded. To avoid hitches, instantiate your asset objects in advance of when you will be using them, allowing time for them to load in the background if necessary.
- _bascenev1.gettexture(name: str) bascenev1.Texture [source]¶
Return a texture, loading it if necessary.
Category: Asset Functions
Note that this function returns immediately even if the asset has yet to be loaded. To avoid hitches, instantiate your asset objects in advance of when you will be using them, allowing time for them to load in the background if necessary.
- _bascenev1.have_touchscreen_input() bool [source]¶
(internal)
Returns whether or not a touch-screen input is present
- _bascenev1.ls_input_devices() None [source]¶
Print debugging info about game objects.
Category: General Utility Functions
This call only functions in debug builds of the game. It prints various info about the current object count, etc.
- _bascenev1.ls_objects() None [source]¶
Log debugging info about C++ level objects.
Category: General Utility Functions
This call only functions in debug builds of the game. It prints various info about the current object count, etc.
- _bascenev1.new_host_session(sessiontype: type[bascenev1.Session], benchmark_type: str | None = None) None [source]¶
(internal)
- _bascenev1.newactivity(activity_type: type[bascenev1.Activity], settings: dict | None = None) bascenev1.Activity [source]¶
Instantiates a bascenev1.Activity given a type object.
Category: General Utility Functions
Activities require special setup and thus cannot be directly instantiated; you must go through this function.
- _bascenev1.newnode(type: str, owner: bascenev1.Node | None = None, attrs: dict | None = None, name: str | None = None, delegate: Any = None) bascenev1.Node [source]¶
Add a node of the given type to the game.
Category: Gameplay Functions
If a dict is provided for ‘attributes’, the node’s initial attributes will be set based on them.
‘name’, if provided, will be stored with the node purely for debugging purposes. If no name is provided, an automatic one will be generated such as ‘terrain@foo.py:30’.
If ‘delegate’ is provided, Python messages sent to the node will go to that object’s handlemessage() method. Note that the delegate is stored as a weak-ref, so the node itself will not keep the object alive.
if ‘owner’ is provided, the node will be automatically killed when that object dies. ‘owner’ can be another node or a bascenev1.Actor
- _bascenev1.printnodes() None [source]¶
Print various info about existing nodes; useful for debugging.
Category: Gameplay Functions
- _bascenev1.register_activity(activity: bascenev1.Activity) bascenev1.ActivityData [source]¶
(internal)
- _bascenev1.register_session(session: bascenev1.Session) bascenev1.SessionData [source]¶
(internal)
- _bascenev1.release_gamepad_input() None [source]¶
(internal)
Resumes normal gamepad event processing.
- _bascenev1.release_keyboard_input() None [source]¶
(internal)
Resumes normal keyboard event processing.
- _bascenev1.set_debug_speed_exponent(speed: int) None [source]¶
(internal)
Sets the debug speed scale for the game. Actual speed is pow(2,speed).
- _bascenev1.set_internal_music(music: babase.SimpleSound | None, volume: float = 1.0, loop: bool = True) None [source]¶
(internal).
- _bascenev1.set_map_bounds(bounds: tuple[float, float, float, float, float, float]) None [source]¶
(internal)
Set map bounds. Generally nodes that go outside of this box are killed.
- _bascenev1.set_replay_speed_exponent(speed: int) None [source]¶
(internal)
Set replay speed. Actual displayed speed is pow(2, speed).
- _bascenev1.time() bascenev1.Time [source]¶
Return the current scene time in seconds.
Category: General Utility Functions
Scene time maps to local simulation time in bascenev1.Activity or bascenev1.Session Contexts. This means that it may progress slower in slow-motion play modes, stop when the game is paused, etc.
Note that the value returned here is simply a float; it just has a unique type in the type-checker’s eyes to help prevent it from being accidentally used with time functionality expecting other time types.
- _bascenev1.timer(time: float, call: Callable[[], Any], repeat: bool = False) None [source]¶
Schedule a call to run at a later point in time.
Category: General Utility Functions
This function adds a scene-time timer to the current babase.Context. This timer cannot be canceled or modified once created. If you
require the ability to do so, use the babase.Timer class instead.
Scene time maps to local simulation time in bascenev1.Activity or bascenev1.Session Contexts. This means that it may progress slower in slow-motion play modes, stop when the game is paused, etc.
##### Arguments ###### time (float) > Length of scene time in seconds that the timer will wait before firing.
###### call (Callable[[], Any]) > A callable Python object. Note that the timer will retain a strong reference to the callable for as long as it exists, so you may want to look into concepts such as babase.WeakCall if that is not desired.
###### repeat (bool) > If True, the timer will fire repeatedly, with each successive firing having the same delay as the first.
##### Examples Print some stuff through time: >>> import bascenev1 as bs >>> bs.screenmessage(‘hello from now!’) >>> bs.timer(1.0, bs.Call(bs.screenmessage, ‘hello from the future!’)) >>> bs.timer(2.0, bs.Call(bs.screenmessage, … ‘hello from the future 2!’))