The interact()
function allows Gizmo to engage with interactable objects directly in front of him, like pressing buttons or pulling levers.
success = interact()
None.
The function returns a boolean:
True
if the interaction was successful.False
if the interaction failed (e.g., no interactable object in front of Gizmo).Here's an example of how to use the interact()
function:
# Try to interact with an object in front of Gizmo
success = interact()
if success:
print("Gizmo successfully interacted with an object!")
else:
print("Interaction failed. There might not be an interactable object in front of Gizmo.")
# Function to detect and interact with objects
def detect_and_interact():
interactable = detect_interactable()
if interactable.detected:
print(f"Detected a {interactable.type}. Attempting to interact...")
if interact():
print(f"Successfully interacted with the {interactable.type}.")
else:
print(f"Failed to interact with the {interactable.type}.")
else:
print("No interactable object detected.")
# Use the function
detect_and_interact()
This example demonstrates how to use the interact()
function and combine it with detect_interactable()
for more robust interaction handling.
interact()
function becomes available at level 20 (UnlocksAtLevel: 20).detect_interactable()
before attempting to interact to ensure there's an object to interact with.