Teleport object - onCollide script

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

Teleport object - onCollide script

Postby leroidangleterre » Wed Oct 30, 2013 5:20 pm

Hello everyone,

I have been trying to make a teleporter (I would use it in water simulations). It is a simple box with an onCollide script that should change the coordinates of the object colliding with the box.

I tried this code:
Code: Select all
onCollide = (e)=>{e.other.pos=e.pos+[1,1]}
but it doesn't do anything. Colliding objects don't have an special behavior.
There doesnt seem to be a syntax error because the objet is loaded and I can see the code in the Script Menu. It just doesn't work, and I don't know why.

So, if anyone can help, it woud be great!
leroidangleterre
 
Posts: 12
Joined: Fri Sep 06, 2013 5:27 pm

Re: Teleport object - onCollide script

Postby Kilinich » Thu Oct 31, 2013 7:59 pm

Everything fine. Are you sure you running 2.1.0 ? Are you sure it's collided (set App.drawCollisions = true to see collision points)?
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: Teleport object - onCollide script

Postby Xray » Fri Nov 01, 2013 5:54 am

I tried it too, and it works just fine as expected. If the problem isn't what kilinich suggested, then you might have something else going on that we don't know about because we don't know what your scene looks like. So, it would be very helpful if you could upload your scene to this forum so that we could take a look at it.
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Teleport object - onCollide script

Postby MrGlinzz » Sat Nov 02, 2013 1:31 am

Works fine with boxes, not with water.

Does water actually have an editable 'pos' option? Could be to do with how water uses 'vecs'. Although e.other.vecs doesn't do anything either..
And trying to get the position of the water by storing it in a variable doesnt work

I hope this helps somewhat!
MrGlinzz
 
Posts: 13
Joined: Tue Mar 19, 2013 11:51 pm

Re: Teleport object - onCollide script

Postby electronicboy » Sat Nov 02, 2013 3:02 am

Can we even run code against water, I don't think that we actually can.
I know water triggers onCollide on geometries, but I don't think water supports e.other, as technically it's not a geometry!

I don't think algodoo even really gives water their own variables, other than for location and velocity.
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm

Re: Teleport object - onCollide script

Postby VZstrikez08 » Fri Nov 08, 2013 1:58 am

PROBLEM DETECTED!


your problem is that you are probably putting in [1,1],you need 3 numbers in there,so,to change the just the X coord is just having [1,0,0],while Y is [0,1,0](not sure what third is)
VZstrikez08
 
Posts: 6
Joined: Fri Nov 08, 2013 1:39 am

Re: Teleport object - onCollide script

Postby Xray » Fri Nov 08, 2013 2:21 am

VZstrikez08 - What are you talking about? The object position array has only two values (one for X pos, and one for Y pos), not three. What makes you think there are three numbers?
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Teleport object - onCollide script

Postby VZstrikez08 » Fri Nov 15, 2013 2:01 am

Epic fail on my part.Must have had some hallucinations.I'll go get that checked out.
VZstrikez08
 
Posts: 6
Joined: Fri Nov 08, 2013 1:39 am

Re: Teleport object - onCollide script

Postby Xray » Fri Nov 15, 2013 9:27 am

VZstrikez08 wrote:Epic fail on my part.Must have had some hallucinations.I'll go get that checked out.


No problem. We all have those brain farts occasionally. I suspect that you were thinking in 3 dimensions (x,y,z), but Algodoo is a 2D simulation program, so, unfortunately, we do not have a third dimension (z) to play with. Maybe some day Algoryx will produce a 3D version of Algodoo, but I'm not holding my breath.

Regards,
Xray
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Teleport object - onCollide script

Postby Xray » Fri Nov 15, 2013 9:41 am

Just a personal note..... Is it just me, or do other people get bothered when a user asks for help (such as this user, leroidangleterre ) and a number of people jump in with suggestions to resolve his issue, and you never hear from him again? It seems rude that in two weeks time he wasn't able to chime in to let us know that either:
1. One of our suggestions resolved his issue.
2. He resolved it himself.
3. He is no longer interested in this issue or for any other reason, no longer needs our help.

