Forgot? Join

Scripting

LSL Guide

Every script function this grid actually runs, read straight from the region software rather than copied from a wiki — including the wolf* functions that exist only here.

Functions · Constants

wolfAttach

Wolf Territories
integer wolfAttach(string frontKey, string pointName, vector myPoint, integer type, list options)

Couple this object (the rear) to the object with coupler key frontKey, joining myPoint (root prim frame) to its hitch point pointName. Both must have the same owner and be physical. The joint is made as soon as the points are within reach, and is kept through restarts and region crossings until wolfDetach. Type is WOLF_JOINT_BALL, WOLF_JOINT_FIFTHWHEEL or WOLF_JOINT_COUPLER; options are "yaw", "pitch" (degrees), "reach" and "break" (metres).

Couples this object — the REAR: a trailer, a caravan, a carriage — to the front with coupler key frontKey, joining myPoint on this object to the front's hitch point pointName. This is a real joint in the region's physics (ubODE and BulletSim both), not a script chasing the truck: the trailer swings, tracks and is pulled. Both objects must have the same owner and be physical. The request is stored in the object: the joint is made as soon as the two points are within reach (3 m unless you say otherwise), and it is made again after the region restarts, after either object has been edited, and in the next region after a crossing, until wolfDetach. Returns 1 when the request is accepted — check wolfAttachInfo to see it couple.

Parameters

TypeName What it does
string frontKey The coupler key the front gave itself with wolfCouplerSetKey.
string pointName Which of the front's hitch points (wolfCouplerSetPoint).
vector myPoint Where on THIS object the hitch is — the kingpin, the tow hitch — in its root prim's frame, metres.
integer type WOLF_JOINT_BALL, WOLF_JOINT_FIFTHWHEEL or WOLF_JOINT_COUPLER.
list options Key/value pairs, any order, may be empty: "yaw", "pitch", "reach", "break" — see the table below.

Joint types

TypeValueWhat it is
WOLF_JOINT_BALL1A tow ball. Every rotation is free. Car and caravan, a boat trailer.
WOLF_JOINT_FIFTHWHEEL2A semi-trailer fifth wheel. Turns and nods within limits, cannot roll against the tractor unit.
WOLF_JOINT_COUPLER3A railway coupler. Like a fifth wheel with tighter limits. Locomotive and carriages.

The options list

Key/value pairs in any order, or an empty list for the defaults. An unknown key or an out-of-range value is refused rather than ignored, and wolfGetLastError says which.

KeyTypeValuesMeaning
yawfloat or integer0 – 170 (degrees)How far the rear may turn either side of straight. Fifth wheel 90, coupler 35 by default. Not taken by WOLF_JOINT_BALL, which turns freely.
pitchfloat or integer0 – 80 (degrees)How far the rear may nod up or down either side of level. Fifth wheel 20, coupler 15 by default. Not taken by WOLF_JOINT_BALL.
reachfloat or integer0.1 – 10 (metres)The two hitch points join once they are this close, 3 m by default; the rear is then moved the rest of the way. Back the truck up to the trailer and it couples.
breakfloat or integer0.1 – 10 (metres)If a coupled pair is pulled more than this far apart at the hitch, 2 m by default, the coupling breaks and wolfAttachInfo reports WOLF_ATTACH_BROKEN.

Example

// In the semi-trailer's root prim. The trailer should NOT have a vehicle motor of its
// own: VEHICLE_TYPE_NONE, or a car type with its motors at zero, whose sideways friction
// is what makes a trailer follow the tractor unit round a corner.
default
{
    state_entry()
    {
        llSetStatus(STATUS_PHYSICS, TRUE);
        // The kingpin: 5.5 m ahead of this trailer's centre, 1.1 m up.
        if (!wolfAttach("wolfhaul", "fifthwheel", <5.5, 0.0, 1.1>,
                        WOLF_JOINT_FIFTHWHEEL, [ "yaw", 80 ]))
            llOwnerSay("Couple refused: " + wolfGetLastError());
        llSetTimerEvent(1.0);
    }

    timer()
    {
        integer st = llList2Integer(wolfAttachInfo(), 0);
        if (st == WOLF_ATTACH_COUPLED)      llSetText("", ZERO_VECTOR, 0.0);
        else if (st == WOLF_ATTACH_WAITING) llSetText("Back the truck under me", <1, 1, 0>, 1.0);
        else if (st == WOLF_ATTACH_BROKEN)  llSetText("Broke away!", <1, 0, 0>, 1.0);
    }
}

A caravan on a tow ball

wolfAttach("wolfcar", "towball", <3.1, 0.0, 0.45>, WOLF_JOINT_BALL, []);

A railway carriage: the same script in every carriage makes a train of any length — each couples its front to the "rear" of whatever is in front of it

wolfCouplerSetKey("wolfrail");
wolfCouplerSetPoint("rear", <-7.0, 0.0, 0.6>);
wolfAttach("wolfrail", "rear", <7.0, 0.0, 0.6>, WOLF_JOINT_COUPLER, []);

Re-hitch after it broke away

wolfAttach("wolfhaul", "fifthwheel", <5.5, 0.0, 1.1>, WOLF_JOINT_FIFTHWHEEL, []);
Energy 10

Ours alone. Grid features you will not find on any other OpenSimulator grid.

More in Wolf Territories