04-13-2011, 12:59 PM
This is a basic Lua tutorial for Buildism Lua.
==Getting set up==
To start off, go to the Buildism site and click the 'Lauch Editor' button in the top right.
So, let's start with the scripting console, click the lua icon near the bottom left of your Buildism client and it will appear. You can use it like a script, but it is only possible to write one line of lua.
So, let's start by inserting a box. Once you've drawn your box let's open the advanced tools. This is achieved by pressing the middle of the three tabs on the left of the client. From here try to find your box in the sidebar that appears. Once you've found it see if you can figure out how to rename it to 'ScriptBox'.
==Stage 1==
So, now we're going to use our scripting console. To locate the 'ScriptBox'. Follow the dotted line on the side of it in your panel, it should lead you to World. So we can write in our scripting console the following.
[lua]World.ScriptBox[/lua]
The '.' shows that ScriptBox is a child of World. This means that it is part of 'World'.
World is also a part of something else known as 'game'. So let's write in our command bar:
[lua]game.World.ScriptBox[/lua]
==Stage 2==
Now that we've located the ScriptBox in lua let's try doing something to it.
Try clicking it in that panel we opened up earlier (Advanced tools). Now let's look at the properties box (The one that pops up giving you information about the item you just selected)
So, let's start by editing a boolvalue. A boolvalue is either 'true' or 'false'. It is represented as a checkbox in the properties box. Let's 'lock' the ScriptBox. First we have to locate the 'Locked' property.
[lua]game.World.ScriptBox.Locked[/lua]
Now let's lock the box.
[lua]game.World.ScriptBox.Locked = true[/lua]
Now try and drag/resize the box. You can't. It's locked. To unlock it:
[lua]game.World.ScriptBox.Locked = false[/lua]
Now you should be able to move it.
A box has four other boolvalues. ShowBorder, Fixed, Collidable and CharacterCollide, they are all manipulated with lua in the same way as 'Locked'.
Now let's do IntValues. IntValues are number values. Let's play around with transparency. Try and use what you've learnt to make a block semi transparent (translucent). Try and do it yourself before you look at the answer below.
[lua]game.World.ScriptBox.Transparency = 0.5[/lua]
Finally we have stringvalues. The important thing to remember with stringvalues is that because it is a string it goes in quotes. So if we want to change our ScriptBox's name to NonScriptBox we can do the following.
game.World.ScriptBox.Name = "NonScriptBox"
Don't forget the quote marks!
Now we just have one last thing to do to our box, remove it!
[lua]game.World.NonScriptBox:remove()[/lua]
==Getting set up==
To start off, go to the Buildism site and click the 'Lauch Editor' button in the top right.
So, let's start with the scripting console, click the lua icon near the bottom left of your Buildism client and it will appear. You can use it like a script, but it is only possible to write one line of lua.
So, let's start by inserting a box. Once you've drawn your box let's open the advanced tools. This is achieved by pressing the middle of the three tabs on the left of the client. From here try to find your box in the sidebar that appears. Once you've found it see if you can figure out how to rename it to 'ScriptBox'.
==Stage 1==
So, now we're going to use our scripting console. To locate the 'ScriptBox'. Follow the dotted line on the side of it in your panel, it should lead you to World. So we can write in our scripting console the following.
[lua]World.ScriptBox[/lua]
The '.' shows that ScriptBox is a child of World. This means that it is part of 'World'.
World is also a part of something else known as 'game'. So let's write in our command bar:
[lua]game.World.ScriptBox[/lua]
==Stage 2==
Now that we've located the ScriptBox in lua let's try doing something to it.
Try clicking it in that panel we opened up earlier (Advanced tools). Now let's look at the properties box (The one that pops up giving you information about the item you just selected)
So, let's start by editing a boolvalue. A boolvalue is either 'true' or 'false'. It is represented as a checkbox in the properties box. Let's 'lock' the ScriptBox. First we have to locate the 'Locked' property.
[lua]game.World.ScriptBox.Locked[/lua]
Now let's lock the box.
[lua]game.World.ScriptBox.Locked = true[/lua]
Now try and drag/resize the box. You can't. It's locked. To unlock it:
[lua]game.World.ScriptBox.Locked = false[/lua]
Now you should be able to move it.
A box has four other boolvalues. ShowBorder, Fixed, Collidable and CharacterCollide, they are all manipulated with lua in the same way as 'Locked'.
Now let's do IntValues. IntValues are number values. Let's play around with transparency. Try and use what you've learnt to make a block semi transparent (translucent). Try and do it yourself before you look at the answer below.
[lua]game.World.ScriptBox.Transparency = 0.5[/lua]
Finally we have stringvalues. The important thing to remember with stringvalues is that because it is a string it goes in quotes. So if we want to change our ScriptBox's name to NonScriptBox we can do the following.
game.World.ScriptBox.Name = "NonScriptBox"
Don't forget the quote marks!
Now we just have one last thing to do to our box, remove it!
[lua]game.World.NonScriptBox:remove()[/lua]