Need help with a simple script

About advanced scenes, and the Thyme scripting language used in Algodoo.

Need help with a simple script

Postby PlanckBanck » Sat Dec 12, 2009 10:13 pm

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.
The world is a gas-station, where you`re allowed to smoke. -Friedrich Dürrenmatt

I forgot 2/3 of my scripting knowledge T.T
User avatar
PlanckBanck
 
Posts: 48
Joined: Sun Nov 22, 2009 5:35 pm
Location: In the Bottoms of Berlin

Re: Need help with a simple script

Postby Dadasas » Sat Dec 12, 2009 10:55 pm

Oh I see it, try making the start scene.my.laser1.
User avatar
Dadasas
 
Posts: 46
Joined: Tue Sep 01, 2009 2:03 am

Re: Need help with a simple script

Postby PlanckBanck » Sat Dec 12, 2009 11:11 pm

thanks, but that ain`t it
The world is a gas-station, where you`re allowed to smoke. -Friedrich Dürrenmatt

I forgot 2/3 of my scripting knowledge T.T
User avatar
PlanckBanck
 
Posts: 48
Joined: Sun Nov 22, 2009 5:35 pm
Location: In the Bottoms of Berlin

Re: Need help with a simple script

Postby standardtoaster » Sun Dec 13, 2009 1:29 am

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     } : {} }
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Need help with a simple script

Postby PlanckBanck » Sun Dec 13, 2009 2:07 am

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?
The world is a gas-station, where you`re allowed to smoke. -Friedrich Dürrenmatt

I forgot 2/3 of my scripting knowledge T.T
User avatar
PlanckBanck
 
Posts: 48
Joined: Sun Nov 22, 2009 5:35 pm
Location: In the Bottoms of Berlin

Re: Need help with a simple script

Postby RicH » Sun Dec 13, 2009 2:40 pm

Well, the fixate needs to know which objects it's connected to.
Millions of voices suddenly cried out in terror, and were suddenly silenced. Something terrible has happened.
User avatar
RicH
[Funniest Person 2010]
 
Posts: 2043
Joined: Tue Sep 01, 2009 9:01 am

Re: Need help with a simple script

Postby PlanckBanck » Mon Dec 14, 2009 12:30 am

aand, err, how can i tell it ? ^^
The world is a gas-station, where you`re allowed to smoke. -Friedrich Dürrenmatt

I forgot 2/3 of my scripting knowledge T.T
User avatar
PlanckBanck
 
Posts: 48
Joined: Sun Nov 22, 2009 5:35 pm
Location: In the Bottoms of Berlin

Re: Need help with a simple script

Postby standardtoaster » Mon Dec 14, 2009 1:05 am

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."
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Need help with a simple script

Postby PlanckBanck » Mon Dec 14, 2009 8:13 pm

can`t i just tell the spawned stuff to have the same body as the object hit by the laser?
The world is a gas-station, where you`re allowed to smoke. -Friedrich Dürrenmatt

I forgot 2/3 of my scripting knowledge T.T
User avatar
PlanckBanck
 
Posts: 48
Joined: Sun Nov 22, 2009 5:35 pm
Location: In the Bottoms of Berlin

Re: Need help with a simple script

Postby standardtoaster » Mon Dec 14, 2009 9:24 pm

I guess. I would suggest using the "New Method" for this.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests