ソラマメブログ › Golden Fish

2009年05月21日

Scrubber

スクリプトを削除したのに、オブジェクトに残ってしまうフローティング・テキストやパーティクルなどを消す事ができる掃除道具です。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Scrubber
//// creator Unknown
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

list buttons =["SitTarget", "SitText", "FloatText", "Particles","TextureAn", "Sound", "TargetOmega", "ALL", "DESTRUCT"];

string menutext = "Select an item to clear, use ALL to Clear all, or DESTRUCT to remove script from prim";

integer handler;

default
{
state_entry()
{
if (handler)
{
llListenRemove(handler);
}
handler =llListen(1,"",llGetOwner(),"");
}
touch_start(integer num_detected)
{
llDialog(llGetOwner(), menutext, buttons, 1);
}
listen( integer channel, string name, key id, string message )
{
string lowmsg = llToLower(message);
if (lowmsg == "sittarget")
{
llWhisper(0,"Clearing Sit Position.");
llSitTarget(ZERO_VECTOR,ZERO_ROTATION);
}
if (lowmsg == "floattext")
{
llWhisper(0,"Clearing Floating Text.");
llSetText("", <1,1,1>, 1.5);
}
if (lowmsg == "particles")
{
llWhisper(0,"Clearing Particles.");
llParticleSystem([]);
}
if (lowmsg == "texturean")
{
llWhisper(0,"Clearing Texture Animation.");
llSetTextureAnim(FALSE, ALL_SIDES,0,0,0.0, 1,0.3);
}
if(lowmsg == "targetomega")
{
llWhisper(0, "Clearing llTargetOmega().");
llTargetOmega(ZERO_VECTOR, 0.0, 1.0);
}
if(lowmsg == "sound")
{
llWhisper(0, "Clearing Sounds.");
llStopSound();
}
if(lowmsg == "sittext")
{
llWhisper(0,"Clearing Sit Text.");
llSetSitText("Sit Here");
}
if (lowmsg == "all")
{
llWhisper(0,"Clearing Floating Text.");
llSetText("", <1,1,1>, 1.5);
llSetSitText("Sit Here");
llWhisper(0,"Clearing Texture Animation.");
llSetTextureAnim(FALSE, ALL_SIDES,0,0,0.0, 1,0.3);
llWhisper(0,"Clearing Particles.");
llParticleSystem([]);
llWhisper(0,"Clearing Sit Position.");
llSitTarget(ZERO_VECTOR,ZERO_ROTATION);
llWhisper(0, "Clearing llTargetOmega().");
llTargetOmega(ZERO_VECTOR, 0.0, 1.0);
llStopSound();
}
if (lowmsg == "destruct")
{
llWhisper(0,"Removing script from prim in 0.2 seconds");
llSleep(0.2);
llRemoveInventory(llGetScriptName());
}
}
}  

Posted by Kingyo at 20:03Comments(0)TrackBack(0)

2009年05月21日

Tipjar script

チップの集金目標を設定して、目標の達成率を表示するチップジャーです。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Tipjar script with a 'goal' and progress meter
//// by Angel Fluffy
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

//********************************************************
//This Script was pulled out for you by YadNi Monde from the SL FORUMS at http://forums.secondlife.com/forumdisplay.php?f=15, it is intended to stay FREE by it s author(s) and all the comments here in ORANGE must NOT be deleted. They include notes on how to use it and no help will be provided either by YadNi Monde or it s Author(s). IF YOU DO NOT AGREE WITH THIS JUST DONT USE!!!
//********************************************************

// CARP Donation box script. Written by Angel Fluffy, with credit to :
// Keknehv Psaltery, jean cook, ama omega, nada epoch, YadNi Monde
// for their work on the "DONATION box" script upon which it was based.
//
//Donation / Tipjar script with a 'goal' and progress meter (ideal for tracking tier)
//What it is : a donation box / tip jar script, that uses the concept of 'goals' and a progress meter to encourage people to donate (as people donate more when they can see the progress being made towards a set goal).
//
//Edit the config settings, drop in a prim, and pay it some money to find out how it works.
//
//In future, I intend to add a 'biggest donors' field to it which people can use to recieve a list of the top 5 donors when the prim is clicked on.
//
//
//CODE
string imtext = "I'm the __________ Donation Box! Please right click and pay me to donate, as this supports the __________ project and helps keep the place open for you!";
// this is the text sent to someone who clicks on the prim containing this script and who isn't the owner.

// first line of hover text above box (always constant)
string floaty = "__________ Donation Box\n";

// when total donated this month is less than monthlyneeded, display whatfunding_1 as the funding target,
// when it is more, display whatfunding_2. This allows you to show your donors when you have switched
// from funding your essential running costs to funding expansion.
string whatfunding_1 = "Funding : __________ \n";
string whatfunding_2 = "Funding : __________ \n";

// name of the current month
// we *could* get this automatically, but changing the month automatically isn't as easy as it seems.
// This is a change I might make in a future version.
string thismonth = "October";

// How much are we trying to raise per month?
// The script displays a countdown in SETTEXT above the prim its in, counting down until this target is reached.
// After this target is reached, the countdown disappears, being replaced with a tally.
// The goal of this is to encourage people to donate by setting a clear goal they feel they can help achieve by donating.
integer monthlyneeded = 30000;


