spawn a complicated object

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

spawn a complicated object

Postby canadian joe » Sat Feb 20, 2010 3:03 pm

is it possible to spawn a complex object? like a polygon. or a shape normally made with the brush tool? if there is than i have a creepy idea for a scene. seriously is there an oncollide code that can do this.
canadian joe wrote:im just writing this so i can sig it


RicH wrote:Phun's Army.
User avatar
canadian joe
 
Posts: 115
Joined: Wed Feb 10, 2010 9:42 pm

Re: spawn a complicated object

Postby KarateBrot » Sat Feb 20, 2010 3:05 pm

Yes it is. But you can spawn much more complex things than just a polygon. You can for example spawn a whole scene with an onCollide script :D

For polygons you have to define the surface.
Code: Select all
scene.addpolygon({ vecs := [[x1, y1],[x2, y2],[x3, y3],...[xn, yn]];  })


That's the basic script. Of course you can also add the spawning position or color or whatever. [xi, yi] is the i-th surface position.
Last edited by KarateBrot on Sat Feb 20, 2010 3:20 pm, edited 2 times in total.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: spawn a complicated object

Postby canadian joe » Sat Feb 20, 2010 3:09 pm

is there a script code to spawn a hand shaped thing that would normally be made with a brush tool.
canadian joe wrote:im just writing this so i can sig it


RicH wrote:Phun's Army.
User avatar
canadian joe
 
Posts: 115
Joined: Wed Feb 10, 2010 9:42 pm

Re: spawn a complicated object

Postby KarateBrot » Sat Feb 20, 2010 3:12 pm

For example:
Code: Select all
scene.addpolygon({ vecs := [[2,2], [-1,1], [-1,-1], [1,-1]]; pos := [0,0]  })


Will spawn a 4-sided polygon at position [0,0]


Check this scene out. Maybe it helps.
Rating: rated 8.5
Filesize: 14.76 kB
Comments: 12
Ratings: 20
download

Well, I thought about it but it's maybe too advanced...
Last edited by KarateBrot on Sat Feb 20, 2010 3:16 pm, edited 1 time in total.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: spawn a complicated object

Postby canadian joe » Sat Feb 20, 2010 3:15 pm

cool. now i just need to modify this to be all hand shaped for my scene. :P :P :geek: :ugeek: :ugeek: :geek:
canadian joe wrote:im just writing this so i can sig it


RicH wrote:Phun's Army.
User avatar
canadian joe
 
Posts: 115
Joined: Wed Feb 10, 2010 9:42 pm

Re: spawn a complicated object

Postby KarateBrot » Sat Feb 20, 2010 3:19 pm

Yes, that's a lot of work if you do it by hand and if you have very much surface points. You could make it automatic with a function but that's maybe a bit too advanced.
But what you can do is to make a polygon with your drawing tool. Then you just have to select the polygon and press CTRL + C. In a text editor you have to press CTRL + V and you get all coordinates.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: spawn a complicated object

Postby canadian joe » Sat Feb 20, 2010 3:23 pm

that sound much easier. i started doing it be hand and it really is kinda trial and error plus there would be alot o points to made a decent shaped hand.
canadian joe wrote:im just writing this so i can sig it


RicH wrote:Phun's Army.
User avatar
canadian joe
 
Posts: 115
Joined: Wed Feb 10, 2010 9:42 pm

Re: spawn a complicated object

Postby canadian joe » Sat Feb 20, 2010 9:09 pm

