Delay function question
8 posts • Page 1 of 1
Delay function question
I am making a fully mouse-controlled machine gun, and I need a delay function.
The gun is here: [scene]51274[/scene] it is still a work in progress; it doesn't work because the code that deletes the red circle triggers too quickly.
and here is the code for the bullets:
I need the delay code right after e.this.color:=[1,0,0,0.5] (line 31, I think)
The gun is here: [scene]51274[/scene] it is still a work in progress; it doesn't work because the code that deletes the red circle triggers too quickly.
and here is the code for the bullets:
- Code: Select all
(e)=>{
scene.addCircle({
pos := e.pos;
vel := e.normal * 80;
airfrictionmult := -1;
heterocollide := true;
restitution := 0;
radius := 0.1;
color := [0, 0, 0, 0.5];
collideset := 65;
drawCake := false;
oncollide := (e)=>{
e.this.density := 100;
e.this.collideset := 0;
scene.addCircle({
pos := e.pos;
attraction := -10;
vel := [0, 0];
color := [0, 0, 0, 0.25];
radius := 1;
density := 11;
heterocollide := true;
collideset := 65;
drawCake := false;
drawBorders := false;
oncollide := (e)=>{
e.this.density := 999999999;
e.this.attraction := -999999999;
protractor := true;
e.this.friction := 999999999;
e.this.color := [1, 0, 0, 0.5];
e.this.collideset := 0;
e.this.airfrictionmult := -inf
}
});
e.this.airfrictionmult := -inf
}
})
}
I need the delay code right after e.this.color:=[1,0,0,0.5] (line 31, I think)
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Delay function question
Wait, so, you want the script to pause momentarily after that line?
Kind of like a sleep command in several other languages, including Java, which I know a little of?
Ohh, man, what the ____ are you attempting to code?
And what are you using as an oscillator? A laser, an alternating collider, a spinning geom, what?
Are you making another scripted cannon?
*taking another look at the code*
Ah, so it is a sleep command. Maybe,
Hmm, the fact that you are using airFrictionMult = -inf leads me to believe that you are using Phun. If I am incorrect and you are using Algodoo, you can use:
Hope this helps.
Kind of like a sleep command in several other languages, including Java, which I know a little of?
Ohh, man, what the ____ are you attempting to code?
And what are you using as an oscillator? A laser, an alternating collider, a spinning geom, what?
Are you making another scripted cannon?
*taking another look at the code*
Ah, so it is a sleep command. Maybe,
- Code: Select all
controllerAcc = 0;
{controllerAcc < 5} ? {controllerAcc = controllerAcc + 1} : {collideSet = 0;
airFrictionMult = -inf
}
Hmm, the fact that you are using airFrictionMult = -inf leads me to believe that you are using Phun. If I am incorrect and you are using Algodoo, you can use:
- Code: Select all
controllerAcc = 0;
{controllerAcc < 5} ? {controllerAcc = controllerAcc + 1} : {density = 0}
Hope this helps.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Delay function question
Someone Else wrote:Wait, so, you want the script to pause momentarily after that line?
Kind of like a sleep command in several other languages, including Java, which I know a little of?
Ohh, man, what the ____ are you attempting to code?
And what are you using as an oscillator? A laser, an alternating collider, a spinning geom, what?
Are you making another scripted cannon?
*taking another look at the code*
Ah, so it is a sleep command. Maybe,
- Code: Select all
controllerAcc = 0;
{controllerAcc < 5} ? {controllerAcc = controllerAcc + 1} : {collideSet = 0;
airFrictionMult = -inf
}
Hmm, the fact that you are using airFrictionMult = -inf leads me to believe that you are using Phun. If I am incorrect and you are using Algodoo, you can use:
- Code: Select all
controllerAcc = 0;
{controllerAcc < 5} ? {controllerAcc = controllerAcc + 1} : {density = 0}
Hope this helps.
Actually I'm using algodoo, although the scene will be phun compadible. Setting the density to zero crashes algodoo on my PC.
And yes, I'm making another scripted cannon with even more power than my last one. The cannon (which is actually a machine gun) will shoot a circle, then when the circle collides, it deletes itself after spawning another circle, which 'explodes' when it collides, and then deletes itself. It's my attempt at a scripted cannon that has no lag, and has no need for killer planes to prevent lag. In some languages, such as Processor (is that really what it's called? anyway, It's similar to what the ATmega328 microprocessing chip is coded in) there literally is a line of code
- Code: Select all
delay(1000), or something like that
The oscillator I'm using is just a rotating rectangle; I've found that this works far better than a gear. On a completely different note, this machine gun seems to fir forward in algodoo, and backward in Phun
That code looks like it will work, although I don't have the time to test it (although, I do have the time to write a whole freakin' novel on the algodoo forums, somehow...) Thanks for the quick response!!
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Delay function question
I know about two micro-liters of FORTRAN, a few milliliters of Java, and about half a liter of Thyme. And I like to use imperial units.
Anyway, in Java-Thyme the code you want is something like this:
I should mention that the code I gave you in my previous post will set the controllerAcc = 0, then increment the controllerAcc by 1 on each collision. That is, until the object collides five times, controllerAcc == 5, and the circle kills itself.
Or you could get creative with spawning lasers with 1 maxRays in a partly transparent geom. This can be used for a timer.
Oh, and I just made up Java-Thyme. The code will not work in either language.
Anyway, in Java-Thyme the code you want is something like this:
- Code: Select all
{
try {sleep 1000}
catch == sleepInterruptException ? {density = 0}
finally {density = 0}
}
I should mention that the code I gave you in my previous post will set the controllerAcc = 0, then increment the controllerAcc by 1 on each collision. That is, until the object collides five times, controllerAcc == 5, and the circle kills itself.
Or you could get creative with spawning lasers with 1 maxRays in a partly transparent geom. This can be used for a timer.
Oh, and I just made up Java-Thyme. The code will not work in either language.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Delay function question
Hmmm... Just tried to implement it into the scene, and it didn't work; are you sure that this
- Code: Select all
controllerAcc = 0;
{controllerAcc < 5} ? {controllerAcc = controllerAcc + 1} : {
collideSet = 0;
airFrictionMult = -inf}
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Delay function question
That looks right, but I suggest testing that code on a circle without any other code.
Maybe try
And you MUST touch the circle five or six times for it to disappear.
Maybe try
- Code: Select all
e.this.controllerAcc = 0;
{e.this.controllerAcc < 5} ? {e.this.controllerAcc = e.this.controllerAcc + 1} : {
e.this.collideSet = 0;
e.this.airFrictionMult = -inf}
And you MUST touch the circle five or six times for it to disappear.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Delay function question
Already tried adding e.this.blahblahblahs; but I now know what I need to do: add another couple of those if statements inside each other so it says (in pseudo-code) IF controlleracc <5, then controlleracc++. IF controlleracc STILL less than 5, controlleracc++. IF controlleracc STILL less than 5, controlleracc++. IF controlleracc STILL less than 5............
I'm assuming that you know that variable++ means the same as variable=variable+1.
Reminds me of when I made a javascript quiz... there were one heckuvalotta if statements inside each other in that code...
I'm assuming that you know that variable++ means the same as variable=variable+1.
Reminds me of when I made a javascript quiz... there were one heckuvalotta if statements inside each other in that code...
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Delay function question
TTHHAAAAATTTTTTTTTTTT......
seems WAY too complexdicatted. Having a bunch of nested IF statements seems horribly inefficient.
But, did you try to make my code work by itself?
Or did you try to make your IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF code work of its own?
seems WAY too complexdicatted. Having a bunch of nested IF statements seems horribly inefficient.
But, did you try to make my code work by itself?
Or did you try to make your IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF code work of its own?
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
8 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest




