Welcome, Guest |
You have to register before you can post on our site.
|
Forum Statistics |
» Members: 8,079
» Latest member: seanac11
» Forum threads: 10,350
» Forum posts: 91,276
Full Statistics
|
Online Users |
There are currently 233 online users. » 0 Member(s) | 231 Guest(s) Bing, Google
|
Latest Threads |
I'm leaving the site too....
Forum: 2DWorlds Discussion
Last Post: Jacob_
07-03-2023, 04:59 AM
» Replies: 12
» Views: 6,414
|
hi there.
Forum: 2DWorlds Discussion
Last Post: Jacob_
01-03-2020, 04:30 AM
» Replies: 1
» Views: 775
|
obroke
Forum: Current Games
Last Post: FrancisSah
09-06-2017, 10:11 AM
» Replies: 0
» Views: 20,546
|
fcouldn't
Forum: Current Games
Last Post: FrancisSah
09-06-2017, 09:02 AM
» Replies: 0
» Views: 8,256
|
qhow
Forum: Current Games
Last Post: PhilipShums
09-06-2017, 07:25 AM
» Replies: 0
» Views: 2,141
|
zstone
Forum: Current Games
Last Post: TimothyTox
09-06-2017, 07:03 AM
» Replies: 0
» Views: 1,010
|
vbit
Forum: Current Games
Last Post: FrancisSah
09-06-2017, 03:00 AM
» Replies: 0
» Views: 985
|
sildenafil 100 mg sandoz
Forum: Current Games
Last Post: RichardLen
09-06-2017, 12:28 AM
» Replies: 0
» Views: 1,203
|
mhis
Forum: Current Games
Last Post: TimothyTox
09-05-2017, 04:09 PM
» Replies: 0
» Views: 1,009
|
sildenafil citrate 100mg ...
Forum: Current Games
Last Post: Waltertog
09-05-2017, 12:27 PM
» Replies: 0
» Views: 964
|
|
|
Is it possible? |
Posted by: Ice - 07-22-2011, 01:37 PM - Forum: Help
- Replies (4)
|
 |
Is it possible or ever will be possible to add music into your place?
|
|
|
Qwertygiy's Scripting Tutorials #1: The Very Basic |
Posted by: Qwertygiy - 07-22-2011, 01:03 PM - Forum: Scripting
- Replies (6)
|
 |
I know that there are many Buildists out there who want to make cool games, but have trouble finding their way through the Lua language. This is the first in hopefully several tutorials to help you work your way through Buildism scripting.
Part One: Referencing
In order to make even the most basic scripts, you need to know how to access game parts.
Let's say you have a Box inside a Model, and a script inside the World. You want to be able to do something to the box from the script. To do that, you'll need to reference it. There are two ways to do it in this instance.
[lua]
script.Parent.Model.Box
--or
game.World.Model.Box
[/lua]
The first line works by finding what the script is inside (in this case, World), then finding the object named Model inside the script's parent, then finding the object named Box inside the Model.
The second line works no matter where the script is located; it doesn't have to be inside World. It first looks in the Root (where everything in the game is located), then World, then finds the Model inside World, and then the Box inside Model.
So, if we wanted to make this box red, wait a moment, then turn blue, we could use these lines:
[lua]
game.World.Model.Box.Color = Color(255,0,0)
sleep(2)
game.World.Model.Box.Color = Color(0, 0, 255)
[/lua]
Part Two: Variables
But say we have not just one or two lines where we need to reference this Box, but many more. It gets tedious having to type in all that, especially if the Box is not located in just one Model, but in a Model inside a Model inside a Model!
Fortunately, there is an easy shortcut -- local variables.
With local variables, we only need to type in the path to the object once.
We use a shorter term -- like box -- to refer to it. We can do this two ways.
[lua]
local box = game.World.Model.Box
box.Color = Color(255, 0, 0)
[/lua]
or
[lua]
box = game.World.Model.Box
box.Color = Color(255, 0, 0)
[/lua]
Here's a few simple things about variables to remember:- If you first reference a variable by putting "local" in front of it, if it is inside a function or other object requiring an "end" line, it is only usable until that "end" line. If you first refer to it with just the name, it can be used in the entire script.
- If you delete an object using :remove(), you can't bring it back into the game if you only referenced it, but if you referred to it as a variable, you can bring it back.
[lua]
local box = game.World.Model.Box
box:remove()
sleep(1)
box.Parent = game.World.Model
[/lua]
- It's not a good idea at all to name a variable with a global term, like "string" or "math" or "table" or "Color" or "Vec2D". If you do this, your script will either error or not be able to use the original term.
- If you want to be able to refer to one variable from more than one script, instead of local variablename, say _G.variablename.
[lua]
_G.box = game.World.Model.Box
[/lua]
Then, in another script, you can refer to _G.box. This is a global variable.
Part Three: Simple Functions
Now, say we have a bit of code that we want to run several times.
[lua]
local box = game.World.Model.Box
sleep(1)
box.Color = Color(255, 0, 0)
sleep(1)
box.Color = Color(0, 255, 0)
sleep(1)
box.Color = Color(0, 0, 255)
[/lua]
We could just repeat these lines, but that takes up lots of space and is quite tedious. So, we use a function.
All functions start with "function name()" and end with "end". All the stuff we want to do goes in between. To "use" the function, we use the line "name()".
[lua]
local box = game.World.Model.Box
function ColorBox()
sleep(1)
box.Color = Color(255, 0, 0)
sleep(1)
box.Color = Color(0, 255, 0)
sleep(1)
box.Color = Color(0, 0, 255)
end
ColorBox()
ColorBox()
ColorBox()
[/lua]
That is the simplest way to do a function. But there is another way, using a function variable.
Part Four: Functions with Variables
"But wait", you might be thinking, "didn't we already go over variables?"
Function variables are only used inside a function, not a whole script. They allow you to do the same function to different objects, or in different ways. So say we have two boxes, and we want to change their colors a bit differently, but we don't want to code in all that exactly. We can still script it into one function and a few call lines.
[lua]
local box = game.World.Model.Box1
local otherbox = game.World.Model.Box2
function ColorBox(part, partcolor)
part.Color = partcolor
end
ColorBox(box, Color(255, 0, 0))
ColorBox(otherbox, Color(0, 255, 0))
ColorBox(box, Color(0, 0, 255))
[/lua]
First, the part function variable refers to box, and the partcolor refers to Color(255, 0, 0) [or red]. Then, part refers to otherbox and partcolor to (0, 255, 0) [green.].
And that is how you create your own functions.
Congratulations! You've completed this scripting tutorial. Now you should be able to make your own basic working Buildism scripts.
|
|
|
h4x |
Posted by: noob007 - 07-22-2011, 07:43 AM - Forum: Programming
- Replies (2)
|
 |
