Difference between revisions of "User:Kerik Rau"
Line 29: | Line 29: | ||
} | } | ||
</lsl> | </lsl> | ||
==Simple Stupid Slide Show== | |||
Dumb slide show: simply rez a cube, throw in the script and textures and instant slide show. Ya, boring isn't it? | |||
<lsl> | |||
integer Face = 2; | |||
float Delay = 25.0; | |||
list Textures; | |||
integer TextureNum; | |||
BuildDB() | |||
{ | |||
Textures = []; | |||
integer NumTextures = llGetInventoryNumber(INVENTORY_TEXTURE); | |||
while(NumTextures--) | |||
Textures += llGetInventoryName(INVENTORY_TEXTURE, NumTextures); | |||
llOwnerSay("Loaded Textures: " + llDumpList2String(Textures, ", ")); | |||
} | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
BuildDB(); | |||
llSetTimerEvent(Delay); | |||
} | |||
changed(integer change) | |||
{ | |||
if(change & CHANGED_INVENTORY) | |||
BuildDB(); | |||
} | |||
timer() | |||
{ | |||
llSetTexture(llList2String(Textures, TextureNum), Face); | |||
if(++TextureNum >= llGetListLength(Textures)) | |||
TextureNum = 0; | |||
} | |||
} | |||
</lsl> | |||
==SLURL Raster Image URL Generator== | ==SLURL Raster Image URL Generator== | ||
I was rather interested in the raster images provided within SL and SLURL.com so I decided to figure out how to replicate it in such a way that it could be incorporated into tools and/or services outside the standard fair offered by Linden Labs. At some point I may rewrite it to use PHP or offer tips to incorporate it into something like the WMS provider in MapGuide. | I was rather interested in the raster images provided within SL and SLURL.com so I decided to figure out how to replicate it in such a way that it could be incorporated into tools and/or services outside the standard fair offered by Linden Labs. At some point I may rewrite it to use PHP or offer tips to incorporate it into something like the WMS provider in MapGuide. |
Revision as of 20:51, 15 May 2008
Code Snippets
Non Destructive Face Finder
I wrote this in a minute or so and it seems pretty useful. Should be helpful for anyone wanting to find the face value in LSL.
<lsl> integer NumSides; integer NextSide;
default {
state_entry() { NumSides = llGetNumberOfSides(); }
touch_start(integer total_number) { vector CurrentColor = llGetColor(NextSide); llSetColor(<1,0,0>, NextSide); llOwnerSay("Turning side " + (string) NextSide); llSleep(1); llSetColor(CurrentColor, NextSide); if(++NextSide >= NumSides) NextSide = 0; }
} </lsl>
Simple Stupid Slide Show
Dumb slide show: simply rez a cube, throw in the script and textures and instant slide show. Ya, boring isn't it?
<lsl> integer Face = 2; float Delay = 25.0;
list Textures; integer TextureNum;
BuildDB() {
Textures = []; integer NumTextures = llGetInventoryNumber(INVENTORY_TEXTURE); while(NumTextures--) Textures += llGetInventoryName(INVENTORY_TEXTURE, NumTextures); llOwnerSay("Loaded Textures: " + llDumpList2String(Textures, ", "));
}
default {
state_entry() { BuildDB(); llSetTimerEvent(Delay); } changed(integer change) { if(change & CHANGED_INVENTORY) BuildDB(); } timer() { llSetTexture(llList2String(Textures, TextureNum), Face); if(++TextureNum >= llGetListLength(Textures)) TextureNum = 0; }
} </lsl>
SLURL Raster Image URL Generator
I was rather interested in the raster images provided within SL and SLURL.com so I decided to figure out how to replicate it in such a way that it could be incorporated into tools and/or services outside the standard fair offered by Linden Labs. At some point I may rewrite it to use PHP or offer tips to incorporate it into something like the WMS provider in MapGuide.
PseudoCode
//grab the region coordinates and store them $RegionPos; //1 Tile = 256m $TilePos = $RegionPos/256.0; //Fix the offset in the service $TilePos.y = 1279.0 - $TilePos.y; //genrate the URL, the 0 on the end may be a switch for gif/png, need to read up more on the SL map API $mapURL = "http://secondlife.com/apps/mapapi/grid/map_image/" \ + Floor($TilePos.x) + "-" + Floor($TilePos.y) + "-1-0"
LSL
<lsl> //SLURL Tile URL Generator - By Kerik Rau
//Based on the javascript from SLURL.com, merely an adaptation in LSL //It should only take a minute or 2 to export this into PHP or other languages
//SLURL uses WMS, I still want to look at incorporating it into something like Mapguide //I will need to look at the implementation to see if this would be easy or a pain
vector genTileVec(vector RegPos) {
//tiles are in a grid based on the regions, so 256m = 1 tile RegPos /= 256.0; //offset provided in the javascript, really 1278 + 1 (probably 0 -> 1 index difference?) RegPos.y = 1279.0 - RegPos.y;
return RegPos;
}
string genMapURL() {
vector TilePos = genTileVec(llGetRegionCorner()); //should look like http://secondlife.com/apps/mapapi/grid/map_image/x-y-zoom-0 string mapURL = "http://secondlife.com/apps/mapapi/grid/map_image/"; mapURL += (string) llFloor(TilePos.x); mapURL += "-"; mapURL += (string) llFloor(TilePos.y); //the 3rd value is something to do with zoom, but only 1 seems to work with this //the 4th value is undefined, omitting it works but I leave it in to match SLURL mapURL += "-1-0"; return mapURL;
}
default
{
state_entry() { llSetText("SLURL Raster Image URL Generator\nOpens the image of the current sim\n(in a browser)", <1,1,1>, 1); } touch_start(integer numdet) { integer i; for(i = 0; i < numdet; ++i) llLoadURL(llDetectedKey(i), "load this page to see the sim image", genMapURL()); }
}
</lsl>