rikkiJoin Date: 2007-10-21 Post Count: 987 |
dang it!!! I just can't seem to understand the tutorials...could someone plz plz PLZ simplify them for me? gah!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! i,m so frustrated!!!
p.s. I have 4 other help messages...=( this is sooooo dumb... |
|
DXiskingJoin Date: 2007-10-13 Post Count: 56 |
waht ru talking about? |
|
TehGeekJoin Date: 2007-08-02 Post Count: 70 |
If you cant understand the tutorials, Then there is almost just no hope for you. :p
keep reading and experment with them, add lines of code to your script from other scripts, or Edit scripts, And DONT start making huge giant scripts on day 1. start simple. |
|
bigbrainkidTop 100 PosterJoin Date: 2007-05-05 Post Count: 2618 |
well scripting is the act of using the programming launguage to make and edit events in a virtual world. Like sertain programs do certain things, cretain scripts do certain things. If you misstype a script we call it a faulty or incoorect script. there simplified 1st tuteral or at least a simplified version of mine. |
|
tottiJoin Date: 2006-11-02 Post Count: 2684 |
Hey,
Many users still don't know how to write one line of script. Even though the wiki has info, I'll show some basic lessons for scripting. There are 5 topics that will be answered:
Creating the script
Tagging objects
The listening event
The function
Modifying objects/tags
NOTE: I strongly recommend doing all work, building and scripting, in Edit Mode. All these lessons will be shown as if you are in Edit Mode. To open Edit Mode, on your desktop screen, hit Start>Programs>ROBLOX>ROBLOX Studio. Then go to your profile, then click "Edit".
___________________________________________________________________________
Lesson 1: Creating the script
What work to be done when you don't have the project? To get a script, simply select Insert>Object. Now a window will show up. In the textbox, type "Script". Do not mispell, and make sure that the first letter is in capital. You should find the script inside"Workspace" in the explorer tab. If you don't see any explorer window up, go to View>Explorer.
Now to open the script, just double-click it. If you did it right, a window will cover the whole ingame screen, and the browser should look a bit more like Microsoft Word. And you will find the line "print("Hello World!")"(Don't ask me why, long story). Before you start, just go ahead and delete that line.
___________________________________________________________________________
Lesson 2: Tagging objects
You got a nice script up, but what good is a script if it doesn't have anything to play with? Assuming the script is still under Workspace, that is where your script will run under. Let's say you want a brick turning invisible/visible, back and forth when touched. That's a good starter on showing your powers of scripting. The script needs to know where that brick is before modifying it.
Now, tagging objects are not necessary, but it can make scripting alot less work. Now here's an example of tagging objects:
brick = game.Workspace.Brick
That will tag the brick under the name you assigned. You can set the name to anything, even "noob", lol. And you can have as many tags as you want, not limited to one, you know.
Now, if you didn't tag it, everytime you try making the script modify the object (explained in lesson 5), you would have to put the line "game.Workspace.Brick" EVERY single time. Not fun. Tags are the way to go, since you'd only have to put the name you assigned. Less time, more fun. Make sure you name the brick desired to something other than "Part" or "Smooth Block Model". Scripts have a hard time picking bricks you want if every brick in the same category has the same name.
So let's start basic. Name the brick desired to "Brick", and tag it in the script by typing the example above.
___________________________________________________________________________
Lesson 3: The listening event
Now we're getting into the meat of scripting. Sure, the script knows where the brick is, but that's all. I can't do anything else. Now we're jumping into a listening event.
What is a listening event? It's the trigger of the script. This is gonna tell the script to do something if the listener finds the trigger fired. This is one important part of the script, otherwise you couldn't really make scripts wait for anything.
Now, you still should have the script with the tag in it, right? Now, for a starter, we're gonna make the script listen for being touched. Here's an example:
brick.Touched:connect(onTouch)
Let's put it this way: If the brick is Touched, It will connect the (function). The function is explained next lesson. Keep in mind that the name inside the parentheses are the name of the function. You can name this anything, however, I recommend doing the above for this lesson before you jump into any other names.
This is not the only listener type. there are many more to use, some of which require some familiarity with scripting. Here's a very well-done reference page set up by MrDoomBringer:
http://wiki.roblox.com/index.php?title=Class_reference
This is where you can find more help in the future, when you begin to understand scripting more. Not only does it show Events, but also shows other scripting references need for other aspects of scripting (some of which is explained in lesson 5.
So for this lesson, put the line "brick.Touched:connect(onTouch)" a line or two below the tag from last lesson.
___________________________________________________________________________
Lesson 4: The function
Your script is getting better and better, but where is the function at? You're script will break if it doesn't have one of those for the listener to refer the script to.
What is a function? It is where all your modifying work will be done. It is also an important part to your scripting. Without it, you could not make the script modify objects from listeners. Another example:
function onTouch(part)
end
There's the almighty function. as you can see, the function has "onTouch". Yep, the listener from last lesson is trying to refer to the function. Basically, the listener's gonna tell the script to run through this function and do whatever is found inside (explained next lesson). notice after "onTouch". This is the tag of the object that the listener found that touched the brick. This is not always needed, especially for different listeners. Most times, with other listening types unlike touching listeners, you would just place this:
function onTouch()
end
But back to what we're looking at. The tag is the object that touched the brick. You can play with this object for fun later. Now notice also two liens below the function: "end". You will need one of these for every funcion and other aspect of scripting, such as "if" statements. Always remember this when scripting.
Now, make the lines from first example, except put it two lines under the tag, and one line above the listener.
___________________________________________________________________________
Lesson 5: Modifying objects/tags
We're almost there. The script knows the brick, will wait until it's touched, and has the function to use. But it doesn't know what to do to the brick.
Time to have fun. Now this is where tagging objects saves you time. We wanted it to flicker invisible/visible, right? Now to pull that feat off! Here's an example:
brick.Transparency = 1
wait(1)
brick.Transparency = 0
These lines will alter the brick as we wanted. The brick's transparency is changed to "1", which is completely invisible. The "wait(1)" line will make the script wait for one second before continuing, then the brick's transparency will be put back at 0, which is completely visible. You can alter "wait(1)" to any number inside the parenthesis. Whatever number you put inside the parenthesis will be the amount of time it will wait in seconds.
Now, put those 3 lines right under the line "function onTouch(part)" and above the line "end".
___________________________________________________________________________
Now if you did everything as explained in this tutorial, you're gonna have your very first working home-made script! There are many more aspects of scripting to play with, but you must become more familiar with scripting. Here's how:
http://wiki.roblox.com/index.php?title=Class_reference
Enjoy, and I hope this thread that took 1 hour to make helped you! =D
>Pilot<
(Dug up by me!)
Totti |
|
cruckshankTop 100 PosterJoin Date: 2007-07-10 Post Count: 1936 |
lol u were lazy and copy and pasted that lol |
|
tottiJoin Date: 2006-11-02 Post Count: 2684 |
Duh...I am wayyy to lazy to make my own xD
Totti |
|
cruckshankTop 100 PosterJoin Date: 2007-07-10 Post Count: 1936 |
Duh u got that hat from begging tealmon lol |
|
tottiJoin Date: 2006-11-02 Post Count: 2684 |
Naw...I didn't bug him at all
Totti |
|
|
|
local p = Instance.new("Part")
p.Anchored = true
p.BrickColor = BrickColor.Green()
p.formFactor = "Symmetric"
local nogo = false
for x_for = -5, 5 do
for z_for = -5, 5 do
nogo = false
local x = x_for * 50
local z = z_for * 50
local c = p:clone()
c.Size = Vector3.new(50, math.random(1, 25), 50)
c.Position = Vector3.new(x, c.Size.y / 2, z)
if c.Size.y <= 5 then
nogo = true
c.Size =Vector3.new(50, 5, 50)
c.Color = Color3.new(0, 0, 255)
c.CanCollide = false
c.Transparency = 0.25
c.Position = Vector3.new(x, c.Size.y / 2, z)
end
if math.random(1, 25) == 15 and nogo == false then
nogo = true
c.BrickColor = BrickColor.new(0)
for mountain_height = 0, 15 do
local mountain_segment = p:clone()
mountain_segment.BrickColor = BrickColor.new(0)
mountain_segment.Size = Vector3.new(50 - mountain_height * 3, 5, 50 - mountain_height * 3)
mountain_segment.Position = Vector3.new(x, c.Size.y + 2.5, z) + Vector3.new(0, mountain_height * 5, 0)
mountain_segment.Parent = game.Workspace
wait()
end
end
if math.random(1, 10) == 5 and nogo == false then
nogo = true
local trunk = p:clone()
trunk.BrickColor = BrickColor.new(192)
trunk.Size = Vector3.new(5, 15, 5)
trunk.Position = Vector3.new(x, c.Size.y + 15 / 2, z)
trunk.Parent = game.Workspace
wait()
local leaves = p:clone()
leaves.BrickColor = BrickColor.new(141)
leaves.Size = Vector3.new(30, 15, 30)
leaves.Position = Vector3.new(x, c.Size.y + 15 + 15 / 2, z)
leaves.Parent = game.Workspace
end
if math.random(1, 5) == 3 and nogo == false then
nogo = true
c.BrickColor = BrickColor.new(0)
end
if math.random(1, 5) == 3 and nogo == false then
nogo = true
c.BrickColor = BrickColor.new(37)
end
c.Parent = game.Workspace
wait()
end
end
[NEXT]
http://www.roblox.com/Forum/ShowPost.aspx?PostID=12203471 |
|