Mouse Clicking

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

Mouse Clicking

Postby Blazemann » Mon Sep 07, 2009 4:59 am

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.
User avatar
Blazemann
 
Posts: 151
Joined: Tue Sep 01, 2009 1:19 am

Re: Mouse Clicking

Postby niffirg1 » Mon Sep 07, 2009 5:48 am

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
User avatar
niffirg1
 
Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

Re: Mouse Clicking

Postby Blazemann » Mon Sep 07, 2009 7:03 am

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)
User avatar
Blazemann
 
Posts: 151
Joined: Tue Sep 01, 2009 1:19 am

Re: Mouse Clicking

Postby Blazemann » Mon Sep 07, 2009 7:03 am

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)
User avatar
Blazemann
 
Posts: 151
Joined: Tue Sep 01, 2009 1:19 am

Re: Mouse Clicking

Postby kilebantick » Mon Sep 07, 2009 8:35 am

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 :-)
Image
User avatar
kilebantick
 
Posts: 1267
Joined: Tue Sep 01, 2009 9:50 am

Re: Mouse Clicking

Postby Versieon » Mon Sep 07, 2009 7:03 pm

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.
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm

Re: Mouse Clicking

Postby Blazemann » Mon Sep 07, 2009 9:51 pm

So pos is probably based on scene, and not onscreen?
User avatar
Blazemann
 
Posts: 151
Joined: Tue Sep 01, 2009 1:19 am

Re: Mouse Clicking

Postby Versieon » Mon Sep 07, 2009 10:41 pm

True, it is based on the scene, so that your cordinates are always acurate no mater what you are viewing
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm

Re: Mouse Clicking

Postby Blazemann » Mon Sep 07, 2009 10:47 pm

Okay, that makes it loads simpler. In your physics scene, I was worried it was otherwise.
User avatar
Blazemann
 
Posts: 151
Joined: Tue Sep 01, 2009 1:19 am

Re: Mouse Clicking

Postby niffirg1 » Wed Sep 09, 2009 5:31 am

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
User avatar
niffirg1
 
Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

Re: Mouse Clicking

Postby standardtoaster » Wed Sep 09, 2009 5:34 am

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.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Mouse Clicking

Postby Chronos » Fri Sep 11, 2009 12:08 pm

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)
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: Mouse Clicking

Postby algadoodle123 » Sat Sep 12, 2009 4:14 pm

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
**/\ /\
>( ' ; ' )<***<---------- cat
*((")("))
i'm right-side-up
uʍop-ǝpısdn ɯ,ı
http://www.sherv.net/flip.html
User avatar
algadoodle123
 
Posts: 66
Joined: Tue Sep 08, 2009 6:04 pm

Re: Mouse Clicking

Postby Blazemann » Sun Sep 13, 2009 2:30 am

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.
User avatar
Blazemann
 
Posts: 151
Joined: Tue Sep 01, 2009 1:19 am

Re: Mouse Clicking

Postby algadoodle123 » Sun Sep 13, 2009 4:14 am

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?
**/\ /\
>( ' ; ' )<***<---------- cat
*((")("))
i'm right-side-up
uʍop-ǝpısdn ɯ,ı
http://www.sherv.net/flip.html
User avatar
algadoodle123
 
Posts: 66
Joined: Tue Sep 08, 2009 6:04 pm

Re: Mouse Clicking

Postby Blazemann » Sun Sep 13, 2009 4:27 am

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)
User avatar
Blazemann
 
Posts: 151
Joined: Tue Sep 01, 2009 1:19 am

Re: Mouse Clicking

Postby algadoodle123 » Sun Sep 13, 2009 5:14 am

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}} : {}
**/\ /\
>( ' ; ' )<***<---------- cat
*((")("))
i'm right-side-up
uʍop-ǝpısdn ɯ,ı
http://www.sherv.net/flip.html
User avatar
algadoodle123
 
Posts: 66
Joined: Tue Sep 08, 2009 6:04 pm

Re: Mouse Clicking

Postby algadoodle123 » Mon Sep 14, 2009 5:51 pm

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
**/\ /\
>( ' ; ' )<***<---------- cat
*((")("))
i'm right-side-up
uʍop-ǝpısdn ɯ,ı
http://www.sherv.net/flip.html
User avatar
algadoodle123
 
Posts: 66
Joined: Tue Sep 08, 2009 6:04 pm

Re: Mouse Clicking

Postby Versieon » Tue Sep 15, 2009 2:00 am

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
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm

Re: Mouse Clicking

Postby algadoodle123 » Tue Sep 15, 2009 3:27 am

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
**/\ /\
>( ' ; ' )<***<---------- cat
*((")("))
i'm right-side-up
uʍop-ǝpısdn ɯ,ı
http://www.sherv.net/flip.html
User avatar
algadoodle123
 
Posts: 66
Joined: Tue Sep 08, 2009 6:04 pm

Re: Mouse Clicking

Postby Versieon » Tue Sep 15, 2009 11:57 pm

Not at all, just cred me if you do!!
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm

Re: Mouse Clicking

Postby algadoodle123 » Wed Sep 16, 2009 3:31 am

Versieon wrote:Not at all, just cred me if you do!!

thx
**/\ /\
>( ' ; ' )<***<---------- cat
*((")("))
i'm right-side-up
uʍop-ǝpısdn ɯ,ı
http://www.sherv.net/flip.html
User avatar
algadoodle123
 
Posts: 66
Joined: Tue Sep 08, 2009 6:04 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron