How to spawn squares with scripting?

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

Re: How to spawn squares with scripting?

Postby pnvv » Tue Jun 09, 2015 1:33 am

Scene.addBox?
Image

(/)(°,,,°)(/)
User avatar
pnvv
 
Posts: 670
Joined: Tue Aug 26, 2014 11:46 pm
Location: Disunited States of America

Re: How to spawn squares with scripting?

Postby JakubKubo » Sat Jun 13, 2015 2:58 pm

EN: Its any command for function SUBTRACT, like when i manualy click it in menu?
So i can use it for working miller/drill.

SK: Je nejaky prikaz pre pouzivanie funkcie ODCITAT ,ako keby som klikol na tuto funkciu manualne v menu?
Chcel by som to pouzit pre funkcnu frezu/vrtak.

Sorry for my poor English but I slovak.
JakubKubo
 
Posts: 18
Joined: Thu Mar 12, 2015 6:27 pm

Re: How to spawn squares with scripting?

Postby JakubKubo » Sat Jun 13, 2015 3:06 pm

Ultragamer564 wrote:Please help me! I want to know how you make squares with scripting or with a onCollide that can turn circles to squares. Does anyone know? :?


Thanks!
~Ultragamer564 8-)


Open algodoo and any text document (example: openpad, onenote, word).
In algodoo select object (example: circle, box, plane, ets.) press CTRL+C click in text document and press CTRL+V
It will copy all information about your object and you can edit it...try to edit only few things (like color, etc.) and try if it works.
When you edit it press CTRL+A for select all and copy it by CTRL+C and paste in algodoo by CTRL+V.
I do it always when i need anything what you can´t make in algodoo (like powered motor by left mouse button).
Sorry for my poor English but I slovak.
JakubKubo
 
Posts: 18
Joined: Thu Mar 12, 2015 6:27 pm

Re: How to spawn squares with scripting?

Postby FRA32 » Mon Jul 27, 2015 2:37 pm

The importand info you need is following:
adding circle: scene.addCircle({})
adding rectangle/box: scene.addBox({})
tracer: scene.addPen({}) and so on, you get the idea

Inside the {} you can write attribute statements. If they are missing, the standart valuse of the scene are used. The most frequently used values are:
friction
restitution
color(HSVA)
collideset
size/radius
vel
pos
and so on. You can basically set any value you can see in the script window for the spawned figure. Remember to write <variable> := <value> instead of a = b as you will alter the spawning figure otherwise. So if you write colorHSVA = [1,1,1,1] it will make both the spawning figure(i.e. something that uses onCollide to spawn the new shape) as the spawned shape white.
FRA32
 
Posts: 227
Joined: Wed Dec 03, 2014 9:51 pm

Re: How to spawn squares with scripting?

Postby JakubKubo » Wed Jul 29, 2015 10:27 pm

I make this a looong time ago, this works perfectly but i want to make a hinges on two object, what is already on scene (for scene car factory where i add hinge on wheel and car) i try use laser to detect ID of both object, but it dont work :/ can you help me?

This make circle onto square and hinge in the middle of both: (its good? :?: )

(e)=>{
Scene.addBox({
size := [0.5, 0.5];
entityID := 280;
pos := [0, 0.25];
geomID := 3072467;
zDepth := +inf
});
Scene.addCircle({
entityID := 303;
pos := [0, 0.25];
radius := 0.1875;
geomID := 3074424;
zDepth := +inf
});
Scene.addHinge({
geom0 := 3074424;
geom0pos := [0, 0];
geom1 := 3072467;
geom1pos := [0, 0];
entityID := 304;
zDepth := +inf;
size := 0.12;
})
}
JakubKubo
 
Posts: 18
Joined: Thu Mar 12, 2015 6:27 pm

Re: How to spawn squares with scripting?

Postby FRA32 » Tue Aug 04, 2015 12:55 am

If you want to specify the geom id for a hinge while spawning 2 shapes add a id counter to the script executor. Make it start at something like 200000 and everytime it summons a car let it make the first piece the id of the ocunter, the second the id of the counter PLUS ONE, and then use these 2 values for the hinge in the geom1 and geom2 attribute. Then increase the counter by 2 and you can repeat the process over and over
FRA32
 
Posts: 227
Joined: Wed Dec 03, 2014 9:51 pm

Re: How to spawn squares with scripting?

Postby JakubKubo » Sun Jan 21, 2018 5:44 pm

You cannot force object to specific ID, if yes, show me in scene
JakubKubo
 
Posts: 18
Joined: Thu Mar 12, 2015 6:27 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 5 guests

cron