HELP! PLEASE!

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

HELP! PLEASE!

Postby crytek » Fri Dec 10, 2010 7:58 am

How do you script an object like a circle so when it collides with another object, it clones itself?
crytek
 
Posts: 355
Joined: Mon Aug 31, 2009 9:55 pm

Re: HELP! PLEASE!

Postby Kilinich » Fri Dec 10, 2010 10:22 am

np, just write an onCollide event with circle spawning and set onCollide := e.this.onCollide in new circle for replication...
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: HELP! PLEASE!

Postby crytek » Fri Dec 10, 2010 8:24 pm

I don't know how to do object spawning. Please give me the exact script.
crytek
 
Posts: 355
Joined: Mon Aug 31, 2009 9:55 pm

Re: HELP! PLEASE!

Postby Kilinich » Fri Dec 10, 2010 10:21 pm

scene.addcircle({pos := [0,0]; radius := 1; color := [1,1,1,1]})
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: HELP! PLEASE!

Postby crytek » Fri Dec 10, 2010 11:46 pm

Kilinich wrote:scene.addcircle({pos := [0,0]; radius := 1; color := [1,1,1,1]})

Thanks! But it doesn't really clone the object. It just makes another circle. I want a script that can clone any object on collide.
crytek
 
Posts: 355
Joined: Mon Aug 31, 2009 9:55 pm

Re: HELP! PLEASE!

Postby Paradigm 29 » Sat Dec 11, 2010 2:37 am

({controllerAcc == 11}) ? {
e.this.radius := 0;
controllerAcc = 10.9;
app.step;
app.undo
} : {
Scene.addCircle ({
collideSet := collideSet
opaqueBorders := opaqueBorders;
textureMatrix := textureMatrix;
drawCake := drawCake
density := density
pos := pos;
radius := radius;
color := color;
drawBorder := drawBorder;
angle := angle
})
}

I hope you get the idea. There are other things that you can copy to your clone, but I don't need to put them all. Just add the ones in that you need (if you see the pattern). Also, this spawns your clone on top of you original. If you want it somewhere else, just change pos := pos to pos := [x,y]
Image
User avatar
Paradigm 29
 
Posts: 284
Joined: Tue Sep 01, 2009 12:06 am
Location: Houston, Tx

Re: HELP! PLEASE!

Postby crytek » Sat Dec 11, 2010 4:05 am

the script doesn't even work... When I put the script into the onCollide menu, it turns red. And yes I placed it between the parenthesis.
crytek
 
Posts: 355
Joined: Mon Aug 31, 2009 9:55 pm

Re: HELP! PLEASE!

Postby Paradigm 29 » Sat Dec 11, 2010 5:27 am

{controllerAcc == 11} ? {
e.this.radius := 0;
controllerAcc = 10.9;
app.step;
app.undo
} : {
Scene.addCircle({
collideSet := collideSet;
opaqueBorders := opaqueBorders;
textureMatrix := textureMatrix;
drawCake := drawCake;
density := density;
pos := pos;
radius := radius;
color := color;
drawBorder := drawBorder;
angle := angle
})
}
Image
User avatar
Paradigm 29
 
Posts: 284
Joined: Tue Sep 01, 2009 12:06 am
Location: Houston, Tx

Re: HELP! PLEASE!

Postby gradyfitz » Sat Dec 11, 2010 5:32 am

crytek wrote:the script doesn't even work... When I put the script into the onCollide menu, it turns red. And yes I placed it between the parenthesis.

Well, there's a good reason for that (you can probably quite easily see yourself if you look).

If not, it was the semicolons, missing e.this.* and e.* (depending on whether you want the circles to be in the same place or not, it may be e.this.pos or e.pos (respectively) instead of e.pos), nonetheless, you should very easily be able to understand what's going on there (why App.step; App.undo happens you may not be clear on, but the rest you should) and the missing redeclaration of the e.this.angle identifier.
Code: Select all
(e)=>{
    ({controllerAcc == 11}) ? {
        e.this.radius := 0;
        e.this.angle := 0;
        controllerAcc = 10.9;
        app.step;
        app.undo
    } : {
        Scene.addCircle({
            collideSet := e.this.collideSet;
            opaqueBorders := e.this.opaqueBorders;
            textureMatrix := e.this.textureMatrix;
            drawCake := e.this.drawCake;
            density := e.this.density;
            pos := e.pos;
            radius := e.this.radius;
            color := e.this.color;
            drawBorder := e.this.drawBorder;
            angle := e.this.angle
        })
    }
}


If you don't understand how it works, you can go to [Thyme] New Method to see.

While I was writing this, Paradigm posted, his code still has a few errors, so this one should be better, also, I'd heard someone say New Method didn't work anymore, but it seems that it does, that's good news :).
Mechanisms: 18 Mechanisms.
Thyme: Tutorial - Variables/Commands List.
Thymechanic
gradyfitz
 
Posts: 174
Joined: Tue Sep 01, 2009 8:33 am
Location: Victoria, Australia

Re: HELP! PLEASE!

Postby crytek » Sat Dec 11, 2010 7:27 pm

Thanks! This one works!!
crytek
 
Posts: 355
Joined: Mon Aug 31, 2009 9:55 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 8 guests