// These two variables define the starting numbers for how much has been donated across all time, and how much this month.
// These starting numbers will have the donations the script recieves in between each reset/save added to it,
// and the result displayed in float text over the top of the script.
// The first time you start accepting donations, you should set both of the numbers below to zero.
// When saving this script, you (the object owner) should touch the donation box object,
// which will then tell you how much has been donated in total and how much has been donated this month.
// Entering this information here before saving will allow you to preserve the 'state' of the script across edits/restarts.
integer totaldonated = 0;
integer monthdonated = 0;

// these settings are like the above, but save the 'last donor' information. You can set them to "" and 0 to clear saved info.
string lastdonor = "Taffy Tinlegs";
integer lastdonated = 0;

// this interval defines how long we wait between each reminder to donate broadcast to SAY (range=20m)
integer timer_interval = 3600;

// these settings determine what the 'default' donation amounts are.
// the buttons are the 'fast pay' buttons, the 'payfield' is the default amount in the text box.
list paybuttons = [50,200,400,800];
integer payfield = 100;


// these variables should be left undefined.
string owner;
string otext;
integer mpercent;

integer updatemath() {
float mpercentfloat = ((monthdonated * 100) / monthlyneeded);
mpercent = (integer)mpercentfloat;

return 1;
}

integer updatetext() {
otext = floaty;

if (mpercent >= 100) {
otext += whatfunding_2;
} else {
otext += whatfunding_1;
}
if (lastdonated > 0) {
otext += "Last donation : L$" + (string)lastdonated + " by " + lastdonor +"\n";
}
if (mpercent >= 100) {
otext += "We have raised L$"+(string)(monthdonated - monthlyneeded)+" for this, beyond our basic running costs of L$"+(string)monthlyneeded+" for "+thismonth+". \n";
//otext += "The excess will go towards giving prizes and running special events!";
} else {
otext += "Our donors have contributed "+(string)mpercent+"% of our basic running costs ("+(string)monthdonated+"/"+(string)monthlyneeded+") for "+thismonth+".\n";
}
llSetText(otext,<1,1,1>,1);
return 1;
}
default
{
on_rez( integer sparam )
{
llResetScript();
}
state_entry()
{
updatemath();
updatetext();
owner = llKey2Name( llGetOwner() );
llSetPayPrice(payfield,paybuttons);
llSetTimerEvent(timer_interval);
llSay(0,"Script updated. Usually this is caused by the donation box owner updating the script.");
}

money(key id, integer amount)
{
totaldonated += amount;
monthdonated += amount;
lastdonor = llKey2Name(id);
lastdonated = amount;
updatemath();
updatetext();
llInstantMessage(id,"On behalf of everyone who uses this place, thank you for the donation!");
llSay(0,(string)llKey2Name(id)+" donated L$" + (string)amount + ". Thank you very much for supporting us, it is much appreciated!" );
}
touch_start(integer num_detected){
if (llDetectedKey(0) == llGetOwner()) {
llOwnerSay("Reporting script status, because you are recognised as the owner of this donation box.");
llOwnerSay("Current TOTAL donations across all time: L$"+(string)totaldonated);
llOwnerSay("Current TOTAL donations for this month: L$"+(string)monthdonated);
} else {
llInstantMessage(llDetectedKey(0),imtext);
}
}
timer() {
integer premainder = 100 - mpercent;
integer aremainder = monthlyneeded - monthdonated;
if (mpercent < 100) {
llSay(0,"We still need to meet the last "+(string)premainder+"% of our basic costs (L$"+(string)aremainder+") this month, to pay for land tier etc. Please consider donating to help us out!");
}
llSetTimerEvent(timer_interval);
}
}   

Posted by Kingyo at 19:48Comments(0)TrackBack(0)LSL

2008年12月09日

高度測定器

海面を基準にした高度と地面を基準にした高度、移動速度などが計測できます。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// air/sea altameter
//// Original creator Unknown
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

default
{
state_entry()
{
llSetTimerEvent(.01); // How often your timer() event updates
}

timer()
{
vector pos = llGetPos(); // Gets your current position
vector size = llGetAgentSize(llGetOwner()); // Get the dimensions of your agent
size.z = size.z / 2.0; // Halve the height element of your agent, get altitude from feet
float aboveground = ((float)pos.z - llGround(<0.0,0.0,0.0>) - size.z); // Distance above ground
if (aboveground < 0.0) // If it thinks your feet are below ground
{
aboveground = llSqrt(aboveground * aboveground); // - flip it
}
if (aboveground < 0.09) // Check the margin of error for zeroing - you can redefine this
{
aboveground = 0.0; // Zero it out
}
vector Speed = llGetVel(); // LSL function that should be fixed in next release.
float RealSpeed = llVecMag(Speed); // Convert it to velocity you can use.
float abovewater = llWater(<0.0,0.0,0.0>) - pos.z; // difference between yourwater height
if (pos.z >= llWater(<0.0,0.0,0.0>)) // If at or above water
{
abovewater = llSqrt(abovewater * abovewater);
}
if (pos.z < llWater(<0.0,0.0,0.0>)) // If underwater
{
abovewater = abovewater - (abovewater * 2.0); // Push the number into the negative range
}
llSetText("Sea Lvl ALT: " + (string)abovewater + "\n" + "Grnd Lvl ALT: " + (string)(aboveground) + "\nSpeed: " + (string)RealSpeed, <1.0,0.0,0.0>, 1.0); // Emit string
}
}  

Posted by Kingyo at 16:24Comments(0)TrackBack(0)LSL

2008年12月09日

アバターの移動

近くにいるアバターを磁石のように引きつけます。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Avatar Magnet Script 0.1
//// creator Unknown
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

// Avatar Magnet Script 0.1
// a simple avatar magnet with some "nice" features built in
// if you turn these features off *please*
// don't use it outside of a combat area
// even if you leave them on this script uses push to simulate a
// magnet effect it *will* register as PvP outside combat areas
//
// if you turn OBJECTS on it will attract physical objects too
// but it doesn't work very well
// especially with small objects as they usually end up flying off world
//
// this script is mostly untested
// if you have problems let me know and i'll try to fix them


// whether the object asks permission to attract or not
// be nice and ask
integer REQUIRE_PERMISSION = TRUE;

// if we are requiring permissions set this based on whether
// you want it to prompt nearby users for permissions
// or require them to touch this object to be asked permission
// TRUE means it will ask without touching
// FALSE means they must touch it to be asked
integer UNSOLICITED = TRUE;

// how far to look around for targets
// this is highly dependant on the mass of this object
// and the mass of the target
// small objects might not have enough energy to attract far away targets
// maximum of 96.0 meters
float RADIUS = 30.0;

// how forceful you want to the magnet to be
// if you set this too high it's hard for the magnet to keep up
// with the velocity of the target so you get a lot of "ping-pong" effect
// if you set it too low then the target can break away easily
// if it has the ability to apply its own impulse
// (an avatar can fly away from the magnet if it's set too low ...
// but this may be a good thing)
// the maximum amount is effectively 2147483647
// but really > 100 is too much
float FORCE = 20.0;

// attract avatars
integer AVATARS = TRUE;

// attract physical objects
// this really doesn't work very well, especially for small objects
integer OBJECTS = FALSE;

// if we're asking permission we need to keep a list of people
// who have accepted and people who have declined
// unfortunately due to memory constraints these lists will be capped
// i haven't tested this!
// if you get stack-heap errors you will need to lower the cap
integer CAP = 50;
list declined;
list accepted;

// listener handle
integer listener;

askPermission(key avatar) {
// build the message based on the settings
string message = "May this magnet attract ";
if (AVATARS) message += "you";
if (OBJECTS && AVATARS) message += " and ";
if (OBJECTS) message += "your objects";
message += "?";

// build dialog button list
// based on whether or not this is the owner
list buttons = ["Accept", "Decline"];
if (avatar == llGetOwner()) buttons += ["Turn Off"];

llDialog(avatar, message, buttons, -38739454);
}

default {
state_entry() {
// turn of collision effects
llCollisionSprite("");
llCollisionSound("", 0.0);

llSetText("Magnet Off", <1.0, 1.0, 1.0>, 1.0);

llOwnerSay("Magnet Off");
}

touch_start(integer touches) {
// turn the magnet on
if (llDetectedKey(0) == llGetOwner()) state magnetized;
}
}

state magnetized {
on_rez(integer start) {
llResetScript();
}

state_entry() {
// clear out the accepted list
accepted = [];

llSetText("Magnet On", <1.0, 1.0, 1.0>, 1.0);

llOwnerSay("Magnet On");

// the magnet shouldn't be phantom or you get weird results
llSetStatus(STATUS_PHANTOM, FALSE);

// figure out which types of targets we're attracting
integer types;
if (AVATARS) types = types | AGENT;
if (OBJECTS) types = types | ACTIVE;

// set our sensor
llSensorRepeat("", "", types, RADIUS, TWO_PI, 0.1);

// listen for dialog responses if we're asking permission
if (REQUIRE_PERMISSION)
listener = llListen(-38739454, "", "", "");
}

listen(integer channel, string name, key id, string message) {
// only listen to avatars
if (llGetOwnerKey(id) == id) {
if (message == "Accept") {
// if they were already on the accepted list
// remove their earlier entry
integer index = llListFindList(accepted, [id]);

if (index > -1)
accepted = llDeleteSubList(accepted, index, index);

// add to the end of the accepted list
accepted += [id];

// make sure our list isn't bigger than the cap
if (llGetListLength(accepted) > CAP)
accepted = llDeleteSubList(accepted, 0, 0);

// remove from the declined list if they're on it
index = llListFindList(declined, [id]);

if (index > -1)
declined = llDeleteSubList(declined, index, index);
} else if (message == "Decline") {
// remove from the accepted list if they're on it
integer index = llListFindList(accepted, [id]);

if (index > -1)
accepted = llDeleteSubList(accepted, index, index);

// if they were already on the declined list
// remove their earlier entry
index = llListFindList(declined, [id]);

if (index > -1)
declined = llDeleteSubList(declined, index, index);

// add to the end of the declined list
declined += [id];

// make sure our list isn't bigger than the cap
if (llGetListLength(declined) > CAP)
declined = llDeleteSubList(declined, 0, 0);
} else if (message == "Turn Off" && id == llGetOwner()) {
state default;
}
}
}

touch_start(integer touches) {
key toucher = llDetectedKey(0);

if (REQUIRE_PERMISSION) {
askPermission(toucher);

return;
}

if (toucher == llGetOwner()) state default;
}

sensor(integer sensed) {
integer i;

for (i = 0; i < sensed; i ++) {
key target_key = llDetectedKey(i);

// if we're getting permission
// we need to see if we've alreay bothered this person
if (REQUIRE_PERMISSION) {
// since we may be attracting objects too
// we need to make sure we're asking the owner
key owner_key = llDetectedOwner(i);

// if this person has not already accepted
// don't attract them
if (llListFindList(accepted, [owner_key]) == -1) {
// but if we haven't already bothered them
// we need to ask them
if (llListFindList(declined, [owner_key]) == -1) {
// put their name on the denied list
declined += [owner_key];

// make sure our list isn't bigger than the cap
if (llGetListLength(declined) > CAP)
declined = llDeleteSubList(declined, 0, 0);

if (UNSOLICITED) askPermission(owner_key);
}

return;
}
}

// the position of our target
vector target_pos = llDetectedPos(i);

vector my_pos = llGetPos();

// normalized vector describing the direction
// from our target to us
// this is a negative vector
// which will draw the object towards us
vector direction = llVecNorm(my_pos - target_pos);

// apply set amount of force
// in the direction from the target to this object
vector impulse = FORCE * direction;

// equalize for the targets mass so pull is consistent
impulse *= llGetObjectMass(target_key);

// equalize for the distance of the target
// so pull is consistent
impulse *= llPow(llVecDist(my_pos, target_pos), 3.0);

// negate the targets current velocity
impulse -= llDetectedVel(i);

llPushObject(target_key, impulse, ZERO_VECTOR, FALSE);
}
}

state_exit() {
// we don't actually need to do this any more because
// listeners are cleaned up on state change but we might as well
if (REQUIRE_PERMISSION) llListenRemove(listener);
}
}  

