// Wolf Rail "where is my train?" - put this in any object of yours, in any region. Touch it and it says in local chat // where your train's engine is: the region, the spot in that region, which way it is heading, its speed and whether it // is running, standing at a station or stopped. It only knows about trains you own. // Uses the wolf-rail plugin through wolfCallAsync("train.where", ...). Wolf Territories, 2026. Copy, change and share freely. string TRAIN = "My train"; // your train's name, as in its engine script key gAsk; // compass degrees (0 = north, 90 = east) to one of 8 directions string Compass(float deg) { list names = ["north", "north-east", "east", "south-east", "south", "south-west", "west", "north-west"]; return llList2String(names, ((integer)llRound(deg / 45.0)) % 8); } default { touch_start(integer n) { gAsk = wolfCallAsync("train.where", [TRAIN]); if (gAsk == NULL_KEY) llSay(0, "Sorry, I cannot ask about " + TRAIN + " just now: " + wolfGetLastError()); } // "state|region|||heading|speed|odometer|age" or "error: " // (local position is ZERO_VECTOR when the grid cannot say where in its region the train is just now) dataserver(key q, string data) { if (q != gAsk) return; if (llGetSubString(data, 0, 5) == "error:") { llSay(0, TRAIN + ": " + llGetSubString(data, 7, -1)); return; } list a = llParseString2List(data, ["|"], []); string what = llList2String(a, 0); vector here = (vector)llList2String(a, 2); float speed = (float)llList2String(a, 5); string doing = "is stopped"; float heading = (float)llList2String(a, 4); // -1 when not known if (what == "running") { doing = "is running at " + (string)llRound(speed * 3.6) + " km/h"; if (heading >= 0.0) doing += ", heading " + Compass(heading); } else if (what == "held") doing = "is standing (a station stop or crossing into the next region)"; string spot = ""; if (here != ZERO_VECTOR) spot = " at " + (string)llRound(here.x) + ", " + (string)llRound(here.y); llSay(0, TRAIN + " " + doing + ", in " + llList2String(a, 1) + spot + "."); } }