Need help with phunlet

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

Need help with phunlet

Postby golodupcew » Sat Mar 17, 2012 12:07 am

I need to spawn phunlet on collide.
But if I put this
Code: Select all
Scene.addCircle {
    collideWater := true;
    color := [0.25000000, 0.50000000, 0.00000000, 1.0000000];
    onCollide := (e)=>{
        e.other.refractiveIndex > 11 ? {
            refractiveIndex = refractiveIndex + 1;
            refractiveIndex == 2 ? {
                (for)(40, (i)=>{
                    density = 0;
                    Scene.addCircle({
                        collideWater := true;
                        colorHSVA := {[30.000000, 1.0000000, 0.83333331 / (0.75000000 * (sim.time - mark)), 1 / (0.75000000 * (sim.time - mark))]};
                        onCollide := (e)=>{};
                        attraction := 0.00000000;
                        controllerAcc := 11.000000;
                        onHitByLaser := (e)=>{};
                        heteroCollide := false;
                        immortal := false;
                        opaqueBorders := true;
                        refractiveIndex := {14 - (sim.time - mark)};
                        killer := false;
                        friction := 0.50000000;
                        materialName := "";
                        restitution := 1.5000000;
                        drawBorder := false;
                        controllerInvertX := false;
                        controllerInvertY := false;
                        edgeBlur := 10.000000;
                        drawCake := false;
                        controllerReverseXY := false;
                        resistivity := +inf;
                        airFrictionMult := 1.0000000;
                        showVelocity := false;
                        density := {(sim.time < mark + 2 ? {(sim.time > mark + 1 ? 0.00019999999 : 200)} : 0)};
                        textureClamped := [false, false];
                        reflectiveness := 1.0000000;
                        showMomentum := false;
                        textureMatrix := [1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000];
                        texture := "";
                        inertiaMultiplier := 1.0000000;
                        showForceArrows := false;
                        collideSet := 1;
                        materialVelocity := 0.00000000;
                        attractionType := 2;
                        protractor := false;
                        entityID := 4785;
                        zDepth := 1.0000000;
                        layer := 0;
                        geomID := 239189;
                        pos := e.pos;
                        angle := 2.4805493;
                        vel := e.normal * (-50);
                        angvel := 0.00000000;
                        radius := 0.33546013;
                        mark = sim.time
                    });
                    Scene.addPen({
                        geom := 239189;
                        relPoint := [1.2545452e-006, -1.7726085e-006];
                        colorHSVA := {[30.000000, 1.0000000, 0.83333331 / (0.75000000 * (sim.time - mark)), 1 / (0.75000000 * (sim.time - mark))]};
                        fadeTime := 0.46999997;
                        opaqueBorders := false;
                        followGeometry := true;
                        size := 1.0239509;
                        entityID := 4774;
                        zDepth := 1.0000000;
                        layer := 0;
                        rotation := 0.00000000;
                        mark = sim.time
                    })
                })
            } : {nan}
        } : {nan}
    };
    attraction := 0.00000000;
    controllerAcc := 11.000000;
    onHitByLaser := (e)=>{
        e.laser.size == 1.1809543 ? {
            (for)(2, (i)=>{
                density = 0;
                Scene.addCircle({
                    collideWater := true;
                    colorHSVA := {[30.000000, 1.0000000, 0.83333331 / (0.75000000 * (sim.time - mark)), 1 / (0.75000000 * (sim.time - mark))]};
                    onCollide := (e)=>{};
                    attraction := 0.00000000;
                    controllerAcc := 11.000000;
                    onHitByLaser := (e)=>{};
                    heteroCollide := false;
                    immortal := false;
                    opaqueBorders := true;
                    refractiveIndex := {14 - (sim.time - mark)};
                    killer := false;
                    friction := 0.50000000;
                    materialName := "";
                    restitution := 0.50000000;
                    drawBorder := false;
                    controllerInvertX := false;
                    controllerInvertY := false;
                    edgeBlur := 10.000000;
                    drawCake := false;
                    controllerReverseXY := false;
                    resistivity := +inf;
                    airFrictionMult := 1.0000000;
                    showVelocity := false;
                    density := {(sim.time < mark + 2 ? {(sim.time > mark + 1 ? 0.00019999999 : 200)} : 0)};
                    textureClamped := [false, false];
                    reflectiveness := 1.0000000;
                    showMomentum := false;
                    textureMatrix := [1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000];
                    texture := "";
                    inertiaMultiplier := 1.0000000;
                    showForceArrows := false;
                    collideSet := 1;
                    materialVelocity := 0.00000000;
                    attractionType := 2;
                    protractor := false;
                    entityID := 4785;
                    zDepth := 1.0000000;
                    layer := 0;
                    geomID := 239189;
                    pos := e.pos;
                    angle := 2.4805493;
                    vel := e.normal * (-50);
                    angvel := 0.00000000;
                    radius := 0.33546013;
                    mark = sim.time
                });
                Scene.addPen({
                    geom := 239189;
                    relPoint := [1.2545452e-006, -1.7726085e-006];
                    colorHSVA := {[30.000000, 1.0000000, 0.83333331 / (0.75000000 * (sim.time - mark)), 1 / (0.75000000 * (sim.time - mark))]};
                    fadeTime := 0.46999997;
                    opaqueBorders := false;
                    followGeometry := true;
                    size := 1.0239509;
                    entityID := 4774;
                    zDepth := 1.0000000;
                    layer := 0;
                    rotation := 0.00000000;
                    mark = sim.time
                })
            })
        } : {nan}
    };
    heteroCollide := false;
    immortal := false;
    opaqueBorders := true;
    refractiveIndex := 1;
    killer := false;
    friction := 0.50000000;
    materialName := "";
    restitution := 0.00000000;
    drawBorder := true;
    controllerInvertX := false;
    controllerInvertY := false;
    edgeBlur := 0.00000000;
    drawCake := false;
    controllerReverseXY := false;
    resistivity := +inf;
    airFrictionMult := 1.0000000;
    showVelocity := false;
    density := 10.000000;
    textureClamped := [false, false];
    reflectiveness := 1.0000000;
    showMomentum := false;
    textureMatrix := [1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000];
    texture := "";
    inertiaMultiplier := 1.0000000;
    showForceArrows := false;
    collideSet := 1;
    materialVelocity := 0.00000000;
    attractionType := 2;
    protractor := false;
    entityID := 1168;
    zDepth := 2.0000000;
    layer := 0;
    geomID := 647;
    pos := [e.pos(0),e.pos(1)+0.1];
   
    radius := 0.083964400
};
Scene.addBox {
    collideWater := true;
    color := [0.24777617, 0.34677637, 0.22498888, 1.0000000];
    onCollide := (e)=>{};
    attraction := 0.00000000;
    controllerAcc := 11.000000;
    onHitByLaser := (e)=>{};
    heteroCollide := false;
    immortal := false;
    opaqueBorders := true;
    refractiveIndex := 15.000000;
    killer := false;
    text := "";
    friction := 0.50000000;
    materialName := "";
    restitution := 0.50000000;
    drawBorder := true;
    controllerInvertX := false;
    controllerInvertY := false;
    textFont := "Verdana";
    edgeBlur := 0.00000000;
    textFontSize := 32.000000;
    controllerReverseXY := false;
    resistivity := +inf;
    ruler := false;
    airFrictionMult := 1.0000000;
    showVelocity := false;
    density := 2.0000000;
    textConstrained := true;
    textureClamped := [false, false];
    reflectiveness := 1.0000000;
    textColor := [1.0000000, 1.0000000, 1.0000000, 1.0000000];
    showMomentum := false;
    textureMatrix := [1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000];
    texture := "";
    inertiaMultiplier := 1.0000000;
    showForceArrows := false;
    collideSet := 1;
    materialVelocity := 0.00000000;
    attractionType := 2;
    textScale := 0.50000000;
    entityID := 1167;
    zDepth := 4.0000000;
    layer := 0;
    geomID := 646;
    pos=[e.pos(0),e.pos(1)-0.1];
   
    body := 1216;
   
   
    size := [1.1450005, 0.12257953]
};
Scene.addBox {
    collideWater := true;
    color := [0.72570622, 0.99962473, 0.60699743, 1.0000000];
    onCollide := (e)=>{};
    attraction := 0.00000000;
    controllerAcc := 11.000000;
    onHitByLaser := (e)=>{};
    heteroCollide := false;
    immortal := false;
    opaqueBorders := true;
    refractiveIndex := 1.5000000;
    killer := false;
    text := "";
    friction := 0.50000000;
    materialName := "";
    restitution := 0.50000000;
    drawBorder := true;
    controllerInvertX := false;
    controllerInvertY := false;
    textFont := "Verdana";
    edgeBlur := 0.00000000;
    textFontSize := 32.000000;
    controllerReverseXY := false;
    resistivity := +inf;
    ruler := false;
    airFrictionMult := 1.0000000;
    showVelocity := false;
    density := 2.0000000;
    textConstrained := true;
    textureClamped := [false, false];
    reflectiveness := 1.0000000;
    textColor := [1.0000000, 1.0000000, 1.0000000, 1.0000000];
    showMomentum := false;
    textureMatrix := [1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000, 0.00000000, 0.00000000, 0.00000000, 1.0000000];
    texture := "";
    inertiaMultiplier := 1.0000000;
    showForceArrows := false;
    collideSet := 0;
    materialVelocity := 0.00000000;
    attractionType := 2;
    textScale := 0.50000000;
    entityID := 1166;
    zDepth := 1.0000000;
    layer := 0;
    geomID := 645;
    pos=[e.pos(0),e.pos(1)+0.1];
   
    size := [0.52000046, 0.35119438]
};
Scene.addHinge {
    geom0 := 647;
    geom0pos := [-1.1924223e-007, 7.6098701e-007];
    geom1 := 645;
    geom1pos := [0.0055580139, 0.087883294];
    legacyMode := 1;
    opaqueBorders := true;
    autoBend := false;
    motorSpeed := 1.5707964;
    hingeConstant := NaN;
    allowDirectSolve := true;
    impulseLimit := 3.2000000;
    motorTorque := 100.00000;
    bendTarget := NaN;
    bend := false;
    ccw := false;
    bendConstant := NaN;
    motor := false;
    color := [0.39074749, 0.76155001, 0.61552578, 1.0000000];
    forceDirectSolve := false;
    distanceLimit := +inf;
    autoBrake := false;
    entityID := 1169;
    zDepth := 3.0000000;
    layer := 0;
    size := 0.096537769;
    totImp3 := [2.2677133e-007, 0.021683218, 0.00000000]
};
Scene.addFixjoint {
    geom0 := 645;
    geom0pos := [0.0020370483, -0.13094908];
    geom1 := 646;
    geom1pos := [-0.0071411133, -0.0019581914];
    color := [0.47835383, 0.29512557, 0.77659208, 1.0000000];
    opaqueBorders := true;
    entityID := 1170;
    zDepth := 5.0000000;
    layer := 0;
    size := 0.076612204
}
in to on collide phunlets are sticking together.
I think about auto changeable geomid but i don't know how.
Please help :shock:
User avatar
golodupcew
 
Posts: 10
Joined: Sun Feb 12, 2012 4:19 pm
Location: Poland

Re: Need help with phunlet

Postby monstertje3 » Sat Mar 17, 2012 12:34 pm

i understand you want a changing geomid, maybe use a scene.my variable
in script:
geomID:= 99999+scene.my.var

at the end:
scene.my.var=scene.my.var+100
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
User avatar
monstertje3
 
Posts: 343
Joined: Sat Sep 05, 2009 4:29 pm
Location: N-H, NL


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 5 guests