Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Auto Teleport

Turokhan Legion
Vortech Enterprises CEO
Join date: 22 Jul 2007
Posts: 32
07-19-2008 12:14
Hey guys,

Im working on something new and want a feature to auto teleport the owner to random locations gridwide.

Just wondering if it can be done and what functions should i be looking for on the wiki?

I would also like to read destinations from a notecard as a seperate option.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
07-19-2008 14:53
From: Turokhan Legion
Hey guys,

Im working on something new and want a feature to auto teleport the owner to random locations gridwide.

Just wondering if it can be done and what functions should i be looking for on the wiki?

I would also like to read destinations from a notecard as a seperate option.


You might want to look at this:

http://www.slexchange.com/modules.php?name=Marketplace&file=item&ItemID=796698

This gives you a rundown on functions relevant to teleporting:

http://www.lslwiki.net/lslwiki/wakka.php?wakka=teleport

and this is prolly the best place to start if you want to find out about reading data from a notecard:

http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetNotecardLine

Hope this helps
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-20-2008 06:36
The notecard thing is certainly do-able (with llMapDestination(), as one way), but a random destination would be tricky. One can get the global coordinates of the current region with llGetRegionCorner(), but I know of no way to invert that process to determine if arbitrary global coordinates map to any region (let alone *which* region) without accessing external data sources.
_____________________
Archived for Your Protection
Turokhan Legion
Vortech Enterprises CEO
Join date: 22 Jul 2007
Posts: 32
07-20-2008 11:21
Ahh gotcha, been trying to achieve notecard settings but found no way of getting that to bring up a map with touch start...

Heres the code:

// Read out a complete notecard from the object's inventory.
string gName; // name of a notecard in the object's inventory
integer gLine = 0; // current line number
key gQueryID; // id used to identify dataserver queries
string name;
string sim_name;
vector pos;

default {
state_entry() {
gName = llGetInventoryName(INVENTORY_NOTECARD, 0); // select the first notecard in the object's inventory
gQueryID = llGetNotecardLine(gName, gLine); // request first line
}

dataserver(key query_id, string data) {
if (query_id == gQueryID) {
if (data != EOF) { // not at the end of the notecard
llSay(0, (string)gLine+": "+data); // output the line
++gLine; // increase line count
gQueryID = llGetNotecardLine(gName, gLine); // request next line

}
}
}
touch_start(integer total_num)
{
llMapDestination(sim_name, pos, pos);
}
}

I didnt know what to put after llMapDestination so i played about till i got a succesfull compile...how can i get mapdestination to read the notecard?
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-20-2008 12:08
In broad outline, there are a couple ways one might proceed. One is to read in all the notecard lines at state_entry (and perhaps on a CHANGED_INVENTORY event, in case somebody updates the notecard), but instead of just llSay()in the data, append it to a global list variable that you can then reference in touch_start, perhaps randomizing with (integer)llFrand() over the number of elements in the list.

The other option--a bit slower on touch, but less memory-intensive--is to only read the line you want, when you want to use it in touch_start. This would require a tiny bit smarter dataserver() handler because it would get two kinds of data: a response to llGetNumberOfNotecardLines() called at state_entry and on CHANGED_INVENTORY, and the single notecard line you pick at random over that number, on touch_start.

I'll just mention that a different (not necessarily better) approach might use landmarks as inventory items in the scripted object, instead of a notecard, and then just pick one of those at random over llGetInventoryNumber(INVENTORY_LANDMARK). What's not as nice as one might assume about this approach is that it's pretty much stuck with just doing an llGiveInventory() of the landmark to the recipient (which can be clicked to teleport), rather than llMapDestination() or any other ways of inter-sim teleporting. That's because there's no sure way to get the region associated with a landmark object (as insane as that seems, especially since it renders llRequestInventoryData all but useless).
_____________________
Archived for Your Protection