killing something but not killing it

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

killing something but not killing it

Postby canadian joe » Wed Feb 10, 2010 10:53 pm

i have phun and i was wondering if there was some way to kill something without killing it. by this i mean that like with a regular killer it destroys the whole object. i don't want this i just want it to destroy the part it touches. almost like csg subtract. is there a script for that? anyone who can find and answer. :clap: :clap: :clap: :cry: :oops: :P :P :?: :?: :!: :idea: :idea: :idea: :idea: :geek: :ugeek: :ugeek: :geek:
Last edited by canadian joe on Thu Feb 11, 2010 11:59 pm, edited 1 time in total.
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: killing something but not killing it

Postby Dadasas » Wed Feb 10, 2010 11:46 pm

No, it is not possible.
User avatar
Dadasas
 
Posts: 46
Joined: Tue Sep 01, 2009 2:03 am

Re: killing something but not killing it

Postby izacque » Wed Feb 10, 2010 11:55 pm

well, no. But you can fake it. Make an object out of lots of small pieces, and then kill the pieces.
[/post]
Paradigm 29 wrote:I've been trying to figure out why people even buy hummers ever since I found out that they don't have machine guns.
User avatar
izacque
 
Posts: 483
Joined: Mon Sep 14, 2009 11:14 am

Re: killing something but not killing it

Postby canadian joe » Fri Feb 12, 2010 12:03 am

OK :ugeek: :ugeek: :ugeek: so that's a good idea. do you know what a script for that would be. by that i mean that on collide whatever the object touches turns into smaller pieces and then kills those. it would be very helpful because im building a scene and i definitely need 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: killing something but not killing it

Postby Rideg » Fri Feb 12, 2010 12:23 am

he meant make an object OF small pieces
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: killing something but not killing it

Postby izacque » Fri Feb 12, 2010 1:18 am

interesting idea, though... couldn't some complex spawning actually turn, for example, one box into four boxes hinged together?
[/post]
Paradigm 29 wrote:I've been trying to figure out why people even buy hummers ever since I found out that they don't have machine guns.
User avatar
izacque
 
Posts: 483
Joined: Mon Sep 14, 2009 11:14 am

Re: killing something but not killing it

Postby Versieon » Fri Feb 12, 2010 1:31 am

Yes, it could, i could probobly do it.
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm

Re: killing something but not killing it

Postby Versieon » Fri Feb 12, 2010 1:59 am

Done.

Rating: rated 7.1
Filesize: 19.51 kB
Comments: 10
Ratings: 6
download
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm

Re: killing something but not killing it

Postby canadian joe » Fri Feb 12, 2010 11:56 pm

ok that works...exept i have phun not algodoo. if anyone could just type up a script that turns one shape into like 8 other shapes fixated together then that would be great. hoever did that scene in the post before this did do a very nice job. :clap: :clap: :clap: i just need the script written down as a post, not an entire scene. but again, good job with that scene :thumbup: :crazy: :clap: :ugeek: :ugeek: :ugeek:
User avatar
canadian joe
 
Posts: 115
Joined: Wed Feb 10, 2010 9:42 pm

Re: killing something but not killing it

Postby Mystery » Sat Feb 13, 2010 2:18 am

Code: Select all
e.other.pos = [0, 0];     e.other.size = [0, 0];     app.step;     app.undo;     scene.my.my1 = scene.my.my1 + 1;     Scene.addBox({         color := [0.09584715, 0.06036842, 0.25704986, 1.0];         entityID := 154;         zDepth := 5.0;         geomID := scene.my.my1 + 855;         pos := e.other.pos + [-0.25, 0.25];         angle := 0.0;         size := e.other.size * [0.5, 0.5]     });     Scene.addBox({         color := [0.09584715, 0.06036842, 0.25704986, 1.0];         entityID := 155;         zDepth := 7.0;         geomID := scene.my.my1 + 856;         pos := e.other.pos + [-0.25, -0.25];         angle := 0.0;         size := e.other.size * [0.5, 0.5]     });     Scene.addBox({         color := [0.09584715, 0.06036842, 0.25704986, 1.0];         entityID := 157;         zDepth := 8.0;         geomID := scene.my.my1 + 858;         pos := e.other.pos + [0.25, -0.25];         angle := 0.0;         size := e.other.size * [0.5, 0.5]     });     Scene.addBox({         color := [0.09584715, 0.06036842, 0.25704986, 1.0];         entityID := 156;         zDepth := 6.0;         geomID := scene.my.my1 + 857;         pos := e.other.pos + [0.25, 0.25];         angle := 0.0;         size := e.other.size * [0.5, 0.5]     });     Scene.addHinge({         geom0 := scene.my.my1 + 855;         geom0pos := e.other.size * [0.25, 0.0];         geom1 := scene.my.my1 + 857;         geom1pos := e.other.size * [-0.25, 0.0];         color := [0.13043503, 0.51888734, 0.052302003, 1.0];         entityID := 158;         zDepth := 9.0;         size := 0.08165382     });     Scene.addHinge({         geom0 := scene.my.my1 + 856;         geom0pos := e.other.size * [0.0, 0.25];         geom1 := scene.my.my1 + 855;         geom1pos := e.other.size * [0.0, -0.25];         color := [0.98707193, 0.8416413, 0.07365841, 1.0];         entityID := 159;         zDepth := 10.0;         size := 0.08165382     });     Scene.addHinge({         geom0 := scene.my.my1 + 858;         geom0pos := e.other.size * [0.0, 0.25];         geom1 := scene.my.my1 + 857;         geom1pos := e.other.size * [0.0, -0.25];         color := [0.78752655, 0.15908076, 0.015631914, 1.0];         entityID := 160;         zDepth := 11.0;         size := 0.08165382     });     Scene.addHinge({         geom0 := scene.my.my1 + 856;         geom0pos := e.other.size * [0.25, 0.0];         geom1 := scene.my.my1 + 858;         geom1pos := e.other.size * [-0.25, 0.0];         color := [0.6095219, 0.8971852, 0.55334485, 1.0];         entityID := 161;         zDepth := 12.0;         size := 0.08165382     });     e.other.density = 0;     e.this.density = 0

