I think I am learing how to script (Sort of the realy basics)
#4
(05-14-2011, 10:20 PM)Qwertygiy Wrote: Exactly. Here's some extra code bits to help you out, and a script that uses them:

while true do: This is a loop. It will repeat until instructed to "break".

[lua]
count = 0
while true do
sleep(1)
print("Looping.")
count = count + 1
if count > 10 then
break
end
end
[/lua]

It loops 10 times, printing "Looping" each time, then stops.

stuff:getChildren(): Gets a table with all the members being the descendents of stuff.

for q = 1, #table do: Loops through each member of table 'table'. q can be any letter. I use q because it's the first letter in the keyboard.

[lua]
local itemz = game.World:getChildren()
for q = 1, #itemz do
if itemz[q]:isA("Character") then
itemz[q].Body.Velocity = Vec2D(0,200)
end end
[/lua]

Makes everyone jump high Big Grin

DO NOT ACT LIKE WHILE TRUE DO IS A SEPERATE KIND OF LOOP!!!!!!!!!!!!!!!!!!!
Teach them what the while loop is then tell them how while true do is a loop that repeats forever, and how "break" exits a loop
[Image: 5widdh.png]
Siggy by McNoobster!
[Image: loading.gif]
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 6 Guest(s)