Posted by Kingyo at 11:54Comments(0)TrackBack(0)LSL

2008年12月03日

オブジェクトの回転角度を取得する

触れるとオブジェクトの回転角度をシャウトします。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Say Rotation
//// by Liaison Dan Linden
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

// This script says it's rotations in Quaternion and Vector when it's touched
//bpJ
// global variable that isn't exposed

// state sections
// default state # all scripts must have a default state

default
{
// when a state is transitioned to, the state_entry event is raised
state_entry()
{

}

touch_start(integer number)
{
rotation gQuatRotation = llGetRot();
llSay(0, "Quat rotation =" + (string)gQuatRotation);
vector gRotation = llRot2Euler(gQuatRotation);
llShout(0, "vector rotation =" + (string)gRotation);
// key ownerKey = llGetOwner();
// llSay(0, "owner's key = " + (string)ownerKey);
// llWhisper(0, "owner's key = " + (string)ownerKey);
// llInstantMessage(ownerKey, "owner's key = " + (string)ownerKey);
}

}  

Posted by Kingyo at 22:50Comments(0)TrackBack(0)LSL

2008年10月01日

建造の制御

このスクリプトをアクティブにすると、オブジェクトは最初にREZしたSIM以外のSIMにREZできなくなります。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Stay in sim!
//// creator Unknown
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

//This script makes sure that your objects stay in the sim that they are created. You can't save an object to inventory and rez in in another sim while this script is active.

123//remove the 123 to be able to use this script. Just delete the numbers and make sure running in the lower left is checked and hit save.(123を取り除いて、このスクリプトを使用下ください。)

//Make sure you save a copy of this script and all others in this package before removing the 123.default
{
state_entry()
{
llSetStatus(STATUS_DIE_AT_EDGE,TRUE);
vector INITCorner = llGetRegionCorner();
while(TRUE)
{
if(llGetRegionCorner() != INITCorner)
{
llDie();
}
}
}
}  

Posted by Kingyo at 22:25Comments(0)TrackBack(0)LSL

2008年10月01日

テクスチャーのアニメーション

プリムにマッピングされたテクスチャーがアニメーションします。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// anim SMOOTH
//// by Doug Linden(I think)
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

// Drop on an object to make it change colors.
//
// If you are interested in scripting, check out
// the Script Help under the help menu.

// The double slash means these lines are comments
// and ignored by the computer.

// All scripts have a default state, this will be
// the first code executed.
default
{
// state_entry() is an event handler, it executes
// whenever a state is entered.
state_entry()
{
// llSetTextureAnim() is a function that animates a texture on a face.
llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, ALL_SIDES,1,1,1.0, 1,0.25);
// animate the script to scroll across all the faces.
}
}
  

Posted by Kingyo at 22:18Comments(0)TrackBack(0)LSL

2008年10月01日

テクスチャーの変化

クリックするとContents-Inventoryの2種類のテクスチャーが交互に変化します。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// TextureSwitcher - Touch
//// creator Unknown
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

default
{

touch_start(integer total_number)
{
integer number = llGetInventoryNumber(INVENTORY_TEXTURE);
float rand = llFrand(number);
integer choice = (integer)rand;
string name = llGetInventoryName(INVENTORY_TEXTURE, choice);
if (name != "")
llSetTexture(name, ALL_SIDES);
}
}  

Posted by Kingyo at 22:14Comments(0)TrackBack(0)LSL

2008年10月01日

気圧計

クリックした位置の気圧を計測して、000.000000 KiloPascal.と表示します。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// AirPressure(vector v) Script
//// by Cid Jacobs
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

// llAirPressure(vector v) Script
// Created by: Cid Jacobs
// Original by: Cid Jacobs
// Last Updated: 11-17-05
// Notes: Speak with Cid Jacobs about any concerns.
//
//This script will calculate air pressure at the objects vector plus offset.
//
//--------------------Globals
//Global Memory Storage For Calibration Offset
float Calibration = 101.32500;
//Global Memory Storage For User Definable Vector Offset
vector Offset = <0,0,10>;
//
//
//--------------------User Defined Function
float llAirPressure(vector Offset)
{
//Extrapolate Task's Local Coordinates
vector Position = llGetPos();
//Calculate And Calibrate Air Pressure
float Base_Reading = llLog10(5- (((Position.z - llWater(ZERO_VECTOR)) + Offset.z)/15500));
//Total Sum Air Pressure
float KiloPascal = (Calibration + Base_Reading);
return KiloPascal;
}
//
//
//--------------------States
//Mandatory Default State
default
{
//Triggered By The Start Of Agent Clicking
touch_start(integer num_detected)
{
//Say Current Total Air Pressure at Task + V
llSay(0,"Current air pressure is: "
+
(string)llAirPressure(Offset)
+
" KiloPascal.");
}
}
  

Posted by Kingyo at 16:53Comments(0)TrackBack(0)LSL

2008年10月01日

ストプウォチ

クリックしてスタート、クリックしてストップ、”reset”とチャットすると時計がリセットされます。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// StopWatch
//// by Water Rogers for IBM/Opensource
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

// Purpose
// --------------------------------------------------------------
// This is a basic example of how you can create a stopwatch.
//

// Requirements
// --------------------------------------------------------------
// A single prim is all that is necessary for this example.

// Usage
// --------------------------------------------------------------
// Touch the object to toggle the timer off/on
// type "reset" to reset the timer. Not case-sensitive.



// GLOBAL VARIABLES
// --------------------------------------------------------------

integer g_Seconds = 0; // Globaly store the Seconds
integer g_Minutes = 0; // Globaly store the Minutes
integer g_Hours = 0; // Globaly store the Hours
integer g_Ticking = FALSE; // Toggles the timer off/on
vector g_TextColor = <1,1,1>; // Text color for the timer. <1,1,1> = White


// FUNCTIONS
// --------------------------------------------------------------

// This is a simple function to zero pad the numbers 2 spaces to make
// the timer look more authentic. It takes an integer as an argument
// and outputs a string.
string zero_pad(integer number)
{
if(number < 10) return "0" + (string)number;
return (string)number;
}


// EVENTS
// --------------------------------------------------------------

default
{
state_entry()
{
// ------------------------------------------------------
// This is the entry-point of the script. After a script
// has been saved or reset, this event will fire off first
// ------------------------------------------------------

// We call llSetText() first to reset the text above the object
// back to 00:00:00 time.
llSetText("00:00:00", g_TextColor, TRUE);

// Set up a listener so that we can reset the timer by typing
// "reset". This particular listener will listen to any chat
// typed by anyone (or any object)
llListen(0, "", "", "");

// Finally, we set up a timer that will repeat itself every
// g_Ticking seconds. Since g_Ticking could only ever possibly
// equal 0 or 1, we can use this to our advantage in optimizing.
// This particular example is not necessary, but can have a
// dramatic impact on larger scripts. Note that setting a timer
// to 0 (False) will indeed turn off the timer.
llSetTimerEvent(g_Ticking);
}

touch_start(integer num_detected)
{
// If someone touches the object, it will toggle the timer off/on

// We can avoid using if/else statements here because of the
// nature of our timer. Using an exclamation in front of the
// variable "flips" the bits. In this case, our variable is either
// only ever TRUE (1) or FALSE(0). Since we need the timer to
// tick each second, this becomes a nice optimization method.
g_Ticking = !g_Ticking;
llSetTimerEvent(g_Ticking);

}

listen(integer channel, string name, key id, string message)
{
// This event is fired off whenever anyone chats around the object
// and a proper listener is set up, such as in state_entry()

// We take the message and make it all lowercase so that the word
// "reset" is not case-sensitive
message = llToLower(message);
if(message == "reset")
{
// The filter determined that the word "reset" was typed. So
// we need to reset everything back to 0, and turn the timer off
g_Ticking = FALSE;
llSetTimerEvent(0);
llSetText("00:00:00", g_TextColor, TRUE);
g_Seconds = 0; g_Minutes = 0; g_Hours;
}
}

timer()
{
// This event fires off each second because the integer 1 is being
// passed as the argument for seconds in llSetTimerEvent(float seconds)

// Incriment the global Seconds variable by 1
g_Seconds++;

// If seconds are at 60, then we've just made a minute
if(g_Seconds >= 60)
{
// So we increment the global minutes by 1, and reset the seconds.
g_Minutes++;
g_Seconds = 0;

// If the minutes are at 60, then we've just made an hour
if(g_Minutes >= 60)
{
// Increment the global hours by 1, and reset the minutes.
g_Hours++;
g_Minutes = 0;
}
}

// Display everything above the object. Notice the use of the zero_pad()
// function that we created earlier to make the timer look better.
llSetText(zero_pad(g_Hours) + ":" + zero_pad(g_Minutes) + ":" + zero_pad(g_Seconds), g_TextColor, TRUE);
}
}
  

Posted by Kingyo at 16:48Comments(1)TrackBack(0)LSL

2008年10月01日

タイマー

タイマをセットしREZするだけ。時間が経過すれば"time is up" と表示されます。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Timer
//// by Murdock Pennell
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

string time = "time is up"; //this is what it will say when the time is up
float sec = 10;// how long you whant the timer to be in seconds

default
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{
llSetTimerEvent(sec);
}
timer()
{
llSay(0,time);
}
}  

Posted by Kingyo at 16:45Comments(0)TrackBack(0)LSL

2008年09月30日

チャットロガー

