How To Increase and Decrease Vector3 Values: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Pspdude40
Page Creation
>Mindraker
Yes, we all 'have to be experienced scripters' to understand 'your complicated tutorial'.
Line 1: Line 1:
{{CatUp|Tutorials}}
__TOC__
__TOC__


== Introduction ==


This tutorial will tell you how to increase and decrease Vector3 values. This will be quite a benefit to your scripts, and will make them more popular if you have them.


=Intro and Notes=
==Adding Vector3 Values==


==Intro==
This will show you how to add or subtract 3 vector3 numbers. The stuff below will be quite interesting to you if you want to add or subtract Vector3 Values.
 
So, you do know how to increase and decrease Vector3 Values, right? Now, this tutorial will tell you how to increase and dcrease them! This will be quite a benefit to your scripts, and will make them more popular if you have them!
 
==Notes==
 
Please note that you need to be an experienced scripter in order to understand this tutorial. If you aren't, then you won't understand anything. View one of the basic tutorials before reading on. If you're experienced, contuine reading on if you want to do it someday!
 
 
 
=Adding Vector3 Values=
 
This will show you how to add or subtract 3 vector3 numbers! The stuff below will be quite interesting to you if you want to add or subtract Vector3 Vaules!


First, insert a Vector3Value. Once you have that done, change the value to 15, 15, 15.
First, insert a Vector3Value. Once you have that done, change the value to 15, 15, 15.


Then, insert a script. Make the script's parent the Vector3Value.
Then, insert a script. Make the script's parent the Vector3Value.


==Scripting==
==Scripting==


Once those parts are done, open the script. I'll try to make it as detailed as possible. First, we need to identify the value we want to change. So put in this.
Once those parts are done, open the script. First, we need to identify the value we want to change. So put in this.


<pre>
<pre>
Line 38: Line 28:
</pre>
</pre>


Good! So far, so good! We currently have 2 lines done! Let's look at our progress...
Let's look at our progress:


<pre>
<pre>
Line 53: Line 43:
</pre>
</pre>


Altough we have the 3 seperate numbers, we still haven't added or subtracted them yet. In order to do that, you just have to add and subtract it like you do with regular numbers.
Although we have the 3 seperate numbers, we still haven't added or subtracted them yet. In order to do that, you just have to add and subtract it like you do with regular numbers.


<pre>
<pre>
Line 61: Line 51:
</pre>
</pre>


Now we have the new x, y, and z. Let's take a look at what we have so far!
Now we have the new x, y, and z. Let's take a look at what we have so far:


<pre>
<pre>
Line 74: Line 64:
</pre>
</pre>


But it's not over yet. The 3 single values have changed, but not the Vector3Value. In order to do that, we need to insert this line...
The 3 single values have changed, but not the Vector3Value. In order to do that, we need to insert this line:


<pre>
<pre>
Line 80: Line 70:
</pre>
</pre>


Now the value has changed. But how will we know? We just need to put in another line. Make sure you have output up first...
Now the value has changed. But how will we know? We just need to put in another line. Make sure you have output up first:


<pre>
<pre>
Line 86: Line 76:
</pre>
</pre>


The script is complete! Let's just look at the finished script...
The script is complete! Let's just look at the finished script:


<pre>
<pre>
Line 104: Line 94:




=Subtracting Vector3 Values=
==Subtracting Vector3 Values==




We've added them, but we now subtract them! Subtracting them is just like adding them, only we edit 3 lines. If it was exactly the same, then what's the point?
We've added them, but we now subtract them! Subtracting them is just like adding them, only we edit 3 lines.  


<pre>
<pre>
Line 115: Line 105:
</pre>
</pre>


Now, let's take a look at that edit in the full script...
Now, let's take a look at that edit in the full script:


<pre>
<pre>
Line 132: Line 122:
Output should say 10, 10, 10. You're done with subtracting them!
Output should say 10, 10, 10. You're done with subtracting them!


 
[[Category:Scripting Tutorials]]
 
=Conclusion=
 
 
You just added and subtracted Vector3 Values! What's next? Well, I don't know. Go to another tutorial if you want to!
 
[[category:Tutorials]]

Revision as of 21:18, 23 August 2008

Introduction

This tutorial will tell you how to increase and decrease Vector3 values. This will be quite a benefit to your scripts, and will make them more popular if you have them.

Adding Vector3 Values

This will show you how to add or subtract 3 vector3 numbers. The stuff below will be quite interesting to you if you want to add or subtract Vector3 Values.

First, insert a Vector3Value. Once you have that done, change the value to 15, 15, 15.

Then, insert a script. Make the script's parent the Vector3Value.

Scripting

Once those parts are done, open the script. First, we need to identify the value we want to change. So put in this.

local value = {script.Parent.Value}

The value is whatever value you put. Next, we need to put an i = 1 part. I don't know why we have to do this, but we have to.

local i = 1

Let's look at our progress:

local value = {script.Parent.Value}
local i = 1

Since we have those 2 lines down, we now can tamper into the x, y, and z of the Vector3 Value. Let's say we want to add 5 to the value. Put in these lines...

local x = value[i].x
local y = value[i].y
local z = value[i].z

Although we have the 3 seperate numbers, we still haven't added or subtracted them yet. In order to do that, you just have to add and subtract it like you do with regular numbers.

x = x + 5
y = y + 5
z = z + 5

Now we have the new x, y, and z. Let's take a look at what we have so far:

local value = {script.Parent.Value}
local i = 1
local x = value[i].x
local y = value[i].y
local z = value[i].z
x = x + 5
y = y + 5
z = z + 5

The 3 single values have changed, but not the Vector3Value. In order to do that, we need to insert this line:

script.Parent.Value = Vector3.new(x,y,z)

Now the value has changed. But how will we know? We just need to put in another line. Make sure you have output up first:

print(script.Parent.Value)

The script is complete! Let's just look at the finished script:

local value = {script.Parent.Value}
local i = 1
local x = value[i].x
local y = value[i].y
local z = value[i].z
x = x + 5
y = y + 5
z = z + 5
script.Parent.Value = Vector3.new(x,y,z)
print(script.Parent.Value)

Output should say 20, 20, 20. You're done!


Subtracting Vector3 Values

We've added them, but we now subtract them! Subtracting them is just like adding them, only we edit 3 lines.

x = x - 5
y = y - 5
z = z - 5

Now, let's take a look at that edit in the full script:

local value = {script.Parent.Value}
local i = 1
local x = value[i].x
local y = value[i].y
local z = value[i].z
x = x - 5
y = y - 5
z = z - 5
script.Parent.Value = Vector3.new(x,y,z)
print(script.Parent.Value)

Output should say 10, 10, 10. You're done with subtracting them!