How to swap two variables without using a temporary in a single line!
[lua]a^=b^=a^=b;[/lua]
:O
|
|
|
People Need To Understand |
Posted by: Ming-Yan - 07-22-2011, 07:42 AM - Forum: General Discussion
- Replies (11)
|
 |
That in Samsung's custom UI for Android, the part the looks like an iPhone is the app drawer. That's right, the home screen looks like android, only the app drawer is set up that way.
In fact, that means that the iOS has bee dumbed down to a sub directory of Android.
Probably why Apple is so butthurt suing HTC and Samsung for things like multitouch to unlock a phone, power management in cameras, sharing data between different devices, and more generic crap Apple doesn't even own.
This is what I hate, someone who already has a big consumer base stooping down to law suits to kill off competition.
Oh yeah and Samsung produces "Apple's" A5 chips, so after this case watch them rack up the prices. Lol no wonder it "over heated" the iPhone 5.
|
|
|
I Got into Another Manga |
Posted by: Ming-Yan - 07-22-2011, 06:55 AM - Forum: General Discussion
- Replies (10)
|
 |
This one seems to be revived because a bunch of chapters were translated in 2009 and only recently was a chapter posted on the 17th.
Anyway, this one is about a guy and a voice actress living together. They fall in ruv blah blah...But there are parts where she is busy or he is busy and crap like that. Oh the guy is also some dude who makes snack commercials [lol].
I liked the story where she talked about having an online friend that encouraged her to do her best and be a voice actress. :>
It's a manga called REC and it has X parts so I don't recommend it, but I do like the story.
|
|
|
A shocking truth. |
Posted by: Slendurrman - 07-22-2011, 06:07 AM - Forum: General Discussion
- Replies (10)
|
 |
In 2010 last year in march, my older brother Sam, tried committing suicide by consuming 25-30 tablets of Tylenol, it was the most shocking thing that struck my heart, I never saw this coming....but this was only the beginning of my search for information. But to day, I was typing down poetry on my moms laptop to print for a slam poetry presentation, when I was going to save it in my documents I saw a file named "the journey of Sam" I was very confused, saved the poetry and opened it. It talked about how he was sensitive his entire life, something I was never told to be aware of in my entire life until today, he also did multiple other things like saying he would kill himself then be in society. I was shocked at how much my parents kept this away, under a blanket of lies away from me. I am going to confront them about this tomorrow, regardless of the consequences or actions, they can send me to my death aslong as I get my answers I seek and how long they have been hiding my brothers true colors from me.
|
|
|
So I thought I heard in the rules you should... |
Posted by: Domino - 07-22-2011, 03:33 AM - Forum: 2DWorlds Discussion
- Replies (1)
|
 |
...should only make threads leading to conversation, well what if I want to say or tell everyone something? Sometimes when I make threads I may get 1 post tops so technically I'd be braking the rules, which I try never to do. So does anyone have an answer to this?
*didn't wanna make a long title*
|
|
|
|