Get Direction

Description

The get_direction() function returns the direction Gizmo is currently facing. Use this function to determine Gizmo's orientation in the game world.

Syntax

direction = get_direction()

Parameters

None.

Return

The function returns an integer representing the direction Gizmo is facing. The return value corresponds to the DirectionEnum:

  • 0: North
  • 1: East
  • 2: South
  • 3: West

Examples

Here's an example of how to use the get_direction() function:

# Get Gizmo's current direction
direction = get_direction()

# Define a dictionary to map direction integers to names
direction_names = {0: "North", 1: "East", 2: "South", 3: "West"}

# Print Gizmo's current direction
print(f"Gizmo is facing: {direction_names[direction]}")

# Check if Gizmo is facing a specific direction
target_direction = DirectionEnum.East
if direction == target_direction:
    print("Gizmo is facing East!")
else:
    print(f"Gizmo needs to turn to face East. Currently facing {direction_names[direction]}.")

This example demonstrates how to get Gizmo's current direction, convert it to a readable format, and check if it matches a target direction.

Notes

  • The get_direction() function is available from the start of the game (UnlocksAtLevel: 0).
  • The direction is updated after each turn action.
  • Remember to import and use the DirectionEnum for clearer code when working with directions.