Need a hand [I'm trying my hand at thyme..]
16 posts • Page 1 of 1
Need a hand [I'm trying my hand at thyme..]
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
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..]
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.
-

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..]
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:
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...
-

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..]
I've never seen this before... what does geval do?
-

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..]
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...
-

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..]
Awesome, thank you Kilinich.
So, in
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
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..]
Kilinich, quit being so complexdicated. And scene.my pointless.
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)
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.
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...
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.
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.
-

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..]
But I like green lasers
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.
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.
-

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..]
Someone Else wrote:Kilinich, quit being so complexdicated. And scene.my pointless.![]()
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..]
Messyart wrote:Someone Else wrote:Kilinich, quit being so complexdicated. And scene.my pointless.![]()
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...
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.
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.
-

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..]
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;
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..]
The script goes in the box, not the laser.
{IF} ? {THEN} : {ELSE}
IF statement pseudocode:
- 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...
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.
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.
-

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..]
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..]
Still trying to understand the code...
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"?
- 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"?
-

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..]
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...
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.
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.
-

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..]
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
-

bozbez - Posts: 149
- Joined: Tue Apr 12, 2011 7:01 pm
16 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests





