question

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

question

Postby Ivanlul » Sun May 09, 2010 4:14 am

Is there a way to make a script do something when it is not being hit by a laser instead of when is is being hit by a laser?
Registered: 2008-10-16
Image
User avatar
Ivanlul
 
Posts: 763
Joined: Mon Aug 31, 2009 11:19 pm
Location: US

Re: question

Postby niffirg1 » Sun May 09, 2010 5:35 am

That has been Suggested: onIdle, etc. It would be great but no, to my knowledge there is not a way to do this (Wish there was)
User avatar
niffirg1
 
Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

Re: question

Postby KarateBrot » Sun May 09, 2010 5:52 am

Yes there is.

If you want to use scene.my. variables

Open the console and type in this two lines of code
Code: Select all
scene.my.timecheck := 0.0

scene.my.onIdle := { (sim.time - scene.my.timecheck > 1/sim.frequency) && sim.running ? {*do sth when not colliding*} : { }; 11.0 }

After that create the object and the laser. In the object's onHitByLaser type in:
Code: Select all
(e)=>{scene.my.timecheck = sim.time}

In the object's controllerAcc type in:
Code: Select all
{scene.my.onIdle}



If you hate scene.my. variables

First create the object and the laser. Define a new object variable in the object's scripting menu. In the line at the bottom type in:
Code: Select all
timecheck := 0.0

If you don't want to define a new object variable use one which already exists and which you don't need (for example textScale)

In the object's onHitByLaser type in:
Code: Select all
(e)=>{timecheck = sim.time}

In the object's controllerAcc type in:
Code: Select all
{ (sim.time - timecheck > 1/sim.frequency) && sim.running ? {*do sth when not colliding*} : { }; 11.0 }


And that's it. Now the event will be executed every time the laser does NOT hit the object ;)

Only important if you want to use the geometry controller:
The cool thing is you still can use controllerAcc for steering objects. The only thing is: if you want to change controllerAcc in the geometry controller menu you can't do it there. But you can change the acceleration values in your scene.my.onIdle code from 11.0 to the value you want.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: question

Postby niffirg1 » Sun May 09, 2010 8:37 pm

Wow... Never knew that.
User avatar
niffirg1
 
Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

Re: question

Postby KarateBrot » Sun May 09, 2010 11:04 pm

Me neither :D
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: question

Postby Matten » Mon May 10, 2010 1:07 pm

But I think an onIdle script would be easier
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
User avatar
Matten
 
Posts: 435
Joined: Mon Apr 05, 2010 2:03 pm
Location: The Netherlands

Re: question

Postby Dakta » Tue May 11, 2010 3:47 am

Meh, if you add features to fill every user's every need for a function, all you do is create unnecessary clutter.

The means to do this already exists, and is pretty straightforward, so I don't think a special function is needed for it.
.. ,__,_____
. / __.==--" - - - - - - - - ""
./#(-'
.`-' From http://www.ascii-art.de/. Modded by me to work in Arial. Image
a Mammoth wrote:be boring and interesting.

Mystery wrote:If you were jailbreaker you shouldn't have when't up the 3.1.3
I didn't know you could go up 3.1.3! Thanks Mystery person!
User avatar
Dakta
 
Posts: 417
Joined: Sat Sep 12, 2009 4:36 pm

Re: question

Postby Rrobba » Wed May 12, 2010 5:43 pm

There is no simple way to do it. But with quite a lot of scripting it can be done. I do hope they implement this in an easier form soon, and the same thing for on-collide with normal objects and shapes.
Image
I don't suffer from insanity. I enjoy every minute of it.
User avatar
Rrobba
[Best Sig 2010]
 
Posts: 1480
Joined: Mon Aug 31, 2009 6:01 pm
Location: Gibraltar

Re: question

Postby KarateBrot » Thu May 13, 2010 5:13 pm

you can do this with oncollide too. you just have to put (e)=>{scene.my.timecheck = sim.time} into onCollide instead of OnHitByLaser
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: question

Postby Rideg » Tue May 18, 2010 9:18 pm

Okey how would I go around making something when it's hit and when it's not do another thing?
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: question

Postby Matten » Wed May 19, 2010 7:27 am

For example if you want to make a loop that is executed every frame. But you can switch the loop off by touching the block.
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
User avatar
Matten
 
Posts: 435
Joined: Mon Apr 05, 2010 2:03 pm
Location: The Netherlands

Re: question

Postby Rideg » Wed May 19, 2010 6:50 pm

I solved this with a DEactivasionbutton on the laser ;)
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: question

Postby Matten » Wed May 19, 2010 7:36 pm

Rideg wrote:I solved this with a DEactivasionbutton on the laser ;)

I was searching for that :thumbup: How does it work?!
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
User avatar
Matten
 
Posts: 435
Joined: Mon Apr 05, 2010 2:03 pm
Location: The Netherlands

Re: question

Postby Rideg » Wed May 19, 2010 9:09 pm

here's the code:
Code: Select all
// Phunlet created by Algodoo v1.7.1

FileInfo -> {
    title = "Missile Launcher v1.6.1 [PROTOTYPE]";
    author = "Rideg";
    version = 8
};
Scene.addLaserPen {
    geom := -1;
    pos := [-0.21875, 0.5414031];
    velocity := +inf;
    fadeDist := 25.0;
    maxRays := 1;
    cutter := false;
    opaqueBorders := true;
    showLaserBodyAttrib := true;
    size := 0.08280628;
    collideSet := 127;
    collideWater := true;
    color := [1.0, 0.0, 0.0, 1.0];
    onLaserHit := (e)=>{};
    entityID := 15225;
    zDepth := 23.0;
    rotation := 1.5707964;
    activationButton := "on toggle return"
}


Just paste it in the algodoo window ;)
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: question

Postby Matten » Thu May 20, 2010 7:27 am

Rideg wrote:here's the code:
Code: Select all
// Phunlet created by Algodoo v1.7.1

FileInfo -> {
    title = "Missile Launcher v1.6.1 [PROTOTYPE]";
    author = "Rideg";
    version = 8
};
Scene.addLaserPen {
    geom := -1;
    pos := [-0.21875, 0.5414031];
    velocity := +inf;
    fadeDist := 25.0;
    maxRays := 1;
    cutter := false;
    opaqueBorders := true;
    showLaserBodyAttrib := true;
    size := 0.08280628;
    collideSet := 127;
    collideWater := true;
    color := [1.0, 0.0, 0.0, 1.0];
    onLaserHit := (e)=>{};
    entityID := 15225;
    zDepth := 23.0;
    rotation := 1.5707964;
    activationButton := "on toggle return"
}


Just paste it in the algodoo window ;)

Thanks :thumbup:
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
User avatar
Matten
 
Posts: 435
Joined: Mon Apr 05, 2010 2:03 pm
Location: The Netherlands


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest