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

Post your tutorials here.

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

Postby niffirg1 » Fri Sep 04, 2009 3:23 am

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
Last edited by niffirg1 on Mon Sep 07, 2009 4:46 am, edited 4 times in total.
User avatar
niffirg1
 
Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

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

Postby thebeech » Fri Sep 04, 2009 12:45 pm

thanks niffrig :) i understood variables before but not mouse control :) made the car :)
Image
thebeech
 
Posts: 241
Joined: Mon Aug 31, 2009 8:32 pm
Location: Your Hardrive

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

Postby Laraso » Fri Sep 04, 2009 1:47 pm

You didn't type anything about key binding.
Phundamentalist... When possible!
Image
User avatar
Laraso
 
Posts: 241
Joined: Tue Sep 01, 2009 12:54 am
Location: What are you, a stalker?

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

Postby niffirg1 » Sat Sep 05, 2009 12:25 am

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

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

Postby Way2crazy » Sat Sep 26, 2009 4:56 am

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?
Thymer... Sorta :/

Like my avatar? Google it: gif it's pretty cool, just get the original sorce and put it for the URL of a pic like this:
http://www.imitationpickles.org/galcon/ ... /zarah.gif
Image
Image
neeed more help? Pm me :^)

My site/forum:
http://way2crazy.iforums.us/

Image


^a ninja was here
User avatar
Way2crazy
 
Posts: 20
Joined: Mon Sep 21, 2009 4:38 am

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

Postby niffirg1 » Sat Sep 26, 2009 5:26 am

Rating: rated 6.1
Filesize: 59.25 kB
Comments: 3
Ratings: 3
download

Here look at the scripts for this
User avatar
niffirg1
 
Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

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

Postby kilebantick » Sat Sep 26, 2009 1:00 pm

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

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

Postby Way2crazy » Fri Oct 02, 2009 12:56 am

ok but to bind an arrow key would it be the same?
Thymer... Sorta :/

Like my avatar? Google it: gif it's pretty cool, just get the original sorce and put it for the URL of a pic like this:
http://www.imitationpickles.org/galcon/ ... /zarah.gif
Image
Image
neeed more help? Pm me :^)

My site/forum:
http://way2crazy.iforums.us/

Image


^a ninja was here
User avatar
Way2crazy
 
Posts: 20
Joined: Mon Sep 21, 2009 4:38 am

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

Postby niffirg1 » Fri Oct 02, 2009 2:10 am

Not Excactly, No
User avatar
niffirg1
 
Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

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

Postby simey j dude » Thu May 06, 2010 2:41 am

how do you make it so the mouse control follows when you move your mouse up and down?
User avatar
simey j dude
 
Posts: 61
Joined: Sat Sep 05, 2009 3:11 am
Location: under your bed!

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

Postby Mystery » Thu May 06, 2010 9:45 am

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.
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

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

Postby Blackonyx2234 » Sun Jan 02, 2011 12:22 am

How do you make something follow another geometry other than a mouse?
What is the script?
I am trying to create a GUided rocket
live to learn
learn to survive
survive to eventually die successful
User avatar
Blackonyx2234
 
Posts: 24
Joined: Sun Jan 31, 2010 5:12 am

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

Postby FuzzyLogicBrain » Tue Feb 01, 2011 3:12 pm

8-) Can I make a bind a so that when it is not pressed, it is acivated?
Image
these guys are awesome. <- full stop
User avatar
FuzzyLogicBrain
 
Posts: 315
Joined: Mon Jan 31, 2011 7:48 pm
Location: when online, on the computer. when not, probably on it anyways. ;D lulz


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests

cron