Page 1 of 1

Need help with a simple script

PostPosted: Sat Dec 12, 2009 10:13 pm
by PlanckBanck
It`s about the following
Code: Select all
(e)=>{
    scene.mylaser1 == true ? {         scene.addcircle({             radius := 0.01;             zdepth = 50;             pos := e.pos;             color = [1.0, 1.0, 1.0, 1.0]         });         scene.addfixjoint({             pos := e.pos;             zdepth := 25         });         scene.mylaser1 = false     } : {} }


Sorry that I couldn`t be more accurate with the title :oops:
it is supposed to spawn a circle and fixate it to the hit object if scene.mylaser1 is true and the put that variable to false, so it has to be turned on again. Problem is, it doesn`t work, it doesn`t even spawn a circle. (lol)
maybe someone knows why?
Oh yeah, and I tried restarting algodoo, still doesn`t work.

Re: Need help with a simple script

PostPosted: Sat Dec 12, 2009 10:55 pm
by Dadasas
Oh I see it, try making the start scene.my.laser1.

Re: Need help with a simple script

PostPosted: Sat Dec 12, 2009 11:11 pm
by PlanckBanck
thanks, but that ain`t it

Re: Need help with a simple script

PostPosted: Sun Dec 13, 2009 1:29 am
by standardtoaster
You can't directly compare booleans. It's an understood true/false by Algodoo.
Code: Select all
    (e)=>{
        scene.mylaser1 ? {         scene.addcircle({             radius := 0.01;             zdepth = 50;             pos := e.pos;             color = [1.0, 1.0, 1.0, 1.0]         });         scene.addfixjoint({             pos := e.pos;             zdepth := 25         });         scene.mylaser1 = false     } : {} }

Re: Need help with a simple script

PostPosted: Sun Dec 13, 2009 2:07 am
by PlanckBanck
yeah, it works, learnt something again! thanks a lot ^^

Btw, a fixjoint spawned above two objects doesn`t fix them? how silly`s that?!?
Man, is there really no way of at least schanging the body (bodyID whatever) of an existing object?
Or the geomID so I can use that other method of yours?

Re: Need help with a simple script

PostPosted: Sun Dec 13, 2009 2:40 pm
by RicH
Well, the fixate needs to know which objects it's connected to.

Re: Need help with a simple script

PostPosted: Mon Dec 14, 2009 12:30 am
by PlanckBanck
aand, err, how can i tell it ? ^^

Re: Need help with a simple script

PostPosted: Mon Dec 14, 2009 1:05 am
by standardtoaster
viewtopic.php?f=14&t=795

Review that topic. You can either spawn objects so that you will know the geomID or you can use the "New Method."

Re: Need help with a simple script

PostPosted: Mon Dec 14, 2009 8:13 pm
by PlanckBanck
can`t i just tell the spawned stuff to have the same body as the object hit by the laser?

Re: Need help with a simple script

PostPosted: Mon Dec 14, 2009 9:24 pm
by standardtoaster
I guess. I would suggest using the "New Method" for this.