クリックするとチャットの記録を開始、再びクリックするとチャットの記録を表示します。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Chat Logger
//// creator Unknown
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

list names;
list speech;
list colours=["002EB8","FF6633","006600","660066","660033","663300",
"1A9900","FF14B1","001A99","#B88A00"];
list unique_names;

default
{
state_entry()
{
llSetText("This is a chat logger - currently only for testing",<0,0,0>,1.0);
integer i;
integer c;
for (i = 0;i< llGetListLength(names);i++)
{
c = llListFindList(unique_names,llList2List(names,i,i) );
while (c >= llGetListLength(colours)) // dont crash if I run out of colours
c -= llGetListLength(colours);
llSetObjectName("[color=#" + llList2String(colours,c)
+ "]" + llList2String(names,i) );
llOwnerSay( llList2String(speech,i) + "[/color]" );
}
names = [];
speech = [];
unique_names = [];
llSetObjectName("Patch's Funky Chat Logger");
}

on_rez(integer i)
{
llResetScript();
}

touch_start(integer total_number)
{
if (llDetectedKey(0) == llGetOwner() )
{
llSay(0, "logging on!.");
state logging_chat;
}
}
}

state logging_chat
{
state_entry()
{
llListen(0,"",NULL_KEY,"");
}

on_rez(integer i)
{
llOwnerSay("Logging still on! Touch to get playback");
}

touch_start(integer total_number)
{
if (llDetectedKey(0) == llGetOwner() )
{
llSay(0, "chat logging now off - replaying log!.");
state default;
}
}

listen(integer channel, string name, key id, string message)
{
if(llListFindList(unique_names,[name]) == -1)
{
unique_names += name;
}
names += name;
speech += message;
}

}
  

Posted by Kingyo at 10:08Comments(2)TrackBack(0)LSL

2008年09月30日

メモをメール送信

コマンド"add"の後に入力したテキストを記録しコマンド"backup"で記録したテキストをメール送信します。詳しくはコマンド"help"で。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Reminder List
//// creator Unknown
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

list gReminders;//Reminder List
string gEmailBackup = "youremail@yourhost.com"; // Email for information backups
integer listnumber;
integer remove;
integer gChannel = 1;//Listen channel
string gCommand1 = "add";//command to add a list item
integer gDigits1 = 3;//Number of digits in the above command
string gCommand2 = "remove";//command to remove a list item
integer gDigits2 = 6;//Number of digits in the above command
string gRemindtext = "";
string gCommand = "";
integer command_listen;

default
{
state_entry()
{
llListenRemove(command_listen);
command_listen = llListen(gChannel, "", llGetOwner(), "");
}

listen( integer channel, string name, key id, string message )
{
if( message == "deletelist" ) //clear entire list
{
llOwnerSay("Deleting list...");
gReminders = [];// delete list
llResetScript();//reset script to update free memory report
}

if( message == "help" ) //reply with help
{
llOwnerSay("Reminder list commands");
llOwnerSay("'/" + (string)gChannel + " listhelp' - Shows these instructions." );
llOwnerSay("'/" + (string)gChannel + " add text' - Adds the specified text to the list.");
llOwnerSay("'/" + (string)gChannel + " list' - Displays the current list.");
llOwnerSay("'/" + (string)gChannel + " remove #' - Removes list entry # from the current list.");
llOwnerSay("'/" + (string)gChannel + " backup' - Sends a copy of the list to " + gEmailBackup +".");
llOwnerSay("'/" + (string)gChannel + " deletelist' - Deletes the entire list." );
}

if (message == "backup")
{
//llOwnerSay(llDumpList2String(gReminders, " \n"));
llEmail(gEmailBackup, "Reminder List Backup", "Reminder List: \n" + llDumpList2String(gReminders, " \n"));
// send copy of email to gmail
}

if( message == "list" )
{
llOwnerSay("Things to remember:");
listnumber = 1;//Start the list numbering
integer len = llGetListLength( gReminders );//Pull list length
integer i;
for( i = 0; i < len; i++ )//List stepping
{
llOwnerSay(" "+ (string)listnumber + ": " + llList2String(gReminders, i) );//report list values
listnumber = listnumber + 1;//step the list numbering +1
}
llOwnerSay("Memory remaining: " + (string)llGetFreeMemory()); //report remaining memory
}

gCommand = llDeleteSubString(message,gDigits2,-1); // Pull only the first 6 letters
if( gCommand == "gCommand2") //Check to see if it matches
{
remove = (integer)llDeleteSubString(message, 0, gDigits2);// Pull everything after the first 6 letters, mke it an integer
llOwnerSay("Removing list item #" + (string)remove);
remove = remove - 1;// Correct for lists starting at 0
gReminders = llDeleteSubList(gReminders, remove, remove);//remove desired line
}

gCommand = llDeleteSubString(message,gDigits1,-1); // Pull only the first 3 letters
if( gCommand == gCommand1) //Check to see if it matches
{
gRemindtext = llDeleteSubString(message, 0, gDigits1);// Pull everything after the first 3 letters
llOwnerSay("Adding Reminder: " + gRemindtext);// tell the user what the fuck we're doing
gReminders = gReminders + gRemindtext;//Add a new reminder to the list
}
}
}
  

Posted by Kingyo at 09:52Comments(0)TrackBack(0)LSL

2008年09月30日

スライディングドアー

スライドして開閉するドアー
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Sliding Door v4
//// by Kayla Stonecutter
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

//How far in meters to travel in each direction. Two or all three can be used for angled movement
//NOTE: when linked, this is relative to the root prim
//Positive = move north, negative = move south
float NorthSouth = -2.0;
//Positive = move east, negative = move west
float EastWest = -0.1;
//Positive = move up, negative = move down
float UpDown = 0.0;

//The amount in seconds to stay open, set to 0 to not autoclose
float Timer = 15.0;

//Sound to play on open, either a UUID or a name in the door contents
//if a name, it must be exact. Leave at "" for no sound
string OpenSound = "cb340647-9680-dd5e-49c0-86edfa01b3ac";

//Volume to play open sound, 0.0 is same as no sound, 1.0 is max
float OpenVol = 1.0;

//Sound to play on close, either a UUID or a name in the door contents
//if a name, it must be exact. Leave at "" for no sound
string CloseSound = "e7ff1054-003d-d134-66be-207573f2b535";

//Volume to play close sound, 0.0 is same as no sound, 1.0 is max
float CloseVol = 1.0;


//misc variables
vector Pos;
vector Offset;
integer Open;
integer x;

default
{
state_entry()
{
Offset = ;
}

touch_start(integer num)
{
for(x = 0; x < num; x++)
{
Open = !Open;
if(Open)
{
Pos = llGetLocalPos();
if(OpenSound != "") llTriggerSound(OpenSound, OpenVol);
llSetPos(Pos + Offset);
llSetTimerEvent(Timer);
}else{
if(CloseSound != "") llTriggerSound(CloseSound, CloseVol);
llSetPos(Pos);
llSetTimerEvent(0);
}
}
}

on_rez(integer param)
{
llResetScript();
}

moving_end()
{
if(Open)
{
Open = 0;
llSetTimerEvent(0.0);
}
}

timer()
{
if(CloseSound != "") llTriggerSound(CloseSound, CloseVol);
llSetPos(Pos);
llSetTimerEvent(0);
Open = 0;
}
}  

Posted by Kingyo at 09:33Comments(0)TrackBack(0)LSL

2008年09月30日

回転ドアー

回転して開閉するドアー
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// open/close door
//// creator Unknown
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

// Swinging door LSL script #1
// Handles the touch event.
// Handles the collision event.
// Handles closing the door automatically via a timer event.
// Triggers sounds when the door opens or closes.

// Parameters you might want to change

float delay = 3.0; // time to wait before automatically closing door
// set to 0.0 to not automatically close
float direction = 1.0; // set to 1.0 or -1.0 to control direction the door swings
float volume = 0.5; // 0.0 is off, 1.0 is loudest

// Variables you will most likely leave the same

key open_sound = "cb340647-9680-dd5e-49c0-86edfa01b3ac";
key close_sound = "e7ff1054-003d-d134-66be-207573f2b535";

// Processing for the script when it first starts up

default {
// What we do when we first enter this state

state_entry() {
state open; // Move to the open state
}
}

// Processing for the script when it is in the closed state

state closed {
// What we do when we first enter this state

state_entry() {
llTriggerSound(close_sound, volume); // Trigger the sound of the door closing
llSetRot(llEuler2Rot(<0, 0, direction * PI_BY_TWO>) * llGetRot());

}

// What we do when the door is clicked (”touched”) with the mouse

touch_start(integer total_number) {
state open; // Move to the open state
}

// What to do when something hits the door

collision_start(integer total_number)
{
state open; // Move to the open state
}

// What to do when the timer goes off

timer()
{
llSetTimerEvent(0.0); // Set the timer to 0.0 to turn it off
}
}

// Processing for the script when it is in the open state

state open {
// What we do when we first enter this state

state_entry() {
llTriggerSound(open_sound, volume);// Trigger the sound of the door opening
llSetRot(llEuler2Rot(<0, 0, -direction * PI_BY_TWO>) * llGetRot());

llSetTimerEvent(delay); // Set the timer to automatically close it
}

// What do do when pulling the door from Inventory if it was saved while open

on_rez(integer start_param) {
state closed;
}

// What we do when the door is clicked (”touched”) with the mouse

touch_start(integer total_number) {
state closed; // Move to the closed state
}

// What to do when something hits the door

collision_start(integer total_number)
{
// Do nothing, the door is already open
}

// What to do when the timer goes off

timer()
{
llSetTimerEvent(0.0); // Set the timer to 0.0 to turn it off
state closed; // Move to the closed state
}
}


  

Posted by Kingyo at 09:30Comments(0)TrackBack(0)LSL

2008年09月30日

アイリスドアー

(眼球の)虹彩(こうさい)の様に開閉するドアー
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Iris Door
//// by YadNi Monde
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

//********************************************************
//This Script was pulled out for you by YadNi Monde from the SL FORUMS at http://forums.secondlife.com/forumdisplay.php?f=15, it is intended to stay FREE by it s author(s) and all the comments here in ORANGE must NOT be deleted. They include notes on how to use it and no help will be provided either by YadNi Monde or it s Author(s). IF YOU DO NOT AGREE WITH THIS JUST DONT USE!!!
//********************************************************

// Iris Open Script by Cera Murakami - 7/21/2006
// Touch-sensitive iris opening door
// Toggles open and closed state for a hole in a torus as an iris door
// Put this script into a flattened torus.

