Browse Search Popular Register Upload Rules User list Login:
Search:
I have a Problem!

Image:
screenshot of the scene

Author: Nitrocide

Group: Default

Filesize: 21.03 kB

Date added: 2016-12-12

Rating: 5

Downloads: 390

Views: 200

Comments: 6

Ratings: 1

Times favored: 0

Made with: Algodoo v2.1.0

Tags:

Scene tag

Everytime when i write a script on the laserbox, it discontinues it
and makes me frustrated. Can someone fix this? Thanks
Please log in to rate this scene
edit
Similar scenes
Title: Elestrian Inkwell Alphabet (Thai-Herbrew)
Rating: 5
Filesize: 207.02 kB
Downloads: 1342
Comments: 2
Ratings: 1
Date added: 2017/08/27 10:11:38
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Breakable RX-8 V 3.1
Rating: 5
Filesize: 0.62 MB
Downloads: 1358
Comments: 0
Ratings: 1
Date added: 2009/03/22 18:07:39
Made with: Phun
Rating: rated 5
download
Title: Car Problems
Rating: 5.125
Filesize: 11.52 kB
Downloads: 535
Comments: 7
Ratings: 2
Date added: 2013/06/07 22:21:48
Made with: Algodoo v2.1.0
Rating: rated 5.1
download
Title: Rowing (Can be used)
Rating: 5
Filesize: 29.51 kB
Downloads: 2280
Comments: 0
Ratings: 1
Date added: 2018/07/30 14:09:06
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: A creative solution to a problem
Rating: 5
Filesize: 187.64 kB
Downloads: 1890
Comments: 0
Ratings: 1
Date added: 2024/08/21 15:08:39
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Fan Marble Race - Part 2
Rating: 5
Filesize: 419.77 kB
Downloads: 548
Comments: 0
Ratings: 1
Date added: 2017/01/12 13:01:29
Made with: Algodoo v2.1.0
Rating: rated 5
download
Something > 5 ? {}:{}
you have to write it like that. What you wrote was
Something > 5 {}
and algodoo doesn't know what that is, so it added some () in order to see if it could fix your code, but nope.
Always be sure that your code isn't changed too much after you finish writing it and clck somewhere else. If parentheses appear on some places your code is bad.

To separate lines of your script you have to use ; like

Scene.my.ignition = true; scene.my.rpm < 300? {scene.my.throttle = 500}:{}

The {}:{} of the if statement mean that if what you're asking is true (like scene.my.rpm < 300 ?) the code on the first {} will be executed. If it isn't the code on the second one will be executed. You can leave one empty inside, but it has to be there!

Also you have to DECLARE your variables before using them, else every scene.my.thing that you wrote doesn't actually exist. Press F10 and write the names of your variables and the initial value you want them to have, like:

Scene.my.whatever = 0

Also if you write a script in the postStep of something, it will be executed no matter what, if the scene is running. so basically you're saying that scene.my.con = 13350 * scene.my.rpm, scene.my.con = 120000 and scene.my.con = 0 at the same time. You have to write that on each lasers' onLaserHit. This means that your script will be executed only when your laser hits something.

And to get scene.my.rpm, you should write scene.my.rpm = angVel * 9.54 on the postStep of the flywheel. This is because angVel is in radians per second, and 1 radian per second is 9.54 RPM
Last edited at 2016/12/12 18:40:05 by The Linkage
Your script does not work for a series of reasons:

First of all, your three lasers all edit the con variable at the same time every single frame, since every one of them has scene.my.con = xxx in their poststep. If you want keycontrolled changes, use keys.isDown("up") ? {} : {} instead. Lasers are a method, but using keys.isdown is more efficient.

Second of all, turning the lasers on has no effect to the scenes since theres neither a onLaserHit nor a onHitByLaser coded somewhere

Lastly, the scene.my.rpm variable is used nowhere, so changing it has no effect.
If you want to know some general thyme, look at this page created by me and someone else:

http://algodoo.wikia.com/wiki/Thyme

for your code to work, remove all code and put it in the hinge like this instead:

postStep: (e)=>{
keys.isDown("up") ? {
motorspeed = math.pi * [Write your RPS here, not RPM. You can also write the formula for it here];
} : {}

Depending on how you want to influence the motor speed or whatever you like to change, add more lines for calculation or whatever you like.


}
actually it would be nice if you didn't use a motor axle for an engine
The Linkage im not trying to.
goooood
I said that mainly cause of fra32's last comment tho
don't be mad at me