Difference between revisions of "User:Lastro Greenwood"

From Second Life Wiki
Jump to navigation Jump to search
Line 5: Line 5:


== Scratch Pad ==
== Scratch Pad ==
=== llCastRay ===
Determines if something is blocking line of sight to avatar.
Uses:
* Radiation?
* Checking to see if avatar is hiding behind cover
* Checking to see if avatar has line of sight to a heat source
* Other stuff that requires LOS
<lsl>integer getnumobj(list traceres)
<lsl>integer getnumobj(list traceres)
{
{
Line 10: Line 19:
}
}


integer isVisible(vector start, vector finish)
integer isVisible(vector start, vector finish, integer filter)
{
{
     list res = llCastRay(start,finish,0,0);
     list res = llCastRay(start,finish,filter,0);
     integer numobj = getnumobj(res);
     integer numobj = getnumobj(res);
      
      
Line 32: Line 41:
         vector pos = llGetPos();
         vector pos = llGetPos();
         vector finalpos = llDetectedPos(0);
         vector finalpos = llDetectedPos(0);
         if(isVisible(pos,finalpos) == TRUE)
         if(isVisible(pos,finalpos,AGENT) == TRUE)
             llOwnerSay("I can see clearly now!");
             llOwnerSay("I can see clearly now!");
         else
         else

Revision as of 16:35, 6 August 2010

Lastro Greenwood's Page

Hey everyone, I'm Lastro Greenwood.

I specialise in software development but can kinda build.

Scratch Pad

llCastRay

Determines if something is blocking line of sight to avatar.

Uses:

  • Radiation?
  • Checking to see if avatar is hiding behind cover
  • Checking to see if avatar has line of sight to a heat source
  • Other stuff that requires LOS

<lsl>integer getnumobj(list traceres) {

   return (integer)llList2String(traceres,llGetListLength(traceres)-1);

}

integer isVisible(vector start, vector finish, integer filter) {

   list res = llCastRay(start,finish,filter,0);
   integer numobj = getnumobj(res);
   
   if(numobj == 0)
       return TRUE;
   
   return FALSE;

}

default {

   state_entry()
   {
       
   }
   touch_start(integer total_number)
   {
       vector pos = llGetPos();
       vector finalpos = llDetectedPos(0);
       if(isVisible(pos,finalpos,AGENT) == TRUE)
           llOwnerSay("I can see clearly now!");
       else
           llOwnerSay("Something is in my way!");
   }

}</lsl>