Difference between revisions of "Best Neighbor Ad Hiding Script"

From Second Life Wiki
Jump to navigation Jump to search
m (<lsl> tag to <source>)
 
(4 intermediate revisions by 2 users not shown)
Line 5: Line 5:
Even after changes regulating the form of advertising billboards in Second Life, many users are still dissatisfied with the look of some ads.  As part of a "Best Neighbor" policy, some advertisers have agreed to hide their advertisements when nearby land owners are logged in.  Doran Zemlja was kind enough to release a script to do this under the open source GPL license.
Even after changes regulating the form of advertising billboards in Second Life, many users are still dissatisfied with the look of some ads.  As part of a "Best Neighbor" policy, some advertisers have agreed to hide their advertisements when nearby land owners are logged in.  Doran Zemlja was kind enough to release a script to do this under the open source GPL license.


<lsl>
<source lang="lsl2">
//  best neighbor.lsl: Best Neighbor Ad Hider
//  best neighbor.lsl: Best Neighbor Ad Hider
//  Copyright (C) 2009 Adam Wozniak and Doran Zemlja
//  Copyright (C) 2009 Adam Wozniak and Doran Zemlja
Line 26: Line 26:
//  adam-opengate@cuddlepuddle.org
//  adam-opengate@cuddlepuddle.org


// Scan for owners on their own land within 96m
// Scan for owners on their own land within 96m
// If any are found, go invisible by setting all alphas to 0.0
// If any are found, go invisible by setting all alphas to 0.0
// Otherwise go visible by setting all alphas to 1.0
// Otherwise go visible by setting all alphas to 1.0


// This is a compromise solution to the "ad problem".  The hope is that
// This is a compromise solution to the "ad problem".  The hope is that
// if the ad is invisible to nearby land owners, then they are less
// if the ad is invisible to nearby land owners, then they are less
// likely to complain about the ad.
// likely to complain about the ad.


// Adapted from an idea proposed by Temporal Mitra
// Adapted from an idea proposed by Temporal Mitra
// in Arbor Project group chat.
// in Arbor Project group chat.


// And no, copying an idea is NOT theft.  Pepsi isn't stealing from Coke,
// And no, copying an idea is NOT theft.  Pepsi isn't stealing from Coke,
// and I'm not stealing from toaster manufacturers when I design and build
// and I'm not stealing from toaster manufacturers when I design and build
// my own kind of toaster, even if toast is a pretty neat idea.
// my own kind of toaster, even if toast is a pretty neat idea.


// variable to store current visibility state
// force alpha value for all prims in linkset
integer visible = FALSE;
setAlpha(float alpha)
{
    llSetLinkAlpha(LINK_SET, alpha, ALL_SIDES);
}


// force an alpha for this prim, as well as all linked prims in set
// change visibility
setAlpha(float alpha) {
changeVisibilityTo(integer inputInteger)
  llSetAlpha(alpha, ALL_SIDES);
{
  llSetLinkPrimitiveParams(LINK_SET,
    if (inputInteger)
        [ PRIM_COLOR, ALL_SIDES, < 1.0, 1.0, 1.0 >, alpha ]);
        setAlpha(1.0);
}


// make it visible if it ain't already
    else
makeVisible() {
        setAlpha(0.0);
  if (!visible) {
      visible = TRUE;
      setAlpha(1.0);
  }
}
}


// make it invisible if it isn't already
default
makeInvisible() {
{
  if (visible) {
    on_rez(integer start_param)
      visible = FALSE;
    {
      setAlpha(0.0);
        llResetScript();
  }
    }
}


default {
    state_entry()
  state_entry() {
    {
      makeVisible();
        changeVisibilityTo(TRUE);
      llSensorRepeat("", NULL_KEY, AGENT, 96.0, PI, 10);
        llSensorRepeat("", NULL_KEY, AGENT, 96.0, PI, 10);
  }
    }


  on_rez(integer param) {
    sensor(integer num)
      llResetScript();
    {
  }
        integer found = FALSE;


  no_sensor() {
        integer i;
      makeVisible();
        do
  }
        {
            key id = llDetectedKey(i);
            key landOwnerAtDetectedPos = llGetLandOwnerAt(llDetectedPos(i));


  sensor(integer num) {
            if (id == landOwnerAtDetectedPos)
      integer found = 0;
                found = TRUE;
      integer i;
        }
        while (++i < num);


      for (i = 0; i < num; i++) {
        if (found)
        if (llDetectedKey(i) == llGetLandOwnerAt(llDetectedPos(i))) {
            changeVisibilityTo(FALSE);
            found++;
        else
        }
            changeVisibilityTo(TRUE);
      }
    }


      if (found) {
    no_sensor()
        makeInvisible();
    {
      }
        changeVisibilityTo(TRUE);
      else {
    }
        makeVisible();
      }
  }
}
}
 
</source>
</lsl>


==See also==
==See also==
[[ Advertising_in_Second_Life | Advertising in Second Life ]]
*[[ Advertising_in_Second_Life | Advertising in Second Life ]]
*[[ Script_Library | Script Library ]]

Latest revision as of 19:26, 24 January 2015

Best Neighbor Ad Hiding Script

Introduction

Even after changes regulating the form of advertising billboards in Second Life, many users are still dissatisfied with the look of some ads. As part of a "Best Neighbor" policy, some advertisers have agreed to hide their advertisements when nearby land owners are logged in. Doran Zemlja was kind enough to release a script to do this under the open source GPL license.

//  best neighbor.lsl: Best Neighbor Ad Hider
//  Copyright (C) 2009 Adam Wozniak and Doran Zemlja
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
//  Adam Wozniak and Doran Zemlja
//  1352 Fourteenth St, Los Osos, CA 93402
//  adam-opengate@cuddlepuddle.org

//  Scan for owners on their own land within 96m
//  If any are found, go invisible by setting all alphas to 0.0
//  Otherwise go visible by setting all alphas to 1.0

//  This is a compromise solution to the "ad problem".  The hope is that
//  if the ad is invisible to nearby land owners, then they are less
//  likely to complain about the ad.

//  Adapted from an idea proposed by Temporal Mitra
//  in Arbor Project group chat.

//  And no, copying an idea is NOT theft.  Pepsi isn't stealing from Coke,
//  and I'm not stealing from toaster manufacturers when I design and build
//  my own kind of toaster, even if toast is a pretty neat idea.

//  force alpha value for all prims in linkset
setAlpha(float alpha) 
{
    llSetLinkAlpha(LINK_SET, alpha, ALL_SIDES);
}

//  change visibility
changeVisibilityTo(integer inputInteger)
{
    if (inputInteger)
        setAlpha(1.0);

    else
        setAlpha(0.0);
}

default
{
    on_rez(integer start_param)
    {
        llResetScript();
    }

    state_entry()
    {
        changeVisibilityTo(TRUE);
        llSensorRepeat("", NULL_KEY, AGENT, 96.0, PI, 10);
    }

    sensor(integer num)
    {
        integer found = FALSE;

        integer i;
        do
        {
            key id = llDetectedKey(i);
            key landOwnerAtDetectedPos = llGetLandOwnerAt(llDetectedPos(i));

            if (id == landOwnerAtDetectedPos)
                found = TRUE;
        }
        while (++i < num);

        if (found)
            changeVisibilityTo(FALSE);
        else
            changeVisibilityTo(TRUE);
    }

    no_sensor()
    {
        changeVisibilityTo(TRUE);
    }
}

See also