Browse Search Popular Register Upload Rules User list Login:
Search:
.Max-speed scripting *Help*.

Image:
screenshot of the scene

Author: XO3-DAN-FR

Group: Default

Filesize: 45.36 kB

Date added: 2015-04-07

Rating: 5

Downloads: 463

Views: 414

Comments: 18

Ratings: 1

Times favored: 0

Made with: Algodoo v2.1.0

Tags:

Scene tag

Hello,

Here is my problem:

I use to one of my scenes, springs which make piston motion, but their speeds are too high and increased the damping is not an option!
I want to know if I can impose a maximum speed?

For example:
The speed of the piston reaches 6m / s, I would reduce it to 1 m / s, how do I do?

Thank you for helping me :s
Please log in to rate this scene
edit
Similar scenes
Title: SONIC UNLEASHED Project 1: With the speed of light...
Rating: 5
Filesize: 53.6 kB
Downloads: 1232
Comments: 0
Ratings: 1
Date added: 2010/02/04 15:09:28
Made with: Phun
Rating: rated 5
download
Title: Laser Scripting Example
Rating: 4.75
Filesize: 22.16 kB
Downloads: 531
Comments: 1
Ratings: 2
Date added: 2009/09/01 03:56:10
Made with: Algodoo demo
Rating: rated 4.8
download
Title: Need help with something...
Rating: 5
Filesize: 88.4 kB
Downloads: 217
Comments: 7
Ratings: 1
Date added: 2017/08/29 15:51:09
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: THE END OF THE WORLD
Rating: 5.625
Filesize: 5 MB
Downloads: 4754
Comments: 5
Ratings: 2
Date added: 2021/03/01 23:56:47
Made with: Algodoo v2.1.0
Rating: rated 5.6
download
Title: Fork Lift, scripted
Rating: 6.7
Filesize: 207.33 kB
Downloads: 828
Comments: 6
Ratings: 6
Date added: 2009/07/12 18:44:00
Made with: Phun
Rating: rated 6.7
download
Title: 4Cyl with 3 speed transmission
Rating: 5
Filesize: 0.61 MB
Downloads: 793
Comments: 0
Ratings: 1
Date added: 2009/12/08 01:30:54
Made with: Phun
Rating: rated 5
download
Possible solution would be use script that adds lenght to the string by the time. For example when lazet hits a ball string lenght grows 0.01 m per second. That way you would get your timing.
Use

{
scene.my.length=scene.my.length + 0.01
}

Other wise use piston and crankshaft.
Well, I already consider this solution but I do not find her very practical for what I want to do I mean.

For example, I made an automatic machining center, so I created a kind of "hard disk" that rotates slowly and is covered by circles each containing a script, a bit like for example my scene.

In the scripts, I give diffenrentes lengths between the springs to create a path. But their displacement are really fast and I imagined solutions is to "curb" the speed of the piston on which the spring is hooked to limited speed!

If you see what I mean? p


I imagined something like this but its not working :

(e)=>{vel=vel<[1,1]}

I think make a variable of type <velocity can not exceed 1 meter / second on the axes X and Y> .

But for manual control, I use the same script that you:

(e)=>{scene.my.length = scene.my.length + 0.01}
Put this in the piston postStep event, and delete vel=scene.my.vel because it is not needed:

vel(0) < -1.0 ? {
vel = [-1.0, vel(1)]
} : {};
vel(0) > 1.0 ? {
vel = [1.0, vel(1)]
} : {}

This will limit the X axis velocity to -1.0 and 1.0 M/S.
Last edited at 2015/04/08 06:35:46 by Xray
Sounds Great !! Thank you very much !! Xray :tup:

Oh, and while I'm at, if you do not mind?

-> How to change color on contact:

An object possesses a spécfifique color, for example white,
When a second object touched, it turns red, and than the second object does not touch it, the first object back to its original color!

Forgiveness asked so many questions, but I am interested much to the script and I found nothing specific on the internet if you Get to Know a place, or how to teach me to use better the script, I would love!


(sry for my english, i'm french ;) )
Last edited at 2015/04/08 09:28:10 by XO3-DAN-FR
It is easy to use "onCollide" to do many different things when another object collides with the object being hit, but it is not so easy to "undo" an action during the time when there is no collision. That's why some users have made a script that can do just that. It is called "mouseOver Effects" and you can find out how to do it in the Algodoo Forum. There are basically three different scripts that can handle boxes, circles, and polygons. There is a very good tutorial by kilinich that describes how to do that. You would need to make a simple mod to the script so that an object detects another geometry rather than the mouse. You do that by changing "app.mousePos" to the continually updated pos of the colliding geometry. In the colliding geometry you would add the script: scene.my.pos = pos in either the postStep event or the update event.

Hope this helps!
Uses scene.my.length, not scene.my.lenght

In spring (not endpoints) postStep event:

maxVel := 1;
scene.my.length > length ? {
length = length + maxVel / sim.frequency
} : {
length = length - maxVel / sim.frequency
}
Its not working in my scene :s

Try it and see if the problem does not come from me! :unsure:

(In Poststep but..)
I did try it, and I know it works. The most probable cause of it not working for you is a spelling error. Here's more detail:

1. In the console, set scene.my.length := 1;
2. In your circles that get hit by the laser, change scene.my.lenght to scene.my.length.
3. Alt left click the spring to select just the spring and not the endpoints.
4. Right click the spring to get the script menu.
5. Copy the following code into the spring postStep:
maxVel := 1;
scene.my.length > length ? {
length = length + maxVel / sim.frequency
} : {
length = length - maxVel / sim.frequency
}
6. Right click the piston.
7. Click "Show plot".
8. Run the scene.
Last edited at 2015/04/09 22:21:58 by s_noonan
s_noonan - Just curious, how is your script that you suggest any better than the script that I suggested in my earlier comment?
:lol: lol, but thank you, anyway !! _o_
X03-DAN-FR - Did you try the script that I suggested? It worked Okay for me when I was testing it!
Xray,

My understanding was that XO3-DAN-FR wished to control the spring. In many cases, I don't trust direct manipulation of object position or velocity. Braking the piston wastes energy whereas controlling the actuator (spring) should be more efficient. I didn't try your code until you questioned mine, but when I tried your code and plotted the speed, it made a weird trace. I believe your code is regulating the speed, but the trace doesn't show it correctly. So, how is my code better? Its not. Yours is shorter, simpler, phunletable, in one place, doesn't dither when at zero velocity, doesn't cause the piston to overshoot or undershoot, and gets the job done. I just took a different approach.
Last edited at 2015/04/10 21:59:59 by s_noonan
s_noonan - Yes, I did try your code and it works quite well. I totally agree with what you said about controlling the spring force to control the speed of the piston rather than controlling the piston like a brake. In the "real world" I of course do things differently than I sometimes do in Algodoo. Like most people here, I do things out of convenience and also because I have experience doing things a certain way.

X03-DAN-FR obviously has a little trouble with English, and that makes things more difficult to understand than if that issue wasn't an issue. I hope that he will resolve this by carefully reading the suggestions that both of us had given him.
Rayon X,

Merci de prendre le temps de vérifier mon code .
s_noonan - كنت موضع ترحيب!
lol men :tup:
it's work fine !! thanks
Last edited at 2015/04/12 16:23:34 by XO3-DAN-FR