Thursday, 1 May 2014

Send email from Second Life

Sends an email to address with subject and message.
• string address
• string subject
• string message
The entire message (including the address, subject and other miscellaneous fields) can't be longer than 4096 bytes combined.

Specification

The message is prefixed with information about the prim sending the email.
Template Example
Object-Name: *prim*
Region: *simname* (*simpos.x*, *simpos.y*)
Local-Position: (*primpos.x*, *primpos.y*, *primpos.z*)

*message*
Object-Name: Object
Region: Gibson (254976, 256000)
Local-Position: (117, 129, 50)

The real message starts here.

Examples


string emailAddress = "somebody@example.com";
string emailHeader = "Someone touched me!";
 
 
default
{
    touch_start(integer num_detected)
    {
        // llSay(PUBLIC_CHANNEL, "Sending eMail report now, this will take ~20 seconds.");
 
        key id = llDetectedKey(0);
        string name = llDetectedName(0);
 
        llEmail(emailAddress, emailHeader,
            "I was touched by: '" + name + "' (" + (string)id + ").");
 
        // llSay(PUBLIC_CHANNEL, "Email has been sent.");
    }

Script to open a website in the browser as soon as the script starts running

Script to open a website in the browser as soon as the script starts running
Shows dialog to avatar offering to load web page at url with message.
If user clicks yes, launches the page in their web browser, starting the browser if required.
• key avatar avatar UUID that is in the same region
• string message message to be displayed in the dialog box
• string url
The url is truncated to 255 characters and message is truncated to 254 characters.
The protocol for the url must be specified, currently only "https://" and "http://" are supported.
The URL should be RFC-1738 compliant with proper escapes.

default
{
    touch_start(integer num_detected)
    {
    key id = llDetectedKey(0);

        // if the touching avatar is in the same sim
        if ( llGetAgentSize(id) )
        {
          string info = "My best website!";

            // must start with either "http://..." or "https://..."
            string url = "http://www.yahoo.co.uk";

            llLoadURL(id, info, url);
        }
        else
            llInstantMessage(id, "I can open it any time!");
    }
}

script to create a note card giver in Second Life

script  to create a note card giver in Second Life






1
string notecard = "Welcome Notecard";

default
{
    state_entry()
    {
       llSetText("Welcome to Notecard", <1,1,1>, 1.0);
    }

    touch_start(integer total_number)
    {
      llGiveInventory( llDetectedKey(0), notecard);
    }
}
2
when you touch the object, it gives error:
Unable to give inventory: 'No item named 'Welcome Notecard'.'.
3
solution:
put the notecard in the inventory box
4
click on inventory -> my inventory -> right click on notecards -> new notecards
in the name, type Welcome Notecard
description: notecard
Touch notecard giver


save the notecard.
drag notecard1 to contents folder.

5
now if you touch the object, it gives message:


Remember: your note card name has to be same as notecard string name


Thursday, 24 April 2014

Upload files by php script

By uploading php script to your web server you can upload many files to the server.


<form enctype="multipart/form-data" action="1-2upload.php" method="POST">
 Please choose a file: <input name="uploaded" type="file" /><br />
 <input type="submit" value="Upload" />
 </form>


Create web directry

To create an directy you have many ways, one of the ways is by php script


<form action="" method="post" >
<table width="400" border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td colspan="3" align="center">Please write your preferred directory name </td>
  </tr>
  <tr>
    <td>Name </td>
    <td>&nbsp;</td>
    <td><input type="text" name="gname" id="text" value=""></td>
  </tr>

  <tr>
    <td colspan="3" align="center"><input type="submit" name="submit" id="submit" value="Submit"></td>
  </tr>
</table>
</form>



<?php



if (isset($_POST['submit'])) {

$name = $_POST['gname'];


mkdir ("$name", 0777);

}


?>





Thursday, 13 March 2014

Second Life – Mailbox


Once we got to know how to tackle note cards and sending emails, we were asked to create a mailbox object which allows an avatar to drop a note card and this is sent to the owner of the mailbox – in this case, my avatar. A notecard is available to be viewed at a later stage. This is the required work for the next two weeks.
The mailbox is created using a typical London red mailbox as an inspiration as shown below.
images
This object is made up of a number of cylinders of different sizes. At the top, a semicircle is added with custom settings in order to produce the same rotating top of a mailbox.
creating
Color is added.
addingcolor
A small box which  would ‘insert’ a notecard is added to the mailbox to make it more realistic.
black
Next, a script is added. This is discussed later on in this blog entry. The script initially asks to user to touch the mailbox and the small entry in it would light up. Also, on dropping a notecard on it, my avatar is able to read the notecard later on.
lighton
Some explanations on the script used for this mailbox is done below. Later on, a link is provided to see the full script.
Light
The light script has been researched for and found through this link: http://wiki.secondlife.com/wiki/Category:LSL_Light. Initially, a number of variables are declared and initialised. The first method is switchit() which basically occurs on an avatar’s request to switch the light on or off. If it is not switched on, it will do so by the llSetColor() function.
llSetColor()
By default, the mailbox displays a message stating “Touch for light”. This is shown in the images above. One important function for this work is the llAllowInventoryDrop() function which must be set to TRUE. This is the script which allows a notecard, which is later on specified, to be added by another avatar.
AllowInventoryDrop
Sending notecard
On clicking on the mailbox, the switchit() method is called and the light is switched on or off accordingly. Also, the llGiveInventory() function is triggered which finds the notecard to be sent to my avatar.
on touch_start
When the inventory is changed, which means that a notecard has been dropped in the mailbox, a message is displayed to my avatar. This has been tested by a number of my colleagues when their avatar sent a notecard to mine. This is shown  in the image below.
notecards sent by avatars
The script for both light and sending notecard can be seen through this link:

Second Life – Letterbox with Drag and Drop.



Today I created a letterbox that allows any item to be dragged and dropped from the inventory on it. To do this I used the same letterbox as I used in my previous post, and edited the script.
I used the CHANGE_ALLOW_DROP, which will allow objects to be dropped into the letterbox.
Image
letterbox3 letterbox2letterbox5letterbox4