Should work in phun.
Btw, Versieon Epic +1
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: killing something but not killing it

Postby canadian joe » Sat Feb 13, 2010 2:40 am

wow, good work :!: :thumbup: :clap: :clap: :clap: . this is a really great script. how many pieces does it turn the box into :?: thank you :D this is awesome. :geek: :ugeek: :ugeek: :geek: do you mind if i use this in one of my scenes :?:. also is there a way to copy and paste this into the phun oncollide script :?: im kinda new to scripting. :oops:
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: killing something but not killing it

Postby Mystery » Sat Feb 13, 2010 8:44 am

Press select all with the code i posted. ctrl + C (Copy)
Then in phun in on-collide (Needs advanced mode ON) paste it between (e)=>{ HERE! } on the object you want to split.
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: killing something but not killing it

Postby canadian joe » Sat Feb 13, 2010 3:38 pm

cool,thanks ill try that :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: killing something but not killing it

Postby canadian joe » Sun Feb 14, 2010 6:18 pm

it didn't work, you can't paste in phun :(
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: killing something but not killing it

Postby KarateBrot » Sun Feb 14, 2010 6:27 pm

canadian joe wrote:it didn't work, you can't paste in phun :(

you can
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: killing something but not killing it

Postby KarateBrot » Sun Feb 14, 2010 7:27 pm

yeah not dragging and dropping. you can copy (CTRL + C) it and paste (CTRL + V) it
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: killing something but not killing it

Postby canadian joe » Sun Feb 14, 2010 7:32 pm

oh i did not know the whole paste shortcut thing. now i feel like a fool :oops:
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: killing something but not killing it

Postby canadian joe » Sun Feb 14, 2010 10:13 pm

IT CRASHED MY PHUN!!!!! IT MAKES THE WHOLE ERROR REPORT THING COME UP. This happens to make me feel sad inside :shock:
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: killing something but not killing it

Postby standardtoaster » Mon Feb 15, 2010 8:22 am

It crashed because it uses zero density. Use airFrictionMult of large negative values to achieve the same effect.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: killing something but not killing it

Postby daniels220 » Wed Feb 17, 2010 4:25 am

Edit: I figured it out, ignore the asking for help (if you saw it).

So I'm not much of a Thymer, but I have some programming knowledge. I think this is really cool but a) it has a couple problems with the physical results (I'll get to that in a moment) and b) it's doing the same thing four times, which immediately made me think "for loop." So I made a version that fixes all that.

Code: Select all
(e)=>{
   e.other.pos = [0, 0];
   e.other.size = [0, 0];
   app.step;
   app.undo;
   scene.my.my1 = scene.my.my1 + 1;
   scene.my.size = e.other.size;
   for(4,(i)=>{
      offset := {
         (i == 0) ? {[0.25,0.25]} : {
            (i == 1) ? {[0.25,-0.25]} : {
               (i == 2) ? {[-0.25,-0.25]} : {[-0.25,0.25]}
            }
         }
      };
      Scene.addBox({
         color := [0.1,0.05,0.25,1.0];
         entityID := 154 + i;
         zDepth := 5.0 + i;
         geomID := scene.my.my1 + 855 + i;
         pos := e.other.pos + e.other.size * offset;
         angle := 0.0;
         size := e.other.size * [0.5, 0.5]
      });
   });
   for(4,(j)=>{
      offset := {
         (j == 0) ? {[0,-0.25]} : {
            (j == 1) ? {[-0.25,0]} : {
               (j == 2) ? {[0,0.25]} : {[0.25,0]}
            }
         }
      };
      Scene.addHinge({
         geom0 := scene.my.my1 + 855 + (j % 4);
         geom0pos := e.other.size * offset;
         geom1 := scene.my.my1 + 855 + ((j + 1) % 4);
         geom1pos := e.other.size * offset * (-1);
         color := [1,1,1,1.0];
         entityID := 158 + j;
         zDepth := 9.0 + j;
         size := (e.other.size(0)^2 + e.other.size(1)^2)^0.5 * 0.1;
      });
   });
   e.other.density = 0
}


The problems I fixed are:

The old version spawned the quadrant boxes at the corners of the original box, so they then "settled" into place with a jerk from the hinges. Worse, when further subdividing an already-subdivided box, the new quadrants still spawn 1m apart—not even the size of the smaller "parent." So I made it so they spawn exactly where they're supposed to end up.

The old version also spawned the hinges at a fixed size, so multiple subdivisions meant the boxes were obscured by the hinges. The hinges now spawn as 1/10 the size of the object.

I also took out "e.this.density = 0" for troubleshooting (that way I don't lose my test objects) but it can obviously be added back.
daniels220
 
Posts: 95
Joined: Mon Aug 31, 2009 11:30 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests

cron