Need a hand [I'm trying my hand at thyme..]

For topics that don't fit under the other topics or forums.

Need a hand [I'm trying my hand at thyme..]

Postby Messyart » Thu Apr 07, 2011 1:32 am

Simple issue, I have been trying to wrap my head around some.. Basics.
I want for a laser hit on a block to increase the attraction to, well, more.
I did so successfully, but then it remains at that.. And my brain just farted while trying to work out how to make it solely while the laser is in contact >.<

I got this.. (e)=>{attraction = (1000)}

I do not want a permanent increase in attraction.
I appreciate any help
Messyart
 
Posts: 5
Joined: Thu Apr 07, 2011 1:24 am

Re: Need a hand [I'm trying my hand at thyme..]

Postby TC42 » Thu Apr 07, 2011 3:09 am

You would have to use two other lasers on the right and left of the original laser to reset the attraction to 0 when the block drifts out of the original laser's beam. That's how I would do it, but you may want to ask Kilinich, for he would know it far better than I.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Need a hand [I'm trying my hand at thyme..]

Postby Kilinich » Thu Apr 07, 2011 7:48 am

There is no easy way to do it. So for beginner I recommend not to dig too deep and search for another way to do the original task (explosion?).

Anyway, here it is a code for laser:

Code: Select all
onLaserHit = (e) => {
    nextTick := sim.tick +1;
    scene.my.obj = e.geom;
    geval("scene.my.obj.attraction= {sim.tick > " +nextTick+ " ? 0 : -5}");
    scene.my.obj = {}
}
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Need a hand [I'm trying my hand at thyme..]

Postby TC42 » Thu Apr 07, 2011 9:13 pm

I've never seen this before... what does geval do?
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Need a hand [I'm trying my hand at thyme..]

Postby Kilinich » Thu Apr 07, 2011 10:11 pm

TC42 wrote:I've never seen this before... what does geval do?

same as "eval" but in global scope.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Need a hand [I'm trying my hand at thyme..]

Postby Messyart » Thu Apr 07, 2011 11:12 pm

Awesome, thank you Kilinich.

So, in
Code: Select all
onLaserHit = (e) => {
    nextTick := sim.tick +1;
    scene.my.obj = e.geom;
    geval("scene.my.obj.attraction= {sim.tick > " +nextTick+ " ? 0 : -5}");
    scene.my.obj = {}
}


I see "scene.my", I guess I'm going to have to hit F11 and type that in?
And the attraction value.. Would that be that " ? 0 part?


I hadn't truly appreciated how difficult it might be to grasp this stuff >.< I admire your works just a little bit more now I can see what goes into it
Messyart
 
Posts: 5
Joined: Thu Apr 07, 2011 1:24 am

Re: Need a hand [I'm trying my hand at thyme..]

Postby Someone Else » Fri Apr 08, 2011 2:12 am

Kilinich, quit being so complexdicated. And scene.my pointless. :thumbdown:

You need one laser attached to the object (it needs to be partly transparent, this laser must be pure blue and with 1 maxRays- set both in script menu, color = [0, 0, 1, 1]), the other laser can be any color and mounted off the geom. Or inside the geom, but with an activation key.

Anyway, inside the geom goes this code: (onLaserHit)
Code: Select all
{e.laser.color == [0, 0, 1, 1]} ? {attraction = 0} : {};
attraction = 1000

Whenever it's being hit by a laser whose color is not pure blue, its attraction becomes 1000. Whenever it is not being hit be a laser whose color is pure blue (no matter how many blue lasers there are), its attraction becomes set equal to 0.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Need a hand [I'm trying my hand at thyme..]

Postby TC42 » Fri Apr 08, 2011 2:30 am

But I like green lasers :cry:

Anyway, I think that Kilinich's way will work better in the long run, but for a complete newbie it is better to use SE's version (or mine) to learn the material.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Need a hand [I'm trying my hand at thyme..]

Postby Messyart » Fri Apr 08, 2011 3:04 am

Someone Else wrote:Kilinich, quit being so complexdicated. And scene.my pointless. :thumbdown:

You need one laser attached to the object (it needs to be partly transparent, this laser must be pure blue and with 1 maxRays- set both in script menu, color = [0, 0, 1, 1]), the other laser can be any color and mounted off the geom. Or inside the geom, but with an activation key.

Anyway, inside the geom goes this code: (onLaserHit)
Code: Select all
{e.laser.color == [0, 0, 1, 1]} ? {attraction = 0} : {};
attraction = 1000

Whenever it's being hit by a laser whose color is not pure blue, its attraction becomes 1000. Whenever it is not being hit be a laser whose color is pure blue (no matter how many blue lasers there are), its attraction becomes set equal to 0.


I might be doing something wrong.. But it's not working D:

the blue laser inside the slightly transparent box?
the box has the coding to change to 1000 attraction when hit by other lasers..

But the attraction is then instantly 1000.. D:
Messyart
 
Posts: 5
Joined: Thu Apr 07, 2011 1:24 am

Re: Need a hand [I'm trying my hand at thyme..]

Postby Someone Else » Fri Apr 08, 2011 3:43 am

Messyart wrote:
Someone Else wrote:Kilinich, quit being so complexdicated. And scene.my pointless. :thumbdown:

You need one laser attached to the object (it needs to be partly transparent, this laser must be pure blue and with 1 maxRays- set both in script menu, color = [0, 0, 1, 1]), the other laser can be any color and mounted off the geom. Or inside the geom, but with an activation key.

Anyway, inside the geom goes this code: (onLaserHit)
Code: Select all
{e.laser.color == [0, 0, 1, 1]} ? {attraction = 0} : {};
attraction = 1000

Whenever it's being hit by a laser whose color is not pure blue, its attraction becomes 1000. Whenever it is not being hit be a laser whose color is pure blue (no matter how many blue lasers there are), its attraction becomes set equal to 0.


I might be doing something wrong.. But it's not working D:

the blue laser inside the slightly transparent box?
the box has the coding to change to 1000 attraction when hit by other lasers..

But the attraction is then instantly 1000.. D:

The blue laser should be inside the slightly transparent box (or circle or polygon), yes. TC42, if you want a green laser, change e.laser.color == [0, 0, 1, 1] to e.laser.color == [0, 1, 0, 1].

This code instantly snaps the attraction to 1000 or 0, based on the presence or absence of non-blue lasers.

If you want the attraction to not snap instantly but instead change gradually, use:
Code: Select all
    {e.laser.color == [0, 0, 1, 1]} ? {attraction = attraction - 30} : {attraction = attraction + 60};
    {attraction < 0} ? {attraction = 0} : {};
    {attraction > 1000} ? {attraction = 1000} : {}

The first line increments or decrements attraction based on the presence or absence of non-blue lasers. The bigger the numbers, the faster the change, but be aware that for increasing the attraction, the code must first make up for the decreasing before it can increase attraction.
The second and third lines simply set limits, so attraction cannot rise greater than 1000 or fall less than 0.

Make sure you put this into onHitByLaser. Your onCollide and onHitByLaser should always look like this:
Code: Select all
(e)=>{codeGoesHere}
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Need a hand [I'm trying my hand at thyme..]

Postby Messyart » Fri Apr 08, 2011 4:21 pm

Right.. Blue laser inside box that has the onhitbyaser script in, which has caused me an instant problem.
That alone has caused the boxs' attraction to increase.

*sigh*
If you care to spare me more of your time, could you explain the "?" function here;
Code: Select all
{e.laser.color == [0, 0, 1, 1]} ? {attraction = 0} : {};
attraction = 1000
Messyart
 
Posts: 5
Joined: Thu Apr 07, 2011 1:24 am

Re: Need a hand [I'm trying my hand at thyme..]

Postby Someone Else » Fri Apr 08, 2011 5:04 pm

The script goes in the box, not the laser.
Code: Select all
{e.laser.color == [0, 0, 1, 1]} ? {attraction = attraction - 30} : {attraction = attraction + 60};
{attraction < 0} ? {attraction = 0} : {};
{attraction > 1000} ? {attraction = 1000} : {}

{IF} ? {THEN} : {ELSE}
IF statement pseudocode:
Code: Select all
{IF e.laser.color is pure blue} ? {THEN decrement attraction by 30 } : {ELSE increment attraction by 60}
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Need a hand [I'm trying my hand at thyme..]

Postby Messyart » Fri Apr 08, 2011 8:57 pm

Someone Else wrote:The script goes in the box, not the laser.
Code: Select all
{e.laser.color == [0, 0, 1, 1]} ? {attraction = attraction - 30} : {attraction = attraction + 60};
{attraction < 0} ? {attraction = 0} : {};
{attraction > 1000} ? {attraction = 1000} : {}

{IF} ? {THEN} : {ELSE}
IF statement pseudocode:
Code: Select all
{IF e.laser.color is pure blue} ? {THEN decrement attraction by 30 } : {ELSE increment attraction by 60}


Thanks for explaining.

I did have the script set for the box D:
Messyart
 
Posts: 5
Joined: Thu Apr 07, 2011 1:24 am

Re: Need a hand [I'm trying my hand at thyme..]

Postby TC42 » Sat Apr 09, 2011 11:00 pm

Still trying to understand the code...

Code: Select all
onLaserHit = (e) => {
    nextTick := sim.tick +1;
    scene.my.obj = e.geom;
    geval("scene.my.obj.attraction= {sim.tick > " +nextTick+ " ? 0 : -5}");
    scene.my.obj = {}
}


So does that ^ essentially say:
"On laser hit, the object's attraction = -5, but if the laser is not hitting it in the next 'tick', then its attraction is 0"?
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Need a hand [I'm trying my hand at thyme..]

Postby Someone Else » Tue Apr 12, 2011 5:38 pm

Messyart wrote:
Someone Else wrote:The script goes in the box, not the laser.
Code: Select all
{e.laser.color == [0, 0, 1, 1]} ? {attraction = attraction - 30} : {attraction = attraction + 60};
{attraction < 0} ? {attraction = 0} : {};
{attraction > 1000} ? {attraction = 1000} : {}

{IF} ? {THEN} : {ELSE}
IF statement pseudocode:
Code: Select all
{IF e.laser.color is pure blue} ? {THEN decrement attraction by 30 } : {ELSE increment attraction by 60}


Thanks for explaining.

I did have the script set for the box D:

Does it work now?
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Need a hand [I'm trying my hand at thyme..]

Postby bozbez » Wed Apr 20, 2011 3:15 pm

TC42 wrote:Still trying to understand the code...

Code: Select all
onLaserHit = (e) => {
    nextTick := sim.tick +1;
    scene.my.obj = e.geom;
    geval("scene.my.obj.attraction= {sim.tick > " +nextTick+ " ? 0 : -5}");
    scene.my.obj = {}
}


So does that ^ essentially say:
"On laser hit, the object's attraction = -5, but if the laser is not hitting it in the next 'tick', then its attraction is 0"?

Yep :)
Image

Go here. Now. That's Now. Not in 5 minutes. Now.
User avatar
bozbez
 
Posts: 149
Joined: Tue Apr 12, 2011 7:01 pm


Return to Algodoo in general

Who is online

Users browsing this forum: No registered users and 4 guests