Question regarding laser scripting

About advanced scenes, and the Thyme scripting language used in Algodoo.

Question regarding laser scripting

Postby Vytas » Fri Nov 06, 2009 4:17 pm

Hi. I'm looking for a way when a laser hits an object I can retrieve the information of the laser for example the fade distance etc. I can't figure it out for myself so I hope u guys have a solution for me.
Vytas
 
Posts: 49
Joined: Mon Oct 26, 2009 8:18 pm

Re: Question regarding laser scripting

Postby standardtoaster » Fri Nov 06, 2009 4:22 pm

e.laser.followed by whatever else is in the script menu of the laser.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Question regarding laser scripting

Postby Vytas » Fri Nov 06, 2009 4:24 pm

Thank you :clap:
Vytas
 
Posts: 49
Joined: Mon Oct 26, 2009 8:18 pm

Re: Question regarding laser scripting

Postby Vytas » Fri Nov 06, 2009 4:29 pm

Well I have one question remaining. Is there a way to get an reference too the laser object when the laser hits nothing. for example an object collides with another object and this way it activates the laser
Vytas
 
Posts: 49
Joined: Mon Oct 26, 2009 8:18 pm

Re: Question regarding laser scripting

Postby standardtoaster » Fri Nov 06, 2009 4:31 pm

Somewhat, yes.
Make a variable:
Code: Select all
scene.my.rays = 0

In the maxrays part of the laser script menu put:
Code: Select all
{scene.my.rays}

In the onCollide of the objects put:
Code: Select all
scene.my.rays = 1000
//or any value higher than 0
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Question regarding laser scripting

Postby Vytas » Fri Nov 06, 2009 4:33 pm

Ok that's all thank you.
Vytas
 
Posts: 49
Joined: Mon Oct 26, 2009 8:18 pm

Re: Question regarding laser scripting

Postby Vytas » Fri Nov 06, 2009 5:46 pm

I have a problem with the script I made.

scene.my.laser1 controls how much rays my laser has got and that works. But I want it to switch on and off each time it collides with an object. So i made this:
Code: Select all
(e) => {scene.my.laser1 = 1 ? {scene.my.laser1 = 0} : {scene.my.laser1 = 1}} // this doesn't work
(e) => {true ? {scene.my.laser1 = 1} : {scene.my.laser1 = 0}} //this will activate the laser but not put it off with an other collide ofcourse.


Do u know what the problem is?
Vytas
 
Posts: 49
Joined: Mon Oct 26, 2009 8:18 pm

Re: Question regarding laser scripting

Postby Sniperkasa » Fri Nov 06, 2009 6:08 pm

Yup
Code: Select all
    (e) => {scene.my.laser1 == 1 ? {scene.my.laser1 = 0} : {scene.my.laser1 = 1}} // this works.
If you have a question, have a dollar and call somebody that cares.
No really just PM me if you have a problem :)
User avatar
Sniperkasa
 
Posts: 493
Joined: Tue Sep 01, 2009 5:34 pm
Location: The bottom of a lake.

Re: Question regarding laser scripting

Postby Vytas » Fri Nov 06, 2009 6:18 pm

Ah I see what I did wrong I used the wrong operator.
Vytas
 
Posts: 49
Joined: Mon Oct 26, 2009 8:18 pm

Re: Question regarding laser scripting

Postby Sniperkasa » Fri Nov 06, 2009 6:44 pm

`Yup, remember to use ==, not =..
= is when you declare an variable
If you have a question, have a dollar and call somebody that cares.
No really just PM me if you have a problem :)
User avatar
Sniperkasa
 
Posts: 493
Joined: Tue Sep 01, 2009 5:34 pm
Location: The bottom of a lake.


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 7 guests