Verse Library verse

01 Standalone

Monitors players for inactivity using async loops and races to trigger idle effects.

verse-library/prop-team/01-standalone.verse

# This is our blueprint for the Prop Team.
# It inherits from base_team (the standard team logic) so we get basic stuff for free.
prop_team : base_team = class:
    # Define the time threshold for the heartbeat. 
    # If a prop is still for this long, they squeak.
    HeartbeatThreshold: float = 3.0
    
    # This is the main function that runs for every Prop player.
    # <suspends> means this function can pause and wait for things to happen
    # without freezing the whole game.
    RunPropGameLoop(PropAgent:agent)<suspends>:void =
        # Print to the debug log so we know this player is being tracked.
        Logger.Print("Prop Agent {PropAgent} is now hiding.")
        
        # We start a loop. This is the "infinite" check-in.
        # It runs forever until the player is eliminated or leaves.
        loop:
            # Reset the "moved" flag. We assume they are still until proven otherwise.
            has_moved := false
            
            # This is the RACE. We are racing two tasks:
            # 1. Waiting for the player to move (MovementCheck)
            # 2. Waiting for the heartbeat timer to run out (TimerCheck)
            race:
                # TASK 1: Check for movement.
                # We wait until the player's position changes.
                # Note: In a real full implementation, you'd compare Vector positions.
                # Here we use a simplified event-based approach for clarity.
                wait_for_movement(PropAgent):
                    # This is a placeholder for the actual movement detection logic.

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in