Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

A funny door, need help please

raven Blair
Registered User
Join date: 2 Feb 2004
Posts: 39
11-01-2009 00:26
ok for once I have no starter code for this cause I Epic Failed with this one. I tried to make this script but it wouldn't even compile and after hours of working on it I got mad and blew it up lol. so what I want to do is, Put a list of friends in a note card in this prim, the prim will sensor once someone gets close, if the person is on the note card the prim will then turn Phantom and invisible, once they pass through it will turn visible and solid. if anyone can help that would be great. I will start over myself and if I get anything working or slightly working Ill post it here.


thanks


lol well I got this, now to add list, and sensor instead of collision.......

default
{
collision_start(integer num_detected)
{
if (llDetectedType(0) & AGENT)
{
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]);
}
}
collision_end(integer num_detected)
{
if (llDetectedType(0) & AGENT)
{
llSetPrimitiveParams([PRIM_PHANTOM, FALSE]);
llResetScript();
}

}
}
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
11-01-2009 01:12
Something like this?

CODE

string NoteCardName;
integer Line;
key Query;

list Allowed;

default
{
state_entry()
{
NoteCardName =llGetInventoryName( INVENTORY_NOTECARD,0 );
if (NoteCardName != "") {
llOwnerSay( "Reading notecard..." );
Query = llGetNotecardLine( NoteCardName, Line);
} else llOwnerSay( "I need a notecard with allowed names please." );
}

dataserver(key query_id, string data)
{
if (query_id == Query){
if (data != EOF){
Allowed += [llToLower( data )];
++Line;
Query = llGetNotecardLine( NoteCardName, Line );
} else {
llOwnerSay( "Done reading notecard." );
state active;
}
}
}

changed(integer change)
{
if( change & CHANGED_INVENTORY ) llResetScript();
}

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

state active
{
state_entry()
{
llSetPrimitiveParams( [PRIM_COLOR, ALL_SIDES, <1.0,1.0,1.0>, 1.0, PRIM_PHANTOM, FALSE] );
}

collision_start(integer num)
{
if (llDetectedType(0) & AGENT && llListFindList( Allowed, [llToLower( llDetectedName(0))]) != -1)
llSetPrimitiveParams( [PRIM_COLOR, ALL_SIDES, <1.0,1.0,1.0>, .0, PRIM_PHANTOM, TRUE] );
}

collision_end(integer num_detected)
{
llSetPrimitiveParams( [PRIM_COLOR, ALL_SIDES, <1.0,1.0,1.0>, 1.0, PRIM_PHANTOM, FALSE] );
}

changed(integer change)
{
if( change & CHANGED_INVENTORY ) llResetScript();
}

on_rez(integer start)
{
llResetScript();
}
}
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
11-01-2009 01:45
Ron was faster... Any way, here is another solution without sensor and without collision.

Hmmm... Assuming that your friend list is of reasonable length so that you can store all the keys in the script memory.

Untested in-world but I'm over-confident... :P

(Quote me and you should retrieve the formating.)

list FriendKeys;

string NotecardName;
key NotecardKey;
integer Line;
key NoteQuery;
key Request;

uuStartReadingNotecard()
{
llSetStatus(STATUS_PHANTOM, FALSE);
FriendKeys = [];
NotecardName = llGetInventoryName(INVENTORY_NOTECARD, 0);
NotecardKey = llGetInventoryKey(NotecardName);
Line = 0;
NoteQuery = llGetNotecardLine(NotecardName, Line);
}

default
{
state_entry()
{
llSetTimerEvent(0.0);
uuStartReadingNotecard();
}

dataserver(key query, string data)
{
if (query == NoteQuery)
{
if (data == EOF)
{
llSetTimerEvent(5.0);
}
else
{
/*
This part depends on if you store names or keys
in your notecard.
If you use keys, just store them in FriendKeys list...
// FriendKeys += (key)data;
Otherwise, you'll have to fetch the keys from the names
using w-hat.com or alpha-fox.com services
// Request =
// llHTTPRequest("http://name2key.alpha-fox.com/?name="
// + data, [], "";);
and store the keys in the http_response() event.
*/
++Line;
NoteQuery = llGetNotecardLine(NotecardName, Line);
}
}
}

timer()
{
list tempo;
vector my_pos = llGetPos();
integer near_by = 0;
integer i = (FriendKeys != []); // llGetListLength()
for (--i; i >= 0; --i)
{
tempo = llGetObjectDetails(llList2Key(FriendKeys, i), [OBJECT_POS]);
vector their_pos = llList2Vector(tempo, 0);
if (llVecDist(my_pos, their_pos) < 2.0) // Within 2 m?
{
++near_by; // Yes
}
}
llSetStatus(STATUS_PHANTOM, (near_by != 0));
}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
key same = llGetInventoryKey(NotecardName);
if (NotecardKey != same)
{
llSetTimerEvent(0.0);
uuStartReadingNotecard();
}
}
}
}
raven Blair
Registered User
Join date: 2 Feb 2004
Posts: 39
11-01-2009 11:54
the first code works great :D have not tested the other code yep but thank you SO much