I think deleting my account McNoobster was a little far
#22
Well I can see it ._. just click on 1 then click view source
I got this much of it and thats it

This article should give you a good start on scripting games in Buildism.
Contents
[hide]

1 Intro
2 Structure
3 Properties
4 Member Functions
5 Events
6 Tools

[edit] Intro

Buildism scripting is done in Lua. A complete introduction to Lua is beyond the scope of this article, but you can find a lot of info on the lua-users wiki.

The command bar at the bottom of the screen is good for experimenting, but to get stuff to happen in your game once it is saved, use Script objects.

To add a script, go to the Edit menu>Insert Object. Find "Script" on the list, then double click it or press OK. It will be placed in the World, if you want it to go somewhere else, drag its icon in the tree to any of the objects you see there.

Once you've added your script, double click it to change the source. To run it right click it and select Run Script, or alternatively, cut and paste it (cutting or deleting a script causes it to stop executing, and disconnects it from any events).

When a user loads your game, all of the scripts you've added will run automatically.

If a script encounters an error, the game will print the error to the console and tell you what script caused the error.
[edit] Structure

The game uses a hierarchy system, which is very much like a family tree. The "founding fathers" are the Services, which are all organized under the root object. These services can contain an indefinite number of descendants.

To navigate the hierarchy, use a period to access a child of an object. For example, this will get you to the ball in the image to the right:

game.World.Ball

If you try to get a child that doesn't exist, the script will have an error and stop running ("break").

Once you get to the object you want to change, you can get its properties, edit them, or use member functions.
[edit] Properties

Properties can be accessed by appending their name to the object's path, e.g.

print(game.World.Ground.Color)

To assign a property, use the = sign:

game.World.Box.Collidable = false

To set a vector or color property, use the Vec2D(x, y) and Color(r, g, b) functions.

game.World.Box.Color = Color(255, 255, 255)
game.World.Box.Position = Vec2D(10, 10)

You can also set a property to the value of another property, or the result of a function.

game.World.Box1.Color = game.World.Box2.Color
game.World.Box.Color = randomColor()

You can do many, many things to edit your script, enjoy!
[edit] Member Functions

Member functions used to perform an action on an object. They are accessed using a colon (Smile, like so:

game.World.Ground:remove()

remove() is probably the most used member function, followed by clone() and getChild(). For a description of the global membember functions, see here: Global Member Functions

There are only 3 global functions that are not members: Vec2D(), Color(), and sleep(time). sleep() causes the script to wait for the given number of seconds.
[edit] Events

See: Events
[edit] Tools
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)