Browse Search Popular Register Upload Rules User list Login:
Search:
i need help with script

Image:
screenshot of the scene

Author: yarik_shlepa

Group: Default

Filesize: 70.78 kB

Date added: 2024-12-09

Rating: 5

Downloads: 650

Views: 187

Comments: 2

Ratings: 1

Times favored: 0

Made with: Algodoo v2.1.0

Tags:

Scene tag

my bacteria should turn towards a piece of wood and turn away from the other materials, but I dont know how to check the material of the object that the laser hit. it would also be cool to bind variables not to the scene, but to the object on which the lasers are located. I will be grateful even for a simple explanation in the comments
Please log in to rate this scene
edit
Similar scenes
Title: script COLLECTION
Rating: 8.25
Filesize: 1.12 MB
Downloads: 5114
Comments: 12
Ratings: 14
Date added: 2019/03/28 18:42:29
Made with: Algodoo v2.1.0
Rating: rated 8.3
download
Title: Mounted Minigun (PHUN ONLY)
Rating: 5.8889
Filesize: 57.57 kB
Downloads: 2264
Comments: 13
Ratings: 3
Date added: 2009/11/29 06:22:18
Made with: Phun
Rating: rated 5.9
download
Title: eat script demonstration
Rating: 5
Filesize: 18.04 kB
Downloads: 494
Comments: 3
Ratings: 1
Date added: 2017/09/13 21:25:09
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Ball mix
Rating: 5
Filesize: 36.32 kB
Downloads: 545
Comments: 4
Ratings: 1
Date added: 2016/02/13 03:46:10
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Bob the Script 1
Rating: 5.7273
Filesize: 19.28 kB
Downloads: 834
Comments: 3
Ratings: 5
Date added: 2009/07/08 22:08:44
Made with: Phun
Rating: rated 5.7
download
Title: Scripted Party Laser V.2
Rating: 5
Filesize: 6.51 kB
Downloads: 498
Comments: 0
Ratings: 1
Date added: 2013/12/30 01:43:13
Made with: Algodoo v2.1.0
Rating: rated 5
download
In your lasers you need to add the letter e like this:

e.geom.materialName == "wood" ? {
scene.my.vel = -0.4
} : {
scene.my.vel = 0.3
}

Then they will see the wood!
What Xray said is true!

As for the variable problem, it's quite simple to move the variables to the object.

Firstly, open the script menu for the object.
Now, in the top left corner, type _(varname) = (value).
It's important to have a _ before the variable name, otherwise the variable will be declared as "volatile" and will delete itself next time the scene reloads. (this includes undo/redo)

To access the variable through the attached lasers, insert this code at the beginning of the script (i.e. right after (e)=>{)

obj = (scene.entityByGeomID((readable(entity)).geom));

­From there, you can simply access the desired variable with obj._(varname).

The same code works on thrusters.

For springs, axles, and fixjoints it's a bit more complicated as there are 2 geometries rather than just 1, but it's fairly straightforward. :lol:

Hope this helps! :lol:

This has actually inspired me to try to make my own "artificial lifeform" kind of like you can see in some old scenes by ravenplucker and darkphenix!

I've tried doing so several times in the past, but none of them were any good :(

This was almost 3 years ago if memory serves me right however -- so hopefully my scripting has improved just a bit. :lol:
Last edited at 2024/12/09 20:36:24 by Little