// Iris opening door script, using a torus
//This script enables you to use a torus as a simple touch-activated iris door, for science fiction or organic building projects. It uses a torus as the prim for the door, and opens or closes the hole in the torus to operate it.
//
//To use, make a flattened torus, the height and width you need for your door, and about 0.1M to 0.05M thick. The 'door frame' for this can be another torus, or an oval or round hole in another prim.
//
//Note that the same script should also be able to be used with a different prim shape for the iris door prim, by changing the specifications in the two llSetPrimitiveParams statements to suit the other prim shape. I'll experiment some more with that soon, and will offer some variations here later.


// ----- Global Variables ------------------
integer g_OpenNow; // True (1) if iris is 'open' now

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

state_entry()
{
if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size
{
state WaitToClose;
}
else // Prim is in a closed (or undefined state), so calculate new 'open' size
{
g_OpenNow = FALSE;
state WaitToOpen;
}
}
}

state WaitToClose // Iris is Open, and waiting to close
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = FALSE;
state WaitToOpen;
}
}

state WaitToOpen // Iris is closed, and waiting to open
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.05, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = TRUE;
state WaitToClose;
}
}  

Posted by Kingyo at 09:23Comments(0)TrackBack(0)LSL

2008年09月30日

カレンダー

クリックすると曜日を表示します。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Day of the week
//// creator Unknown
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

string getDay(integer offset) {
list weekdays = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"];
integer hours = llGetUnixTime()/3600;
integer days = (hours + offset)/24+17; //サマータイムの場合は+16
integer day_of_week = days%7;
return llList2String(weekdays, day_of_week);
}

default {
touch_start(integer total_number) {
integer offset = -4; // offset from UTC
llSay(0, "Today is " + getDay(offset) + ".");
}
}  

Posted by Kingyo at 09:05Comments(0)TrackBack(0)LSL

2008年09月29日

光のオン・オフ

クリックで光のオン・オフを切換える照明器具などに使えるスクリプトです。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// neon light script - touch on/off, fully adjustable
//// creator Unknown
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

vector color = <1,1,1>; // Use to change the color of the light
float intensity = 1.000; // Use to change the intensity of the light, from 0 up to 1
float radius = 10.000; // Use to change the Radius of the light, from 0 up to 20
float falloff = 0.750; // Use to set the falloff of the light, from 0 up to 2

// Everything below here is just script stuff, you don't have to mess with it unless you know what you are doing.

integer g_OpenNow; // True (1) if light is on now

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

state_entry()
{
llSay(0, "touch to turn on and off");
if (g_OpenNow == TRUE)
{
state WaitToClose;
}
else
{
g_OpenNow = FALSE;
state WaitToOpen;
}
}
}

state WaitToClose // light is off waiting to turn on
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <1, 1, 1>, 1.0, 10.0, 0.75]);
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);
g_OpenNow = FALSE;
state WaitToOpen;
}
}

state WaitToOpen // light is on, waiting to turn off
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, color, intensity, radius, falloff]);
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);
g_OpenNow = TRUE;
state WaitToClose;
}
}  

Posted by Kingyo at 18:32Comments(0)TrackBack(0)LSL

2008年09月29日

SLURL Maker 0.4

クリックするとオブジェクトをREZした場所のSLURLが返ってきます。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// SLURL Maker 0.4
//// by Dyne Talamasca
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

// This is a simple script to generate a basic SLURL from your present location (so you can copy it and paste it somewhere outside of SL).
//Put it in a HUD attachment or something, then just touch the HUD to make the slurl. Open your chat history and copy from there.
//I don't know of a way to retrieve the parcel name or description, so this just uses the sim name as the SLURL title. It doesn't convert spaces in the names.


vector Where;
string Name;
string SLURL;
integer X;
integer Y;
integer Z;

default
{
touch_start(integer numtouching)
{
llOwnerSay("One moment, retrieving data...");
Name = llGetRegionName();
Where = llGetPos();

X = (integer)Where.x;
Y = (integer)Where.y;
Z = (integer)Where.z;


// I don't replace any spaces in Name with %20 and so forth.

SLURL = "http://slurl.com/secondlife/" + Name + "/" + (string)X + "/" + (string)Y + "/" + (string)Z + "/?title=" + Name;

llOwnerSay(SLURL);
}

}  

Posted by Kingyo at 18:24Comments(0)TrackBack(0)LSL

2008年09月27日

ウエルカムマット

ドアーマットの上を歩くと歓迎のメッセージを返します。
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//// Welcome Mat
//// Script Donated to The Wall Of Script by Alan Edison,
//// Original creator Unknown. Modified by Jason Keegan.
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

1// Remove this number for this script to work.(この数を取り除いてスクリプトを動かしてください。)

//This is a welcoming script, It will be triggered as it detects someone walking on the prim which has this script in it.

string Welcome = "Welcome to my humble abode"; //This is the message the welcome mat will give when it detects someone on it.

string Online = "Welcome mat Online."; //This is the message you will hear when the script is reset to confirm the script is active.

float gSleep = 3;// This is the time delay of the welcome mat, Giving time for the person that sets the welcome mat enough time to walk off.

integer name = TRUE; //If you do not wish for the welcome mat to also add thename of the person that walked on it, Then change the TRUE to FALSE.

default
{
state_entry()
{
llSay(0, Online);
}

collision_start(integer total_number)
{
if (name == TRUE)
{
llWhisper(0, Welcome + " " + llDetectedName(0));
llSleep(gSleep);
}
else
{
llWhisper(0, Welcome);
llSleep(gSleep);
}
}
on_rez(integer start_param)
{
llResetScript();
}
}
  

Posted by Kingyo at 14:55Comments(0)TrackBack(0)LSL