Change color on walk over?
|
|
Justa Meness
Registered User
Join date: 10 Jul 2007
Posts: 28
|
10-08-2007 07:24
this seems easy thinking of it, But as I have problems with learning code I thought I would ask.
What I need is If if someone walks on a prim change the color from black to white. But leave the texture as it is, So it just changes the Tint color of that object.
Is there such a script or is it possible? I see sensor where you can open and close doors in the way I am thinking about so I think it should be possible.
Thanks For any Help Justa.
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
10-08-2007 07:35
You're looking for the function llSetColor and event start_collision. Whenever the start_collision is triggered you can toggle the colour set with llSetColor. Something like the following: integer toggle = 0; default { start_collision(integer num) { toggle = !toggle; // invert the toggle, i.e. 1 becomes 0 or 0 becomes 1. llSetColor(ALL_SIDES, <toggle,toggle,toggle>  ; } } That would be it's simplest form and you could make it as complex as you like, timing out the colour, adding a reset system to change the whole floor back to it's default colour etc.
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Justa Meness
Registered User
Join date: 10 Jul 2007
Posts: 28
|
10-08-2007 07:42
Thank you Nand As I say I know nothing of coding, I was never any good at things like this in school because I dont think the BBC Micro was capable.. Ok so now you know I am old....lol What it is when someone walks on it I want it to change from black to white and when they are no longer standing on it it goes back to black. I wish I had the brain to cope with learning code, I did sit TUi classes but it just goes right over my head, pitty you cant get memory upgrades in real life to hu?....  Justa.
|
|
Buffy Wilder
Registered User
Join date: 12 Jan 2007
Posts: 16
|
10-08-2007 08:31
Ok i think this is the sort of thing you want (warning may contain typos  Basically what this script does is look for start and end collsions and changes a counter accordingly, when the counter is zero its changes the colour back to its original colour <1,1,1>. When a collision happens it changes the colour to <0,0,0> Now the timer is used because in my experience SL can lose collision_end events (it eats them  So the timer is used to decrement the counter every 20 seconds (in this example) so that the prim will change back to normal eventually in the case of collision_end eating. Once it does this it stop the timer by setting it to 0. Hope this helps Buffy integer count = 0; default { state_entry() { llSetColor(ALL_SIDES,<1,1,1>  ; } timer() { count--; if (count == 0) { llSetColor(ALL_SIDES,<1,1,1>  ; llSetTimerEvent(0); } } collision_start(integer num) { count++; llSetColor(ALL_SIDES,<0,0,0>  ; llSetTimerEvent(20); } collision_end(integer num) { count--; if (count == 0) { llSetColor(ALL_SIDES,<1,1,1>  ; } } }
|
|
Justa Meness
Registered User
Join date: 10 Jul 2007
Posts: 28
|
10-08-2007 08:44
Thanks Buffy...  I just tried it inworld I get a syntax Error on line 35,0 wich is the last } im looking and trying to figure it out..
|
|
Buffy Wilder
Registered User
Join date: 12 Jan 2007
Posts: 16
|
10-08-2007 08:46
Ok missing end }  fixed my post above (told you there might be typos  buffy
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
10-08-2007 08:49
From: Justa Meness Thank you Nand As I say I know nothing of coding, I was never any good at things like this in school because I dont think the BBC Micro was capable.. Ok so now you know I am old....lol What it is when someone walks on it I want it to change from black to white and when they are no longer standing on it it goes back to black. I wish I had the brain to cope with learning code, I did sit TUi classes but it just goes right over my head, pitty you cant get memory upgrades in real life to hu?....  Justa. Well I learnt to program in school on a BBC Micro  then again I was the geek who had their BASIC program all singing and dancing while waiting for the rest of the class to catch up. They were phased out for PCs in my time there, so now you know how old I am Anyhoo, looks like Buffy has your solution for you, I though you wanted something slightly different.
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Justa Meness
Registered User
Join date: 10 Jul 2007
Posts: 28
|
10-08-2007 08:50
yes I appriciate your help Typos are my specialty...lol I now get a error in 6,28 integer count = 0; default { state_entry() { llSetColor(ALL_SIDES,<1,1,1>  ; <------Here I have an error after entering the extra } }
|
|
Buffy Wilder
Registered User
Join date: 12 Jan 2007
Posts: 16
|
10-08-2007 08:57
Ok that'll tech me for not looking up the functions and trusting the code someone else had posted above mine  Basically the arguements for llSetColor are the wrong way round, heres a version that should work (ive also made the colours as seperate vectors so you can change them easily) integer count = 0; vector ON_COLOUR = <0,0,0>; vector OFF_COLOUR = <1,1,1>; default { state_entry() { llSetColor(OFF_COLOUR,ALL_SIDES); } timer() { count--; if (count == 0) { llSetColor(OFF_COLOUR,ALL_SIDES); llSetTimerEvent(0); } } collision_start(integer num) { count++; if (count == 1) { llSetColor(ON_COLOUR,ALL_SIDES); llSetTimerEvent(20); } } collision_end(integer num) { count--; if (count == 0) { llSetColor(OFF_COLOUR,ALL_SIDES); } } }
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
10-08-2007 08:57
From: Justa Meness llSetColor(ALL_SIDES,<1,1,1>  ; <------Here I have an error after entering the extra } My fault, the variables are around the wrong way, replace all as below: llSetColor(<1,1,1>,ALL_SIDES); EDIT: Beaten to it by mere seconds.
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Justa Meness
Registered User
Join date: 10 Jul 2007
Posts: 28
|
10-08-2007 09:07
Yes Very big thank you..  Its working but like a strobe effect I guess if I change the timer Values I can slow that down?
|
|
Buffy Wilder
Registered User
Join date: 12 Jan 2007
Posts: 16
|
10-08-2007 09:14
I will check the behaviour when i log into SL tonight, not currently near a computer that can use SL  I'll post any corrections to stop the "strobe" effect (i assume its strobing as you walk across it correct ?) Buffy
|
|
Justa Meness
Registered User
Join date: 10 Jul 2007
Posts: 28
|
10-08-2007 09:30
Yes it is when I walk or stand on it it gives the strobing effect. and is only a one time happening I think that is due to the timer though But you seem the best to say than me. As when I walk onto it after it doesnt work at all. ok I will check back later And thank you for the help you and nand have given..  Justa
|
|
Buffy Wilder
Registered User
Join date: 12 Jan 2007
Posts: 16
|
10-08-2007 15:30
This will have the desired behaviour that you want (note this will make the prim phantom so do not use on the floor unless you want them falling through it  Buffy integer count = 0; vector ON_COLOUR = <0,0,0>; vector OFF_COLOUR = <1,1,1>; default { state_entry() { llVolumeDetect(TRUE); llSetColor(OFF_COLOUR,ALL_SIDES); } timer() { count = 0; llSetColor(OFF_COLOUR,ALL_SIDES); llSetTimerEvent(0); } collision_start(integer num) { count++; if (count == 1) { llSetColor(ON_COLOUR,ALL_SIDES); llSetTimerEvent(20); } } collision_end(integer num) { count--; if (count == 0) { llSetColor(OFF_COLOUR,ALL_SIDES); llSetTimerEvent(0); } } }
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
10-09-2007 02:38
From: Justa Meness Yes it is when I walk or stand on it it gives the strobing effect. and is only a one time happening I think that is due to the timer though But you seem the best to say than me. As when I walk onto it after it doesnt work at all. ok I will check back later And thank you for the help you and nand have given..  Justa I tried to write some code for this last night but didn't manage anything to solve the problem. Looks like Buffy wins again  Volume detect will certainly be the simplest solution at the cost of turning phantom. The issue with the strobeing is caused by the collision_start and collision_end being called multiple times as an avatar walks over/onto the prim. To overcome this you would need to detect the first collision_start and ignore all the collision_start's and collision_end's occurring within close succession before turning the prim back to black when the avatar finally leaves the prim (which would occur with another flurry of collision_start's and collision_end's). I was trying to use a clock to count the seconds since the last collision_start/end within a timer which would turn the prim black if no activity in x seconds. Not good enough though as the avatar could just be standing still on the prim and the prim would turn black.
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Justa Meness
Registered User
Join date: 10 Jul 2007
Posts: 28
|
10-09-2007 15:21
Thank you very much for all the help..  It was for a sort of Halloween Idea where someone would walk along and the linked part that would turn white would show the scary picture ect. Though Not knowing scripting I thought as long as I had the script in the main Linked part it would also change the linked one, I guess I was wrong as this does not happen. So really these both scripts would have been got for the project as the strobe effect would have been good as a lightinging effect and then walk on the next part and the pic would have been as though it had been switched on. But I have asked enough of you both already. Justa.
|