wow i think you were right. this is kind of complicated. i can get all of the points onto a text thing like you said. then pasted them where the normal points should be. i even made sure that i pasted in between the begining and the end of th e script. by this i mean that beforehand i finished the script with the )s and} that made sence and then added the points befor thos so it looked like ({ vecs := (points) }) but for some reason it still wont work. i am sad so now i cannot spaw those lower arm things that ragdolls have :cry: :cry: :oops: :oops: :thumbdown: :thumbdown: :thumbdown: :( :( :( :(
canadian joe wrote:im just writing this so i can sig it


RicH wrote:Phun's Army.
User avatar
canadian joe
 
Posts: 115
Joined: Wed Feb 10, 2010 9:42 pm

Re: spawn a complicated object

Postby KarateBrot » Sun Feb 21, 2010 12:10 am

are you sure you didn't forget any brackets or commas or something else?
Be sure to make [ ] brackets around all your points => [ [2,2], [-1,1], [-1,-1], [1,-1] ]
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: spawn a complicated object

Postby fox11trot » Sun Feb 21, 2010 9:00 pm

fox11trot
 
Posts: 62
Joined: Tue Sep 01, 2009 7:25 am

Re: spawn a complicated object

Postby Versieon » Mon Feb 22, 2010 4:13 am

Actualy, there are two sets of brackets [[ [0,1],[0,0],[1,0],[1,1] ]]
That should work.

And I made a scaner / spawner that reads shapes and spits them out, it uses a polygon spwn code.
Here, I'll upload it.
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm

Re: spawn a complicated object

Postby KarateBrot » Mon Feb 22, 2010 7:29 am

the important thing is to have a 2 dimensional array (an array with arrays in it). two sets of brackets make it a 3 dimensional array. you will get an error message.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: spawn a complicated object

Postby Versieon » Tue Feb 23, 2010 4:44 am

Huh, I always have to have two sets, it won't work otherwise,.
Yes, i just checked it.
Look at the scipts for putting the array together, it has 2 at the begining and the end, without it it gives an error message saying not a real list.
Rating: rated 6.2
Filesize: 25.52 kB
Comments: 10
Ratings: 4
download
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm

Re: spawn a complicated object

Postby KarateBrot » Tue Feb 23, 2010 6:16 am

Hmm yeah, indeed. Maybe it has something to do with your use of eval or something different because normally you get an error message if it's not a two-dimensional array. Maybe you have to add an extra pair of brackets because they get removed/ignored somewhere in a function so at the end you get a two-dimensional array and no three-dimensional one. after looking at different error messages with different numbers of brackets i am pretty sure it has something to do with it.
besides: you made a very complicated scripting part. it can be done MUCH easier but nice one for going the complicated way :thumbup:
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: spawn a complicated object

Postby canadian joe » Thu Feb 25, 2010 2:38 am

for some reason my ctrl+C ctrl+v isn't working anymore. it used to work but now nothing is happeneing :(
canadian joe wrote:im just writing this so i can sig it


RicH wrote:Phun's Army.
User avatar
canadian joe
 
Posts: 115
Joined: Wed Feb 10, 2010 9:42 pm

Re: spawn a complicated object

Postby Chronos » Thu Feb 25, 2010 1:59 pm

Some people seem to have that problem. As far as I know, there's no fix.
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: spawn a complicated object

Postby canadian joe » Fri Feb 26, 2010 12:17 am

it works! now i have a script that spawns a polygon. how do you set it's size?
canadian joe wrote:im just writing this so i can sig it


RicH wrote:Phun's Army.
User avatar
canadian joe
 
Posts: 115
Joined: Wed Feb 10, 2010 9:42 pm

Re: spawn a complicated object

Postby Versieon » Fri Feb 26, 2010 12:39 am

the vecs that you put in determin the size of the polygon
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm

Re: spawn a complicated object

Postby KarateBrot » Fri Feb 26, 2010 1:19 am

jup you should do that already in the vecs that's the best way. but if you want to scale the polygon you still can multiplicate the vecs with a factor to make the polygon bigger/smaller.

For example to make it double sized
Code: Select all
scene.addpolygon({ vecs := 2*[[2,2], [-1,1], [-1,-1], [1,-1]]; pos := [0,0]  })
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: spawn a complicated object

Postby canadian joe » Fri Feb 26, 2010 2:18 am

thanks! you are a big help to this!since i am an amateur scripter this is very helpful :D :D :D
canadian joe wrote:im just writing this so i can sig it


RicH wrote:Phun's Army.
User avatar
canadian joe
 
Posts: 115
Joined: Wed Feb 10, 2010 9:42 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests