User:Legend26/Test: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Flurite
>Legend26
(→‎Operators: change Vector3 -> Vector3int16)
 
(24 intermediate revisions by 4 users not shown)
Line 1: Line 1:
*Work in progress. When it's done I'll release it.
=Vector3int16=
*If you find something wrong, have some edit to make, or a way to make it easier to read, go ahead and edit this. It's a wiki after all.
{{Map|Scripting|Data Types}}
*Article will be named "Beginner's Guide to String Patterns" when finished or something similar.
__TOC__ <!-- TOC should be below the Map template. -->


==What are String Patterns?==
{{type|Vector3int16}} is a variant of the {{type|Vector3}} datatype. {{type|Vector3int16}}, as its name implies, is a type whose coordinates are stored as 16 bit signed integers. What does this mean? It means that the coordinates of a {{type|Vector3int16}} must be in the range of -32767 to 32767. Additionally, the {{type|Vector3int16}} datatype is stripped down in terms of functionality. Currently, it is exclusively used for creating a {{type|Region3int16}} which in turn is used for using some of the {{type|instance=Terrain|terrain}} object's methods.
String patterns are, in essence, just [[String|strings]]. What makes them different from ordinary strings then, you ask? String patterns are strings that use a special combination of characters. These characters combinations are generally used with functions in the string library such as 'string.match' and 'string.gsub' to do special things with strings. For instance, with string patterns you can do something like this:


<pre>
==[[Constructors]]==
local s = "I am a string!"
{| class="wikitable"
for i in string.gmatch(s, "[^%s]+") do --Where "[^%s]+" is the string pattern.
! Constructor !! Description
    print(i)
|-
end
| Vector3int16.new(<var>x</var>, <var>y</var>, <var>z</var>) || Creates a new {{type|Vector3int16}} using coordinates <var>x</var>, <var>y</var>, <var>z</var>.
|}


Output:
== Methods ==
I
Unlike the {{type|Vector3}} datatype, {{type|Vector3int16}} does not have any known methods.
am
a
string!
</pre>


But what makes the code above so cool? Perhaps you've wanted to make a list of people without using a [[Tables|table]], or maybe you need to [[Text_Parsing_Tutorial|parse]] a string. String patterns can help do this!
== Properties ==
All of these properties are Read Only (you can't just set them Vector3int16.x = 5, it doesn't work) but you can create new vectors with such changes, or apply an operation, seen in the next section.


==The Basics of String Patterns==
{| class="wikitable"
As said before, string patterns are strings that look a little different and are used for a different purpose than what strings are usually used for. Here we will look at the basics of just what make a string pattern up. Here we will look at just what the different parts of a string pattern mean.
! Property !! Type !! Description
|-
| Vector3int16.'''x''' || {{type|number}} || The x-coordinate
|-
| Vector3int16.'''y''' || {{type|number}} || The y-coordinate
|-
| Vector3int16.'''z''' || {{type|number}} || The z-coordinate
|}


===Character Classes===
== Operators ==
Character classes in string patterns stand for a range or set of characters. Let's look at the classes listed below.
Unlike {{type|Vector3}}, you can only operate on a {{type|Vector3int16}} with another {{type|Vector3int16}}.


*%a
{| class="wikitable"
:*This character class represents all letters no matter if they're lowercase or uppercase.
! Operator !! Description
:*Some examples are: 'a', 'd', 'F', and 'G'.
|-
| {{type|Vector3int16}} + {{type|Vector3int16}} || returns Vector3int16 translated (slid) by Vector3int16
|-
| {{type|Vector3int16}} - {{type|Vector3int16}} || returns Vector3int16 translated (slid) by -Vector3int16 (also gives relative position of 1 to the other)
|-
| {{type|Vector3int16}} * {{type|Vector3int16}} || returns Vector3int16 with each component multiplied by corresponding component
|-
| {{type|Vector3int16}} / {{type|Vector3int16}} || returns Vector3int16 with each component divided by corresponding component
|}


*%l
== See Also ==
:*This character class represents all lowercase letters.
* [[Vector3]]
:*Some examples are: 'a', 'd', 'f', and 'g'.
* [[Region3]]
 
*%u
:*This character class represents all uppercase letters.
:*Some examples are: 'A', 'B', 'D', and 'Z'.
 
*%p
:*This character class represents all punctuation characters.
:*Some examples are: ".", "?", "+", and "/".
 
*%w
:*This character class represents all alphanumeric letters.
::*This means that this class encompasses both letters and numbers.
:*Some examples are 'A',  'f', '3', and '7'.
 
*%s
:*This character class represents all space characters.
:*Some examples are ' ', '\n', and '\r'
 
*%c
:*This character class represents all control characters.
:*Control characters are characters with an ASCII code below 32 and also ASCII code 127
:*Control characters are all non-printing meaning that they don't represent a symbol representation.
 
*%x
:*This character class represents all hexadecimal (Base 16) characters.
:*Some examples are '21' which represents '!' and '5A' which represents 'Z'
 
*%z
:*This character class represents the character '\0'.
:*This character is commonly referred to as NUL.
 
*The dot character class
:*This class is represented by a single dot '.'
:*This class represents all characters, every single one.
:*Unlike the others, it is not preceded by a '%' sign.
 
 
As you can see, each of the character classes are used to represent a set of characters. Now let's look at some just some of the many things we can do with just these character classes.
 
== Examples ==  
 
A common way of using these string patterns are using them with string functions. Here's an example:
 
{{Example|
<pre>
string = "12:47"
for i in string.gmatch(string, "%p") do
print(p)
end
 
Output:
":"
</pre>
}}
 
==See also==
*[[Function_Dump/String_Manipulation|String Manipulation]]

Latest revision as of 18:45, 23 April 2012

Vector3int16

Vector3int16 is a variant of the Vector3 datatype. Vector3int16, as its name implies, is a type whose coordinates are stored as 16 bit signed integers. What does this mean? It means that the coordinates of a Vector3int16 must be in the range of -32767 to 32767. Additionally, the Vector3int16 datatype is stripped down in terms of functionality. Currently, it is exclusively used for creating a Region3int16 which in turn is used for using some of the terrain object's methods.

Constructors

Constructor Description
Vector3int16.new(x, y, z) Creates a new Vector3int16 using coordinates x, y, z.

Methods

Unlike the Vector3 datatype, Vector3int16 does not have any known methods.

Properties

All of these properties are Read Only (you can't just set them Vector3int16.x = 5, it doesn't work) but you can create new vectors with such changes, or apply an operation, seen in the next section.

Property Type Description
Vector3int16.x number The x-coordinate
Vector3int16.y number The y-coordinate
Vector3int16.z number The z-coordinate

Operators

Unlike Vector3, you can only operate on a Vector3int16 with another Vector3int16.

Operator Description
Vector3int16 + Vector3int16 returns Vector3int16 translated (slid) by Vector3int16
Vector3int16 - Vector3int16 returns Vector3int16 translated (slid) by -Vector3int16 (also gives relative position of 1 to the other)
Vector3int16 * Vector3int16 returns Vector3int16 with each component multiplied by corresponding component
Vector3int16 / Vector3int16 returns Vector3int16 with each component divided by corresponding component

See Also