sm.unit

Associated object type: Unit

Unit creation and management

Functions:

  • createUnit
  • forceDestroy
  • getAllUnits
  • getUnitsInRange

  • sm.unit.createUnit(uuid, feetPos, yaw?, data?, pitch?, visible?)

    Server only

    Creates a new unit of type from an Uuid

    Parameters:

    TypeNameDescription
    UuiduuidThe character type uuid.
    Vec3feetPosThe feet position in world where unit should spawn.
    numberyaw?The initial yaw. Defaults to 0 (Optional)
    anydata?The param data. (Optional)
    numberpitch?The initial pitch. Defaults to 0 (Optional)
    booleanvisible?Whether the unit is visible on spawn. Defaults to true. (Optional)

    Returns:

    TypeDescription
    UnitThe created unit.

    sm.unit.forceDestroy(unit)

    Server only

    Destroys a unit.

    If the unit does not exist at the moment, it is removed from the save file. This will stop it from loading back into the game.

    Parameters:

    TypeNameDescription
    UnitunitThe unit.

    sm.unit.getAllUnits(world?)

    Server only

    Returns a table with all the units in the world.

    Parameters:

    TypeNameDescription
    Worldworld?The world to get units from. Defaults to the world of the script (Optional)

    Returns:

    TypeDescription
    tableThe table of all units. {Unit, ..}

    sm.unit.getUnitsInRange(world, position, range, heightModifier?)

    Server only

    Returns a table with units within a given range.

    Parameters:

    TypeNameDescription
    WorldworldThe world to check in.
    Vec3positionThe position to check from.
    numberrangeThe range to check.
    numberheightModifier?A value to modify the height of the range check. Defaults to 1. Higher values makes enemy elevation difference deemed as greater distance.