Page 1 of 1

Mouse Clicking

PostPosted: Mon Sep 07, 2009 4:59 am
by Blazemann
I have looked through Grady's stuff, but I cannot find out how to make a click do anything. Like in Versieon's Physics Scene for instance.

Re: Mouse Clicking

PostPosted: Mon Sep 07, 2009 5:48 am
by niffirg1
Ok.... Do you want like a hinge controlled by a click or a box that can tell that it has been clicked like in this scene:
Image
Author: Niffirg1
Title: Ragdoll Avalanche Ultimate
File Size: 15.22 kB
Rating: Image
ImageImage
I could Help with both.
If you want the simulation to know that the Mouse has gone into a certain postion then
Code: Select all
  {(app.mousepos(0) >= Bla  && app.mousepos(0) <= bla) && (app.mousepos(1) >= bla && app.mousepos(1) <= bla)} ? {Bla } : {bla}

Insert t what you need into the Bla's like the mouse position on the x axis or the y-axis or the reaction.
Hope this was of some help to you

Re: Mouse Clicking

PostPosted: Mon Sep 07, 2009 7:03 am
by Blazemann
Yes thankyou. Now, I might find this myself, but jsut incase, how does the x-y axis work in Algodoo? How do you know where is where(coordinate wise)

Re: Mouse Clicking

PostPosted: Mon Sep 07, 2009 7:03 am
by Blazemann
Yes thankyou. Now, I might find this myself, but jsut incase, how does the x-y axis work in Algodoo? How do you know where is where(coordinate wise)

Re: Mouse Clicking

PostPosted: Mon Sep 07, 2009 8:35 am
by kilebantick
Double post.

You know how grid's work right? [0, 0] is the center of the cartesian plane, [1, 0] is directly on the Y line, but to the left of the centre, [0, 1] is on the X line, but up 1. Hard to explain, but this is basically how it all works. [0, 0] is the very centre of gun :)
If you have done maths in school, this should be no problem at all :)


For future referance, pos(0) is the X axis, and pos(1) is the Y axis :-)

Re: Mouse Clicking

PostPosted: Mon Sep 07, 2009 7:03 pm
by Versieon
How i find it is by making a box that tells me the mouse pos(app.mousepos) and then writing my script of of those positions.

Re: Mouse Clicking

PostPosted: Mon Sep 07, 2009 9:51 pm
by Blazemann
So pos is probably based on scene, and not onscreen?

Re: Mouse Clicking

PostPosted: Mon Sep 07, 2009 10:41 pm
by Versieon
True, it is based on the scene, so that your cordinates are always acurate no mater what you are viewing

Re: Mouse Clicking

PostPosted: Mon Sep 07, 2009 10:47 pm
by Blazemann
Okay, that makes it loads simpler. In your physics scene, I was worried it was otherwise.

Re: Mouse Clicking

PostPosted: Wed Sep 09, 2009 5:31 am
by niffirg1
Create a box and in the text script menu write
Code: Select all
{"" + app.mousepos}

Sorry could not answer sooner i just got a puppy and it is my responsibility to lets say collect his presents

Re: Mouse Clicking

PostPosted: Wed Sep 09, 2009 5:34 am
by standardtoaster
niffirg1 wrote:Create a box and in the text script menu write
Code: Select all
{"" + app.mousepos}

Sorry could not answer sooner i just got a puppy and it is my responsibility to lets say collect his presents

You forgot to tell him [b]where[/i] to put it. ;)

You put it in the text script box.

Re: Mouse Clicking

PostPosted: Fri Sep 11, 2009 12:08 pm
by Chronos
standardtoaster wrote:
niffirg1 wrote:Create a box and in the text script menu write
Code: Select all
{"" + app.mousepos}

Sorry could not answer sooner i just got a puppy and it is my responsibility to lets say collect his presents

You forgot to tell him [b]where[/i] to put it. ;)

You put it in the text script box.

uhh... yes he did :| read his post

and niffirg, did your puppy make algo-doo? :P (sorry, i couldnt resist)

Re: Mouse Clicking

PostPosted: Sat Sep 12, 2009 4:14 pm
by algadoodle123
if you create the code for a button,and then drag the button around, will it still be "clickable" :?:

P.S. I am new here

Re: Mouse Clicking

PostPosted: Sun Sep 13, 2009 2:30 am
by Blazemann
nope. I wish that was possible. Wait, scratch that. If you had two boxs in two corners of the button that set THIER respective x and y cooridinates to a variable, then those variables were used as the coordinates, then it might work.

Re: Mouse Clicking

PostPosted: Sun Sep 13, 2009 4:14 am
by algadoodle123
Blazemann wrote:nope. I wish that was possible. Wait, scratch that. If you had two boxs in two corners of the button that set THIER respective x and y cooridinates to a variable, then those variables were used as the coordinates, then it might work.



what code would work to input the variables as the coordinates :?:

...and that would only work for one button

What if you had a script that carry out an action when an object is selected?

Re: Mouse Clicking

PostPosted: Sun Sep 13, 2009 4:27 am
by Blazemann
I don't know of any value for selected versus unselected, but there would be the problem then of multiple selections at once.(like fast forward and rewind at the same time)

Re: Mouse Clicking

PostPosted: Sun Sep 13, 2009 5:14 am
by algadoodle123
Blazemann wrote:I don't know of any value for selected versus unselected, but there would be the problem then of multiple selections at once.(like fast forward and rewind at the same time)

good point!

edit: maybe you could have a prevention code?
selected = fast-forward ? {selected = re-wind ? {} : {code to carry out}} : {}

Re: Mouse Clicking

PostPosted: Mon Sep 14, 2009 5:51 pm
by algadoodle123
I brought up the topic of selected objects because i never could get the coordinate thing to work.

could somebody post a code for a square that is 2 by 2 meters, and in the center of the x,y coordinates
Image

Re: Mouse Clicking

PostPosted: Tue Sep 15, 2009 2:00 am
by Versieon
If you look at my Simple Physics scenes, They have a self contained clickable button that can be moved anywhere and still funtion correctly, as for a toggle, the if statement is correct

Code: Select all
{scene.my.ff == 1} ? {scene.my.ff = 0} : {scene.my.ff = 1}


This switches ff between 0 and 1.

As for a code for a button,

Code: Select all
(e)=>{{(app.mousepos(0) >= e.pos(0)) && (app.mousepos(0) <= (e.pos(0) + 0.5)) && (app.mousepos(1) >= e.pos(1)) && (app.mousepos(1) <= (e.pos(1) + 0.5))} ? {What you want to do here} : {else}}

This would go in the bottom left corner, in a mouse controlled collider.
For 2m box, change the .5 to 2

Re: Mouse Clicking

PostPosted: Tue Sep 15, 2009 3:27 am
by algadoodle123
thank you so much, versieon
i thought you were supposed to enter the code into the config, but you enlightened me to the truth
i used the click mechanism from your phun dvd player, I hope you don't mind

Re: Mouse Clicking

PostPosted: Tue Sep 15, 2009 11:57 pm
by Versieon
Not at all, just cred me if you do!!

Re: Mouse Clicking

PostPosted: Wed Sep 16, 2009 3:31 am
by algadoodle123
Versieon wrote:Not at all, just cred me if you do!!

thx