Page 1 of 1

Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Fri Sep 04, 2009 3:23 am
by niffirg1
Custom Variables
Brief Explaination
A variable is something that holds a value, alphanumeric in general, used to store information, and vital in programming languages (otherwise your programming language wouldn't work very well, or would have to use another to help). (Gradfitz Explanation)
Creating a Variable
1. First open up the console by pressing ~ or the tilde key
2.Type in Scene.my.Var = 0
3.0 is the value of which the variable is set to
4.Doesnt have to scene.my.var, Can be scene.my.hasdfl. Can be anything as long as it is scene.my.
5.Use that Variable to do any thing (Not Literally of course)
6. Use it to Control MotorSpeed, Spring length, counters, etc.
Here is a Video Tutorial on Custom Variable and Key binding

[youtube]UQBBse72DAY[/youtube]
If Statements
Explaination
An if statement is if this happens than this will happen as a result
Creating an If statement
1.Create a Fast colliding Object like a probe
2.Type {scene.my.var == 10} ? {scene.my.hasdfl = 129} : {} in the oncollide menu of the Probe
3.This Says that is Scene.my.var gets to the value ten then as a result scene.my.hasdfl is set equal to the value 129
4. Use this in what ever way you want
Mouse Control
Mouse Controlled Hinge
Mouse Control can be helpful in many ways. Like Video Games
Creating a Mouse Controlled Hinge
1.Go into the Console and type scene.my.pos = [0,0] and hit enter
2.Create a Probe or fast colliding object
3.In the oncollide of that probe type scene.my.pos = e.pos
4.Create a simple Car and put the Probe on the car
5.In the script menu of the Car hinges type in th motorspeed space -{app.mousepos(0) - scene.my.pos(0)}
6. The car will now Follow the Mouse

Re: Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Fri Sep 04, 2009 12:45 pm
by thebeech
thanks niffrig :) i understood variables before but not mouse control :) made the car :)

Re: Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Fri Sep 04, 2009 1:47 pm
by Laraso
You didn't type anything about key binding.

Re: Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Sat Sep 05, 2009 12:25 am
by niffirg1
Laraso wrote:You didn't type anything about key binding.

It was in the Video also for a written tutorial check this link http://www.phunland.com/forum/viewtopic.php?id=8778

Re: Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Sat Sep 26, 2009 4:56 am
by Way2crazy
yes, but that only makes a set point in withch the farther away from the spot, the faster the hinges, how do you make it stop at your mouse?

Re: Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Sat Sep 26, 2009 5:26 am
by niffirg1
Rating: rated 6.1
Filesize: 59.25 kB
Comments: 3
Ratings: 3
download

Here look at the scripts for this

Re: Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Sat Sep 26, 2009 1:00 pm
by kilebantick
As to your mouse control, it makes no difference, but i put all of the stuff you put in your hinges, into the oncollide section. You may also point out that it will work differently depending on how big the objects are. Good tut

Re: Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Fri Oct 02, 2009 12:56 am
by Way2crazy
ok but to bind an arrow key would it be the same?

Re: Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Fri Oct 02, 2009 2:10 am
by niffirg1
Not Excactly, No

Re: Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Thu May 06, 2010 2:41 am
by simey j dude
how do you make it so the mouse control follows when you move your mouse up and down?

Re: Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Thu May 06, 2010 9:45 am
by Mystery
app.mousepos is a integrated variable that will show the known location of the mouse.
app.mouse(1) is the Y axis (I.E Up and down)
using this we can make a code to make your object behave differently to the height of the mouse
Code: Select all
{app.mousepos(1) >= e.pos(0)}?{scene.my.motor = true}:{scene.my.motor = false}

So in plain English.
If the mouse is higher then my current location, turn the motor on, otherwise turn it off.

To make the script more personalized i would actually need to see the scene.

Re: Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Sun Jan 02, 2011 12:22 am
by Blackonyx2234
How do you make something follow another geometry other than a mouse?
What is the script?
I am trying to create a GUided rocket

Re: Custom Variables, Key binds,If Statements, and Mouse Control

PostPosted: Tue Feb 01, 2011 3:12 pm
by FuzzyLogicBrain
8-) Can I make a bind a so that when it is not pressed, it is acivated?