|
Kalidor Lazarno
Just here to have fun!!
Join date: 1 Feb 2006
Posts: 7
|
03-23-2006 14:54
I have looked around and have not found one that does what I would like, am asking here to see if anyone knows of one or would be willing to write one ..
Greeter and Welcome Note Giver
Requirements;
1.) Object must be phantom and only gives when avatar passes through it. 2.) Capable of giving more than one notecard 3.) Will only give out once to the same avie in the same day 3.) Auto Resets when the notecards are changed
Any ideas or suggestions would be welcome.
I have found many that do some of these but not all, and I have buthered them all to the point I gave up .. Thanks in Advance.
|
|
Static Sprocket
Registered User
Join date: 10 Feb 2006
Posts: 157
|
03-23-2006 15:50
I just whipped something up in game at secondlife://Baramdoli/8/106/66/ Look for the semi-transparent cube on the little platform. It's set to buy for L$1, and is full Mod/Copy/Transfer. Here's the code: list lAgentsGreeted = []; string sToday;
integer INVENTORY_TYPES = INVENTORY_NOTECARD;
string sGiveFolder = ""; //Specify a name for the folder to give items in or leave empty to give items seperately.
list lItemsToGive = [];
GreetAgent( key kAgent ) { integer iNumObjects = llGetListLength(lItemsToGive);
if( iNumObjects > 0 ) { if( sGiveFolder != "" ) { llGiveInventoryList( kAgent, sGiveFolder, lItemsToGive); } else { string sObjectName; integer i; for( i = 0; i<iNumObjects; i++ ) { sObjectName = llList2String(lItemsToGive, i); llGiveInventory( kAgent, sObjectName); } } } }
ResetAgentList() { lAgentsGreeted = []; sToday = llGetDate(); }
init() { llOwnerSay("Initializing list of items to be given."); integer iNumObjects = llGetInventoryNumber( INVENTORY_TYPES ); string sObjectName;
integer i; for( i = 0; i<iNumObjects; i++ ) { sObjectName = llGetInventoryName( INVENTORY_TYPES, i ); if(llGetInventoryPermMask(sObjectName, MASK_NEXT) & PERM_COPY) { lItemsToGive += sObjectName; } }
if( (llGetListLength(lItemsToGive) >= 1) && (sGiveFolder != "") ) { llOwnerSay("Initialization done, the following items will be given in a folder named [" + sGiveFolder + "]:"); llOwnerSay( llList2CSV( lItemsToGive ) ); } else if( (llGetListLength(lItemsToGive) >= 1) && (sGiveFolder == "") ) { llOwnerSay("Initialization done, the following items will be given:"); llOwnerSay( llList2CSV( lItemsToGive ) ); } else { llOwnerSay("Initialization done, there are no items to give:"); } llOwnerSay("Resetting list of agents to give items to."); ResetAgentList(); }
default { state_entry() { llVolumeDetect(TRUE); init(); }
on_rez(integer num) { init(); }
collision_start(integer num_detected) { integer i; for(i = 0; i < num_detected; i++) { if( llDetectedType(i) & AGENT ) { if( sToday != llGetDate() ) { ResetAgentList(); } key kAgentKey = llDetectedKey(i); if( llListFindList( lAgentsGreeted, [kAgentKey] ) == -1) { GreetAgent( kAgentKey ); lAgentsGreeted += [kAgentKey]; } } } }
changed( integer change ) { if( change & CHANGED_INVENTORY ) { init(); } } }
Comments, suggestions, constructive critiqing always welcome. [edit]Changed to PHP code tags for the forum to make it easier to read[/edit]
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-23-2006 16:18
Nice. A couple of small suggestions: * Use PHP tags instead of CODE tags - makes it easier to read  * I'm not very familiar with the syntax for checking inventory permissions. But it looks like you're checking to see if the next owner has copy permissions on the notecards. Shouldn't you be checking the current owner's permissions? Maybe I'm reading that code wrong. * You could add a warning message if you skip a notecard because of permissions issues.
if( sToday != llGetDate() ) { ResetAgentList(); }
This check is inside a for loop, and it probably doesn't really need to be. You could put this at the beginning of the collision_start event. Or better still, if this will be used in a high traffic area, put it on a 6 hour timer or something, that way it won't get triggered every time someone walks through this object.
|
|
Kalidor Lazarno
Just here to have fun!!
Join date: 1 Feb 2006
Posts: 7
|
03-23-2006 16:38
Thanks guys will give that a test run, and let you know, but it looks like what I was looking for
|
|
Static Sprocket
Registered User
Join date: 10 Feb 2006
Posts: 157
|
03-23-2006 22:02
From: Ziggy Puff * I'm not very familiar with the syntax for checking inventory permissions. But it looks like you're checking to see if the next owner has copy permissions on the notecards. Shouldn't you be checking the current owner's permissions? Maybe I'm reading that code wrong.
To be honest, I just pulled that part from the WIKI and appeared to work for me okay. From: Ziggy Puff
if( sToday != llGetDate() ) { ResetAgentList(); }
This check is inside a for loop, and it probably doesn't really need to be. You could put this at the beginning of the collision_start event. Or better still, if this will be used in a high traffic area, put it on a 6 hour timer or something, that way it won't get triggered every time someone walks through this object. I was specifically trying to avoid timers all together. I'd rather run a few dozen (or hundred) extra function calls to fetch the current date throughout the day (in little spikes as avatars collide), then add yet another timer (and it's associated lag) to a potentially already loaded sim. As for being outside the for loop, the vast majority of the time the for loop will not, uh, loop. It'll only ever "loop" if there is more then one avatar colliding with the prim at the same time. But if it were deployed as a 10 x 10 x 10 cube, in a small space, where your holding one of those "How many people can we fit into a phone booth" contests -- then ya, it'd be a good idea to move it out of the for loop  Probably be a good idea to just do that on the prinicple that it could happen anyway. I'll go ahead and edit that post to use php code tags, and to move that date check. [edit]Actually, I just remembered why I put the date check where it is. If it's outside the for loop, or actually outside the AGENT mask check (which is in the for loop) -- then the date check will happen everytime objects pass through the prim too, not just when avatars pass through... I'm having a tough time guessing which would be better. In either case, this script should have extremely low impact[/edit]
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-23-2006 22:13
From: someone As for being outside the for loop, the vast majority of the time the for loop will not, uh, loop.
Good point  From: someone I'd rather run a few dozen (or hundred) extra function calls to fetch the current date throughout the day (in little spikes as avatars collide), then add yet another timer (and it's associated lag) to a potentially already loaded sim.
OK. I would expect a 6 hour timer to be significantly less laggy than calling a function potentially every few minutes, but I could be wrong *shrug* Edit: Just saw your edit. That's a good point too. I'd still go with the timer  But now we're into semantics, not solutions.
|