Page 1 of 1
loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Tue Dec 15, 2015 5:17 pm
by mistiqpiotr
Hello.He is trying to make a circle which dies and creates new same circle endlessly. My scrio in circle (e)=>{
Scene.addCircle({
timeToLive := 3;
collideSet := 1;
friction := 0.5;
color := [0.73151445, 0.55123925, 0.21842225, 1.0];
pos := [-0.84514439, 2.6246722];
onDie := (e)=>{};
density := 2.0;
radius := 0.38
})
}
I can made it like x loop coping script like.
(e)=>{
Scene.addCircle({
timeToLive := 3;
collideSet := 1;
friction := 0.5;
color := [0.73151445, 0.55123925, 0.21842225, 1.0];
pos := [-0.84514439, 2.6246722];
onDie := (e)=>{
Scene.addCircle({
timeToLive := 3;
collideSet := 1;
friction := 0.5;
color := [0.73151445, 0.55123925, 0.21842225, 1.0];
pos := [-0.84514439, 2.6246722];
onDie := (e)=>{};
density := 2.0;
radius := 0.38
})
}
density := 2.0;
radius := 0.38
})
}
but i need infinite loop.
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Tue Dec 15, 2015 6:45 pm
by T'wind_
Paste this code in the onDie event.
- Code: Select all
timeToLive = 3;
Scene.cloneEntityTo(e.this, Pos)
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Tue Dec 15, 2015 8:26 pm
by Kilinich
Use tmetolive and ondie
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Tue Dec 15, 2015 8:53 pm
by T'wind_
If the ball has to be spawned on position [-0.84514439, 2.6246722] you can write this code in the onDie event
- Code: Select all
timeToLive = 3;
Scene.cloneEntityTo(e.this, [-0.84514439, 2.6246722])
You also have to remove the code that you have already written in the circle.
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Tue Dec 15, 2015 10:01 pm
by mistiqpiotr
Thx.
![Thumbup :thumbup:](./images/smilies/icon_thumbup.gif)
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Wed Dec 16, 2015 4:11 pm
by mistiqpiotr
what i if i wanna make it on group? like i have 2 circle in group and when one of it colide make another group with 2 circle?
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Wed Dec 16, 2015 6:19 pm
by FRA32
ondie = (e)=>{
timetolive = 3;
scene.cloneEntityTo(e.this , pos1);
scene.cloneEntityTo(e.this , pos2)
}
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Thu Dec 17, 2015 5:23 pm
by mistiqpiotr
no it's no't work.
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Thu Dec 17, 2015 9:03 pm
by FRA32
what doesnt work? does the object not reappear after dying? If you wrote the above code, the circle should create 2 clones when triggering the script. If you want it to clone on death, write it in OnDie, if you want it to clone when colliding, write it in OnCollide
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Dec 19, 2015 2:50 pm
by mistiqpiotr
scripts must be in first circle not on both
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Dec 19, 2015 3:12 pm
by T'wind_
mistiqpiotr wrote:scripts must be in first circle not on both
I don't think that's possible, unless you know the ID of both circles.
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Dec 19, 2015 5:11 pm
by mistiqpiotr
ok if we know how make it?
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Dec 19, 2015 6:12 pm
by T'wind_
This code might work, although it's a kinda odd way to do it.
- Code: Select all
onCollide = (e)=>{
scene.cloneEntityTo(e.this, [-1, 1]);
scene.cloneEntityTo(scene.entityByID(<id1>), [1, 1])
}
update = (e)=>{
(scene.entityByID(<id1>)).onCollide = (e)=>{
scene.cloneEntityTo(e.this, [1, 1]);
scene.cloneEntityTo(scene.entityByID(<id2>), [-1, 1])
}
}
replace <id1> by the entityID of the other circle and <id2> by the entityID of the circle that runs the code
Re: loop script
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Dec 19, 2015 9:31 pm
by mistiqpiotr
ok thx.
![Thumbup :thumbup:](./images/smilies/icon_thumbup.gif)