wolfDriveInput
Wolf Territorieslist wolfDriveInput(string avatar)
The exact wheel and pedals of a driver sitting on this object (the script needs PERMISSION_TAKE_CONTROLS from them, as control() does), from their Wolf viewer: [steer -1..1 (right +), throttle 0..1, brake 0..1, clutch 0..1, gear (WOLF_DRIVE_GEAR_P/R/N/D or 1..18), buttons (WOLF_DRIVE_BTN_* bits), age in seconds]. Sent on change and once a second, so an age over ~2 s means the viewer has gone. An empty list from any other viewer: keep a control() event for those.
Only for a script in the linkset the avatar is sitting on, holding PERMISSION_TAKE_CONTROLS from them, on a Wolf Territories region. The list is empty when any of that is not so, or when the driver's viewer is not WolfViewer or WolfStorm (other viewers never send these values): keep a control() event for them. wolfGetLastError says which.
Parameters
| Type | Name | What it does |
|---|---|---|
| string | avatar | The driver: the avatar sitting on this object, usually llAvatarOnSitTarget(). |
What it returns
| Index | Type | Value |
|---|---|---|
| 0 | float | steer, -1 to 1 (right is +) |
| 1 | float | throttle, 0 to 1 |
| 2 | float | brake, 0 to 1 |
| 3 | float | clutch, 0 to 1 |
| 4 | integer | gear: WOLF_DRIVE_GEAR_P, _R, _N or _D, or 1 to 18 (a gear the driver chose) |
| 5 | integer | buttons held: WOLF_DRIVE_BTN_* bits |
| 6 | float | age: seconds since the viewer sent these (it sends on change and once a second, so over about 2 s means the viewer has gone) |
The constants
| Constant | Value |
|---|---|
| WOLF_DRIVE_BTN_GEAR_UP | 1 |
| WOLF_DRIVE_BTN_GEAR_DOWN | 2 |
| WOLF_DRIVE_BTN_HORN | 4 |
| WOLF_DRIVE_BTN_LIGHTS | 8 |
| WOLF_DRIVE_BTN_INDICATOR_LEFT | 16 |
| WOLF_DRIVE_BTN_INDICATOR_RIGHT | 32 |
| WOLF_DRIVE_BTN_HANDBRAKE | 64 |
| WOLF_DRIVE_BTN_HAZARDS | 128 |
| WOLF_DRIVE_BTN_CRUISE | 256 |
| WOLF_DRIVE_GEAR_P | -2 |
| WOLF_DRIVE_GEAR_R | -1 |
| WOLF_DRIVE_GEAR_N | 0 |
| WOLF_DRIVE_GEAR_D | 99 |
How players use it, and more examples: the Driving guide.
Example
// From analogue_car.lsl (the full script is on the Driving guide):
list wheel = wolfDriveInput(gDriver);
if (llGetListLength(wheel) == 7 && llList2Float(wheel, 6) < LIVE_AGE)
{
// A Wolf viewer: exactly how far the wheel is turned and the pedals are pressed.
steer = llList2Float(wheel, 0);
throttle = llList2Float(wheel, 1);
brake = llList2Float(wheel, 2);
gear = llList2Integer(wheel, 4);
pressButtons(llList2Integer(wheel, 5));
}
else
{
// Any other viewer: the keys, all or nothing. Back is reverse, as on most SL cars.
if (gKeys & CONTROL_FWD) throttle = 1.0;
if (gKeys & CONTROL_BACK) { throttle = 1.0; gear = WOLF_DRIVE_GEAR_R; }
if (gKeys & (CONTROL_ROT_RIGHT | CONTROL_RIGHT)) steer += 1.0;
if (gKeys & (CONTROL_ROT_LEFT | CONTROL_LEFT)) steer -= 1.0;
}Ours alone. Grid features you will not find on any other OpenSimulator grid.