Scan

Description

The scan() function returns a list of all detectable items within Gizmo's range. This function consumes energy but provides valuable information about the surrounding environment.

Syntax

scan_results = scan()

Parameters

None.

Return

The function returns a list of objects, each representing a detected item. Each object has the following properties:

  • x: An integer representing the x-coordinate of the detected item.
  • y: An integer representing the y-coordinate of the detected item.
  • z: An integer representing the z-coordinate of the detected item.

Examples

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

# Perform a scan of the surroundings
scan_results = scan()

print(f"Scan detected {len(scan_results)} objects.")

# Process and display the results
for item in scan_results:
    print(f"Detected object at coordinates: X={item.x}, Y={item.y}, Z={item.z}")

# Function to find the closest detected object
def find_closest_object(scan_results, current_position):
    closest_distance = float('inf')
    closest_object = None
    for item in scan_results:
        distance = ((item.x - current_position.x)**2 + 
                    (item.y - current_position.y)**2 + 
                    (item.z - current_position.z)**2)**0.5
        if distance < closest_distance:
            closest_distance = distance
            closest_object = item
    return closest_object

# Use the function
current_position = get_position()
closest = find_closest_object(scan_results, current_position)
if closest:
    print(f"Closest object is at X={closest.x}, Y={closest.y}, Z={closest.z}")
else:
    print("No objects detected in scan.")

This example demonstrates how to perform a scan, process the results, and find the closest detected object.

Notes

  • The scan() function becomes available at level 15 (UnlocksAtLevel: 15).
  • This function consumes energy, so use it judiciously.
  • Scan results can include various game objects like hazards, stations, and barriers.
  • Use scan results to plan routes, avoid dangers, or find resources efficiently.