trying to create a avatar counting script
|
|
Wendy Han
Registered User
Join date: 14 Jul 2006
Posts: 16
|
04-27-2009 16:19
Hi
I have two problems; one is I am trying to create an avatar counter to show me how many pass through the entrance to my small shop.
I have made a mat out of a flat cylinder....and was advised to use this prim with script method rather than a more complacated and I am guesing more expensive method... the name of which escapes me.... (and is probably unecessary for my small shop).
I have put a collision script from lsl.net/lslwiki/wakka.php?wakka=collision_start into the prim script.
someone said I then need to create a list to count and send back to my email.
I have come unstuck here as anything additional I put into the script says it is fine but doesnt register the fact when my avatar is passing over the prim.
I pared back the script to a basic touch and say one that I copied from one of my shop items. and baffelingly this did not register a touch ..although works fine in my other item.
I am quite confused by this...I must be doing somthing really obviously wrong but just cant see it
many thanks for any help
Wendy
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
04-27-2009 16:54
You can get very complicated if you want to, but the very simplest script is just one that counts people as they pass over the threshold and then lets you know the total count when you ask. Something like this.... integer count= 0; default { collision_start(num_detected) { ++count; } touch_start (num_detected) { if (llDetectedKey(0) == llGetOwner()) { llInstantMessage(llGetOwner(), "The total number of people going through your doorway so far is " + (string)count); } }
You can certainly do all sorts of tricky things to count people going IN but not OUT, people who visit once as opposed to those who come back several times, etc...... and you can have the script send you information by e-mail. If all you want to know is how many people went through the doorway, though, this is the plain vanilla way to find out.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
04-28-2009 01:20
Maybe the scripts aren't running. Sometimes when you copy a script from inventory into a object the checkbox 'Running' becomes unchecked.
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
04-28-2009 01:28
integer gIntTrapLimit = 300; list vLstTrapUnique;
default{ state_entry(){ gIntLimit -= 1; llVolumeDetect( TRUE ); }
collision_start( integer vIntCount ){ //-- @Loop/jump same as do/while only faster @Loop;{ if (llDetectedType( vIntCount ) == AGENT){ //-- use name because it's often smaller than key list vLstName = (list)llDetectedName( --vIntCount ); //-- (!~x) same as (-1 != x) only smaller and faster if (!~llListFindList( vLstTrap, vLstName ) ){ //-- limit list to avoid stack/heap collisions vLstTrapUnique = llList2List( vLstName + vLstTrapUnique, 0, gIntTrapLimit ); } } }if (vIntCount) jump Loop; }
touch_start( integer vIntCount ){ //-- (gLstTrapUnique != []) = llGetListLength( gLstTrapUnique ) but smaller & faster. llSay( 0, (string)(gLstTrapUnique != []) + " Unique Visitors since the last check. " + "(count capped at " + (string)gIntTrapLimit + ")" ); gLstTrapUnique = []; } }
make it cover the entrance and invisible it's catch flyers too... and since you have all the names in your list, you can report those too if you like
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
04-28-2009 01:32
the 'expensive' method you referred to is a sensor event.
_____________________
My tutes http://www.youtube.com/johanlaurasia
|
|
Wendy Han
Registered User
Join date: 14 Jul 2006
Posts: 16
|
thank you : )
04-28-2009 10:27
.....Thanks... that is very much appreciated will try both scripts
best, Wendy
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
04-28-2009 10:44
@ Void (or whoever..  ) -- Exactly what is the effect of using !~ in a test like if (!~llListFindList( vLstTrap, vLstName ) ) ? I've taken it to mean "If the result of llListFindList() isn't reasonably close to TRUE, then do stuff." Is that right (or reasonably close to right)? If so, what does "reasonably close" mean?
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
04-28-2009 14:02
From: Rolig Loon @ Void (or whoever..  ) -- Exactly what is the effect of using !~ in a test like if (!~llListFindList( vLstTrap, vLstName ) ) ? I've taken it to mean "If the result of llListFindList() isn't reasonably close to TRUE, then do stuff." Is that right (or reasonably close to right)? If so, what does "reasonably close" mean? list find returns a number from -1 to (listLength - 1)... anthything >= 0 means it was found, and -1 means not found. so if you apply ~ to -1 you get 0 (it flipps all the bits, -1 == 0xFFFFFF, 0 == 0x000000 ) evaluation of 0 = FALSE. but we want it to be true if it's not found and false otherwise, so we reverse it with ! to get NOT_FOUND == TRUE and then run the the if code within. ~ is a bitwise operator (it looks at and changes bits) ! is a logical operator (it sees everything as 0 or not 0 for our purposes) both are unary operators (they only work with the number following them) in our case ~ preforms the bitwise operation of two's complement on integers (but I think it performs ones complement on floats, or perhaps -0 is inherent in floats, I'd have to look) essentially you can replace (!~x) with (-1 != x) and it runs faster and smaller (I added a comment for it above) why is it smaller and faster? it doesnt have an extra variable, it doesn't need to compare 2 variables, it just applies two changes and deals with the result in terms of a logical(boolean) value (which is what if expects) this is also why checking counters that count down from a number to 0 in a loop it's faster just to check the 'truth' of the number than to compare it (like you see in my @loop-jump). but this only works if you can guarantee that the number isn't going to be below 0 to start (or above 0 if you're counting up from negatives). fortunately all events that provide a count in lsl only trigger at 1+ so they will never start at or below zero. other notes: in some languages ! is a bitwise operator that works exactly as ~ does in LSL on integers. in some languages logical TRUE is -1 only, in others +1 only, in still others true is >0 and false<=0 all important things to know before hand.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
04-28-2009 14:11
Aha! Light dawns. I had been misinterpreting it totally, then. I was thinking of ! and ~ as essentially the same operators, so a statement like this looked like a quirky sort of double negative. This makes sense now. Thanks, Void.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
04-28-2009 14:19
np =)
of course the wiki had me screwed up at first because I wasn't getting what ~ was doing, because it says it's a one's complement operation (which is a rather different animal than 2's) I need to edit that, but I need to check the float definition first.
EDIT: I R DUM. duh of course float have inherent -0, because they have a sign bit, sign/exponent/mantissa which I should know since one of my fun projects was to tear them apart in vb to create higher ranges of testable numbers for my prime sieve.
wiki editing on the way as soon as I verify inworld that ~ either doesn't work with floats (it might not) or definitely uses a specific complement style
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Wendy Han
Registered User
Join date: 14 Jul 2006
Posts: 16
|
second problem solved too : )
04-28-2009 15:28
thanks for the scripts..... I also found that for some reason all the scripts wernt working (as I mantioned in my inital question ..... but... I took my shop door mat ( ave counter prim with the scripts), to a sand box and rezzed it there and hey presto! it worked..... and on returning to my shop it now works there. So not sure why but because I made the mat in my shop, the scripts actually had to be rezzed in a sand box it.
thanks you for the help and i now have a happy ave counter...just need some customers lol
|
|
Wendy Han
Registered User
Join date: 14 Jul 2006
Posts: 16
|
just one query about floating text
04-28-2009 16:15
Hi just one query about floating text ....in this instance ..I am the only one able to see the text? not like the floating text or touch text on items for sale for example...
wendy x
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
04-28-2009 16:53
From: Wendy Han Hi just one query about floating text ....in this instance ..I am the only one able to see the text? not like the floating text or touch text on items for sale for example...
wendy x do you mean you ARE seeing floating text? or you WANT TO see floating text? the first shouldn't be happening with either script presented here, and the second would be impossible to make only show for you PS I changed one small thing in my above script, not sure if it compiled without it, I forgot to cast the name to a list when it was stored in the variable.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Wendy Han
Registered User
Join date: 14 Jul 2006
Posts: 16
|
05-02-2009 16:34
ahhhh no it didnt and yes that makes sense ..I will alter it thank you : ) : ) wendy
|
|
Wotan Forsythe
Registered User
Join date: 12 Mar 2009
Posts: 3
|
05-23-2009 14:52
that counting script is ok, but I can teleport to your shop without going through door ...
isnt better a Security CAM, which detects all people in your shop? Not the only one who enters through teh door
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
05-23-2009 19:17
From: Wotan Forsythe that counting script is ok, but I can teleport to your shop without going through door ... isnt better a Security CAM, which detects all people in your shop? Not the only one who enters through teh door You could certainly do it that way, but you would have to devise a way to distinguish between an avatar who is a new arrival and one who has been standing around for a while. You might also want to tell the difference between a brand new visitor and a returning visitor. Those are not difficult scripting challenges, but obviously more complicated than a simple collision counter at the door. Also, a security cam is going to use a sensor as the detector, which automatically adds some lag to the sim. The question, really, is how much accuracy you expect out of the counter. If you can accept missing the avs who TP in, take the simpler option. If it's crucial to count every blessed visitor, go the complicated route. Personally, I've used both approaches in different places and have been satisfied each time. 
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
05-23-2009 20:47
and of course, if you use the collision counter (as i do), if you own the land/parcel or have the powers to change the landing position, you can set a landing point and make it so they land just outside, or even on top of the counter
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-24-2009 06:30
From: Ruthven Willenov and of course, if you use the collision counter (as i do), if you own the land/parcel or have the powers to change the landing position, you can set a landing point and make it so they land just outside, or even on top of the counter don't drop people on counters that are volume detect cubes (to catch flyers) because frequently the cube doesn't rez in quickly enough and you're staring at a box instead of you av... very annoying. doorways are traffic spaces so you don't want you TP spot there either. out of the way, on a short glass slope (so they automatically get out of the way of new arivals) and then you'll still not be counting friend tps (which ignore landing position) or people that are just cammed in.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|