Page 1 of 1

Another Scripting Problem...

PostPosted: Fri Feb 12, 2010 7:04 pm
by o0shadow0o
i am trying to remake a game called Color Infection and i cannot make the script for the brown balls function correctly!
this is the code i am using;
Code: Select all
(e)=>{
    e.other.color == [1, 1, 0, 1] ? {e.other.color = [0.5, 0.25, 0, 1]} : {e.other.color == [1, 1, 0, 1]}(:)({});     e.other.onCollide = e.this.onCollide }



If anyone has a solution it would help me a lot... :lol:

Re: Another Scripting Problem...

PostPosted: Fri Feb 12, 2010 7:18 pm
by Kilinich
Code: Select all
(e)=>{
    (e.other.color == [1, 1, 0, 1]) ? {e.other.color = [0.5, 0.25, 0, 1]} : {e.other.color == [1, 1, 0, 1];     e.other.onCollide = e.this.onCollide }}


?

Re: Another Scripting Problem...

PostPosted: Fri Feb 12, 2010 7:46 pm
by o0shadow0o
i try that and when the brown balls touch the yellow or green balls not only do the brown balls not change the yellow/green balls color, but they make all parts of the scene it touches have the same oncollide.
i want all green/yellow balls any brown ball touches to turn brown and have the same oncollide.
basically it only works once, after that bothe involved balls have the oncollide;
Code: Select all
(e)=>{
    e.other.color == [1, 1, 0, 1] ? {e.other.color = [0.5, 0.25, 0, 1]} : {e.other.color == [1, 1, 0, 1]}(:)({});     e.other.onCollide = e.this.onCollide }

Re: Another Scripting Problem...

PostPosted: Fri Feb 12, 2010 8:03 pm
by standardtoaster
Code: Select all
(e)=>{
        e.other.color == [1, 1, 0, 1] ? {e.other.color = [0.5, 0.25, 0, 1]} : {e.other.color == [0, 1, 0, 1] ? {e.other.color = [0.5, 0.25, 0, 1]} : {}} ;     e.other.onCollide = e.this.onCollide }

I believe this is what you were trying to achieve. :)

Re: Another Scripting Problem...

PostPosted: Fri Feb 12, 2010 8:08 pm
by o0shadow0o
that works, however, if a brown ball hits the peice of ground on which the yellow/green balls are on, they give the floor the code but not the color, and all balls turn brown.
i only want the code to affect yellow/green balls or it doesnt work...

Re: Another Scripting Problem...

PostPosted: Fri Feb 12, 2010 10:02 pm
by standardtoaster
That's easy enough to do. All you need is another comparison.
Code: Select all
    (e)=>{
            e.other.color == [1, 1, 0, 1] && e.other + "" == "circle" ? {e.other.color = [0.5, 0.25, 0, 1]} : {e.other.color == [0, 1, 0, 1] ? {e.other.color = [0.5, 0.25, 0, 1]} : {}} ;     e.other.onCollide = e.this.onCollide }

Re: Another Scripting Problem...

PostPosted: Sat Feb 13, 2010 9:23 am
by o0shadow0o
no... same problem as before, all balls touching the arena turn brown
seeing as i only need to change balls, would there be a way just to change circles, not polygons or boxes.
that seems easier... :)

Re: Another Scripting Problem...

PostPosted: Sat Feb 13, 2010 5:43 pm
by standardtoaster
Sorry about that again. I forgot to put the added comparison into all of the ifs.
Code: Select all
        (e)=>{
                e.other.color == [1, 1, 0, 1] && e.other + "" == "circle" ? {e.other.color = [0.5, 0.25, 0, 1]} : {e.other.color == [0, 1, 0, 1 && e.other + "" == "circle"] ? {e.other.color = [0.5, 0.25, 0, 1]} : {}} ;     e.other.onCollide = e.this.onCollide }

Re: Another Scripting Problem...

PostPosted: Sat Feb 13, 2010 9:06 pm
by o0shadow0o
nope... still doesnt work.

here it is.

http://www.algodoo.com/algobox/details.php?id=37792

:(

Re: Another Scripting Problem...

PostPosted: Sat Feb 13, 2010 9:58 pm
by standardtoaster
Code: Select all
            (e)=>{
                    e.other.color == [1, 1, 0, 1] && e.other + "" == "circle" ? {e.other.color = [0.5, 0.25, 0, 1]} : {e.other.color == [0, 1, 0, 1 ]&& e.other + "" == "circle" ? {e.other.color = [0.5, 0.25, 0, 1]} : {}} ;     e.other.onCollide = e.this.onCollide }

Re: Another Scripting Problem...

PostPosted: Sun Feb 14, 2010 3:49 pm
by blahblah200
So, let me get this straight:
You want the Yellow/Green balls to turn brown and turn other Yellow/Green balls brown, and so on.
You don't want the arena to have the OnCollide of the brown balls.

Is that right?
If so, here is the code and the scene:
Rating: rated 5
Filesize: 30.56 kB
Comments: 0
Ratings: 1
download

Code: Select all
(e)=>{
    e.other.color == [1, 1, 0, 1] ? {         e.other.color = [0.5, 0.25, 0, 1];         e.other.oncollide = e.this.oncollide     } : {         e.other.color = [0, 1, 0, 1] ? {             e.other.color = [0.5, 0.25, 0, 1];             e.other.oncollide = e.this.oncollide         } : {}     } }

Re: Another Scripting Problem...

PostPosted: Mon Feb 15, 2010 6:58 am
by Cs24
Filesize: 14.54 kB
download


our scripts look the same (blah blah 200) but somehow your, i think is a little broken

script on brown circle
Code: Select all
(e)=>{
    e.other.color == [0, 1, 0, 1] ? {         e.other.color = e.this.color;         e.other.oncollide = e.this.oncollide     } : {};     e.other.color == [1, 1, 0, 1] ? {         e.other.color = e.this.color;         e.other.oncollide = e.this.oncollide     } : {} }