Paying bits for a script teacher
#1
Unless you'll do it for free.
I'd like to make some games, and I've never learned how.
I'll pay a to-be-determined amount for each lesson.
~Invader~
Reply
#2
I'd be glad to teach you as much as I could without any "fee". I've already got way too many of these rather-worthless things lying around my account Tongue

Do you want to do it through PMs or here in this thread?
Reply
#3
(09-04-2012, 12:56 PM)Qwertygiy Wrote: I'd be glad to teach you as much as I could without any "fee". I've already got way too many of these rather-worthless things lying around my account Tongue

Do you want to do it through PMs or here in this thread?
It doesn't really matter, you can decide.
~Invader~
Reply
#4
Might as well put it up here, so that other people can get some use out of it.

First thing you need to know is how Buildism stores data in games. The root object, in which everything in the game is stored, is called simply "game". Everything you can create or edit is somewhere inside of game. However, game alone is not much help to us. So let's go a step further.

All physical parts in games belong in the World. (There can be multiple worlds but that's advanced stuff.) So all your boxes, circles, characters, and ladders belong in game.World. Your character, when you enter a game, can be found at game.World.Username.

Let's say you want to change your health to 0, for example if you've gotten stuck somewhere. We'd want to change the Health variable of your character. This is called in mostly the same way: game.World.Username.Health. To change it, you would type this code:

[lua]
game.World.Username.Health = 0
[/lua]

and viola, your character is dead.

There is another way to access objects: the getChild method. This is for when the name of the object has a space or other odd character like @ or #, or you can't be sure the object actually exists or not. The way you do this is you write the path to the "parent" object normally, then add :getChild("objectname") to the end.

[lua]
game.World:getChild("Username").Health = 0
[/lua]

You can do this for nearly any object and property you can find in the Advanced Tools browser in the editor (and some ones you can't), except for some important things like player and service names, and class types. Generally, if you can change it with Advanced Tools, you can change it with a script.


I'll post some more stuff later.
Reply
#5
Okay, interesting.
And keep in mind I will pay if you want it.
~Invader~
Reply
#6
pay me 2,000,000 in advance and ill teach you everything
Reply
#7
I have almost 1,800 of them already, which is probably more than anyone else. And I really have no use for them, because I generally make my own character bits.

Anyway, back to script stuff.

Being able to change stuff is handy, but if you're changing the same thing more than once, having to write out the full path every time you do so can get unnecessarily tedious. That's where variables come in.

In some languages, you have to say what type of variable you're making when you first write it. In Lua, fortunately, it's simpler than that. You just come up with a name, and then set it.

[lua]
me = game.World.Username
me.MaximumHealth = 1000
me.Health = me.MaximumHealth
[/lua]

Make sure you define your variable before you try to do anything else to it. For example, removing the first line from the code above so that you have this code will give you an error that "me" does not exist:

[lua]
me.MaximumHealth = 1000
me.Health = me.MaximumHealth
[/lua]

There are 3 special types of variables; local, global, and function parameters; but those can come later.

So now you should know how to declare a variable to an existing object, or property of one. There are other uses for variables, though. You can declare variables of data types that originate inside the script:

[lua]
--boolean values: true or false
bool = true

--number values: Lua can do math for you
--(+ is addition, - is subtraction, * is multiplication, / is division,
--and parenthesis and order of operations apply normally)
ten = 6 + 6 - 2

--strings: not yarn or twine, but lines of text
myname = "Qwertygiy"

--two special Buildism data types:
--Colors are r[ed], g[reen], b[lue] and values range from 0 (none) to 255 (full);
--Vec2Ds are x, y
white = Color(255, 255, 255)
origin = Vec2D(0, 0)

--you can read those parts of Colors and Vec2Ds on their own,
--but you can't write them separately; you need to use the constructors and change the whole value,
--like I did above.
redness = white.r
leftright = origin.x

--and of course, objects! You can create most object types like this,
--just make sure to change the Parent after setting all other properties you're changing
circle = create("Circle")
circle.Name = myname
circle.Radius = ten
circle.CharacterCollide = bool
circle.Color = white
circle.Position = origin
circle.Parent = game.World
[/lua]
Reply
#8
Okay, I see.
If I wanted to do something like we did on multiplayer yesterday such as explode, I'd have to define it if I said "me" in the script, right? Could I say something such as "game.Players.Invader.Health = 0" and have it work without defining "me"?
~Invader~
Reply
#9
yes but if you define something you are going to use lots of times in the same script it cuts down on loads of writing
Reply
#10
[lua]
game.World.Invader.MaximumHealth = 1000
game.World.Invader.Health = game.World.Invader.MaximumHealth
[/lua]

vs.

[lua]
me = game.World.Invader
me.MaximumHealth = 1000
me.Health = me.MaximumHealth
[/lua]

Easy to see which is quicker to write, isn't it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)