CircleCount

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

CircleCount

Postby Rideg » Sun Apr 11, 2010 10:02 pm

Hello. back again and hungry to learn more...
Straight to the question, is there a way to see how many circles there are in a scene? Or to make spawned boxes not count as a geom? Like glue it to the backround and then delete it? Please help me, I'm on my biggest thyme project (so far).

If someone knows how to count circles with cake like "sim.circlesWithCakeCount" or how to make one yourself that would also be appricieated.

I hope my english is alright.
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: CircleCount

Postby TimTheOne » Mon Apr 12, 2010 7:03 am

To see how many circles there are, you can select all (ctrl+a) go to select -> select circles.
then you can go to velocity, where it will say 'Velocity for ... circles'

idk how you can see it in scripts. maybe you can do it in variables. if you have 10 circles in a scene, just make a variable 10 + 1 for every circle that you spawn and -1 for every circle that gets deleted.

if you want to this with the cricles with cake only, you should do something like this.

Code: Select all
(e)=>{e.other.DrawCake == true ? {scene.my.count = scene.my.count + 1} : {}}


(not sure if this works, haven't tested it :P)

EDIT : tried it and it doesn't work. never knew it didn't work with true and false. Controlleracc is better solution.
Last edited by TimTheOne on Mon Apr 12, 2010 4:24 pm, edited 1 time in total.
TimTheOne
 
Posts: 40
Joined: Tue Jan 12, 2010 9:22 pm

Re: CircleCount

Postby Chronos » Mon Apr 12, 2010 11:12 am

That wouldn't work. If the same circle hits it twice, it'll count as two instead of one. You could fix it by turning off the circle cake after it collides, though.
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: CircleCount

Postby Mystery » Mon Apr 12, 2010 11:38 am

Your code doesn't work.
Code: Select all
{e.other.controlleracc == 11} ? {
        scene.my.count = scene.my.count + 1;
        e.other.controlleracc = e.other.controlleracc = 12
    } : {}

Seems to be a bug with drawcake.
Last edited by Mystery on Mon Apr 12, 2010 11:51 am, edited 1 time in total.
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: CircleCount

Postby Chronos » Mon Apr 12, 2010 11:48 am

Is drawcake a readable variable?
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: CircleCount

Postby Mystery » Mon Apr 12, 2010 11:53 am

It is readable i think there is a funny way to read bool (True / false) variables. Either that or its a bug.
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: CircleCount

Postby Chronos » Mon Apr 12, 2010 1:03 pm

Actually, I just noticed he used = instead of ==.
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: CircleCount

Postby Mystery » Mon Apr 12, 2010 1:54 pm

With Bool i think you use =
== doesn't work anyway.
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: CircleCount

Postby Rideg » Mon Apr 12, 2010 4:10 pm

well I'm doing some Genetic research and want to see how many boys, girls and how big the entire population is...
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: CircleCount

Postby Mystery » Mon Apr 12, 2010 4:17 pm

entire population for what? another evolution sim?

If it is another evolution sim the best way to count is by adding 1 to scene.my.countboys every time a boy is born and taking 1 every time a boy dies.

Same goes with girls scene.my.countgirls.

scene.my.countboys + scene.my.girls = entire population
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: CircleCount

Postby TimTheOne » Mon Apr 12, 2010 4:22 pm

Ah, i see that i made a mistake in my code with the =, it should indeed be ==.
i never tried an if statement with a true or false, but i guessed it would work. clearly it doesn't.
so ignore that part of my post ^-^.

The best way to do it would prolly indeed be to use controlleracc.
TimTheOne
 
Posts: 40
Joined: Tue Jan 12, 2010 9:22 pm

Re: CircleCount

Postby Rideg » Mon Apr 12, 2010 8:45 pm

entire population for what? another evolution sim?

If it is another evolution sim the best way to count is by adding 1 to scene.my.countboys every time a boy is born and taking 1 every time a boy dies.

Same goes with girls scene.my.countgirls.

scene.my.countboys + scene.my.girls = entire population
thank you Mystery. Btw, sounded like the evulotion simulations ain't so popular.
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: CircleCount

Postby Mystery » Tue Apr 13, 2010 3:14 am

Its just that there are already a heap of them.
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: CircleCount

Postby Rideg » Tue Apr 13, 2010 3:59 pm

Yeah but I hope you think mine is special. It works perfectly and have a realistic evolution and I so many ideas to put to this project.
I hope it will be special for you, though it's quite fun to watch them multiplyand evolve :D
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests

cron