In two weeks time, he could have given us the courtesy of replying, if for no other reason but to acknowledge our assistance, and maybe even to express a little gratitude.

Maybe I'm being a little overly sensitive about this, but I felt the need to spout off about it.

Thanks for listening. :thumbup:
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Teleport object - onCollide script

Postby jon_joy_1999 » Tue Dec 03, 2013 8:24 am

Xray wrote:Maybe some day Algoryx will produce a 3D version of Algodoo, but I'm not holding my breath.

Regards,
Xray
they got one, it's called AgX Multiphysics, but it's definitely probably™ not free (in fact there isn't even a price on it, a buyer must contact Algoryx for information)
Xray wrote:Just a personal note..... Is it just me, or do other people get bothered when a user asks for help (such as this user, leroidangleterre ) and a number of people jump in with suggestions to resolve his issue, and you never hear from him again? It seems rude that in two weeks time he wasn't able to chime in to let us know that either:
1. One of our suggestions resolved his issue.
2. He resolved it himself.
3. He is no longer interested in this issue or for any other reason, no longer needs our help.

In two weeks time, he could have given us the courtesy of replying, if for no other reason but to acknowledge our assistance, and maybe even to express a little gratitude.

Maybe I'm being a little overly sensitive about this, but I felt the need to spout off about it.

Thanks for listening. :thumbup:
it happens, people either post and forget, or decide to abandon the project, or become too busy to work on the project. while I agree that it is frustrating that he hasn't responded, I don't feel it's rude. rudeness would require deliberation. I apply excessive amounts of Hanlon's razor in these matters.
Image
BSrac = BoincStats recent average credit
I'd rather be network computing.
jon_joy_1999
 
Posts: 233
Joined: Fri Dec 09, 2011 12:51 am

Re: Teleport object - onCollide script

Postby Xray » Tue Dec 03, 2013 6:13 pm

Hi Jon_joy - Hanlon's Razor??? I'll have to look that up!

You are right about the OP possibly not being deliberate, and I may be a little too cynical. I just happen to be a little older than most people on this forum, and therefore I come from the old school of courtesy, manners, and consideration for others, which people now-a-days just don't seem to have as much of. I won't lose any sleep over it.

Thanks for your input!
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Teleport object - onCollide script

Postby leroidangleterre » Mon Mar 24, 2014 12:54 am

Hello everyone,

First, I am sorry about the delay. I did not mean to be rude or to seem uninterested in your replies, but I had priorities that kept me away.
I tried a few things, including the display of the collisions, but I can't find out the origin of the problem. As you can see in the attached scene file, I see that a collision is detected between the box and the circles; I manage to change the color of the circles when the collision occurs. But I still can't change the position of the colliding object. Any idea why the code
Code: Select all
onCollide = (e)=>{e.other.pos := e.this.pos + [0.0, 2.0]}
won't work?

Thank you (and this time I will try not to be AFK for too long :) )!
Attachments
teleporter.phz
(5.36 KiB) Downloaded 52 times
leroidangleterre
 
Posts: 12
Joined: Fri Sep 06, 2013 5:27 pm

Re: Teleport object - onCollide script

Postby Xray » Mon Mar 24, 2014 4:11 am

I don't understand what you think the problem is because it is working exactly as you scripted it. Just working with one circle so as not to add too much confusion, as soon as the circle collides with the box, the circle translates to the pos of the box + [0.0,2.0], and the circle's color becomes the color of the box. What do you see is wrong with that? :?
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Teleport object - onCollide script

Postby leroidangleterre » Mon Mar 24, 2014 11:31 am

Well, on my computer the circle changes its color but is not "teleported", as if the code
Code: Select all
onCollide = (e)=>{e.other.pos := e.this.pos + [0.0, 2.0]}
did not exist at all. But the color is affected, so it's quite weird. I should try re-installing the software.
Thanks, anyway!
leroidangleterre
 
Posts: 12
Joined: Fri Sep 06, 2013 5:27 pm

Re: Teleport object - onCollide script

Postby Kilinich » Mon Mar 24, 2014 2:11 pm

use = instead of := for existing variables/objects
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: Teleport object - onCollide script

Postby leroidangleterre » Mon Mar 24, 2014 10:45 pm

Ok, I reinstalled everythig with the latest version and this time, the teleportation worked :clap:
I still feel frustrated because it ony works with solids, and not with water, and I would have liked that; anyway, this is funny enough for me right now.
And maybe I could write a specific script for regular circles that would make them act like water particles; but it would probably be easier to write my own Java or C application...
Thanks for your help and sorry again about not following my own post.
leroidangleterre
 
Posts: 12
Joined: Fri Sep 06, 2013 5:27 pm

Re: Teleport object - onCollide script

Postby Kilinich » Tue Mar 25, 2014 10:33 am

Yea, water don't call onCollide so you could not teleport it this way(
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: Teleport object - onCollide script

Postby leroidangleterre » Tue Mar 25, 2014 3:52 pm

Do you think there could be another way to teleport water? Would it be possible to turn water into a solid, then teleport it, and then change it to water again?
leroidangleterre
 
Posts: 12
Joined: Fri Sep 06, 2013 5:27 pm

Re: Teleport object - onCollide script

Postby Xray » Tue Mar 25, 2014 6:56 pm

You can freeze water (convert water into a polygon) but as far as I know, it can only be done manually through the edit menu:
Select the water that you want to freeze, then in the edit menu, select "Water options" and then select "Freeze water". You CAN liquefy a geometry such as a polygon which is frozen water. For example: onCollide = (e)=> [e.other.liquify}

The amount of control that we have over water is extremely limited. There have been attempts to simulate Algodoo water using circles, but the results (in my humble opinion) have been less than desirable. If you figure out a good way to simulate water using circles, please do share it with us!
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: Teleport object - onCollide script

Postby Luka » Tue Mar 25, 2014 7:15 pm

Water has only three variables. But water actually registers onCollide, but you can't register it from water.

Here are the variables:
vecs - water's position (every water particle has its own variable)
vels - water's velocity
version - idk what is this

Want proof?
Add a small circle (0.01 - 0.06m) and liquify it. You got one particle of water.
Now copy the water and add that code on a solid object on onCollide().
You will see that there are only three variables. Now play the scene and woala! It registers onCollide but only on an solid object.

Code:
Code: Select all
Scene.addWater({
        vecs := [[11.462126, 5.2153082]];
        vels := [[0.0, 0.0]];
        version := 4
    })


PS. Xray replied while I was still writing. :lol:
EDIT: I was trying to edit the vecs variable to teleport water in that way. Water actually does not register itself on e.other.
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Luka
 
Posts: 17
Joined: Wed Oct 23, 2013 12:57 pm
Location: pos[0, 0]

Re: Teleport object - onCollide script

Postby leroidangleterre » Fri Mar 28, 2014 4:56 pm

I am currently working on a separate program to apply the SPH technique. As soon as I am done with it, I will try to apply these equations to a regular circle in Algodoo, and I will see what I get. If successful, I'll let you know!
leroidangleterre
 
Posts: 12
Joined: Fri Sep 06, 2013 5:27 pm

Re: Teleport object - onCollide script

Postby electronicboy » Fri Mar 28, 2014 6:46 pm

"// Phun scene created by Phun v5.28"

Eeeerm, guuys, according to the scene he passed he is running Phun.
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm

Re: Teleport object - onCollide script

Postby Xray » Fri Mar 28, 2014 10:31 pm

electronicboy wrote:"// Phun scene created by Phun v5.28"

Eeeerm, guuys, according to the scene he passed he is running Phun.


True, but then later he replied: Ok, I reinstalled everythig with the latest version and this time, the teleportation worked"
User avatar
Xray
 
Posts: 501
Joined: Sun Jun 17, 2012 6:12 am
Location: USA


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 6 guests