I think I am learing how to script (Sort of the realy basics) - Printable Version +- 2DWorlds Forums (http://2dworlds.buildism.net/forum) +-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4) +--- Forum: 2DWorlds Discussion (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=10) +--- Thread: I think I am learing how to script (Sort of the realy basics) (/showthread.php?tid=4645) Pages:
1
2
|
I think I am learing how to script (Sort of the realy basics) - Fish - 05-14-2011 RockFolder = create("Model") RockFolder.Name = "Rocks" RockFolder.Parent = game.World link(RockFolder.ChildAdded,function(Stone) link(Stone.Collided,function (hit) if hit.Parent:isA("Character") and hit.Parent.Name ~= script.Parent.Parent.Parent.Name then hit.Parent.Health = hit.Parent.Health-100 hit.Velocity = Vec2D(0,math.random(125,150)) end end) for i=1,25 do Stone.Position = Stone.Position:add(Vec2D(0,0.4)) sleep(0.01) end sleep(0.05) for i=1,25 do Stone.Position = Stone.Positionub(Vec2D(0,0.4)) sleep(0.01) end local s = create("Script") s.Source = "sleep(3) script.Parent:remove()" s.Parent = Stone end) function Stone(Pos,Number) S = create("Box") --S = create("Box") S.Name = "Rock" --S.Fixed = true --S.Locked = true S.Transparency = 0.0 S.Collidable = true S.Size = Vec2D(math.random(2,7),math.random(20,25)) S.Color = Color(148, 83, 17) S.Position = Pos:add(Vec2D(Number*10,0)) S.Parent = RockFolder end D = false link(script.Parent.MouseDown,function() if D == true then return end D = true local BP = Vec2D(script.Parent.Parent.Parent.Character.Body.Position.x,script.Parent.Parent.Parent.Character.Body.Position.y) for i=1,10 do Stone(BP,i*-1) sleep(0.05) end D = false end) It was origonaly water. I have never edited a script (Well... But Person299 Admin commands on ROBLOX. LOL) So I thought If I made Water into Box, a soild box would appear instead of water, it was right, then I changed the color and Transparenty! Looking at Qwertygiy's ROBLOX Scripts, he studyed Scripts to learn, like I am doing. So if anyone can give me basic scripts to edit, Thanks. P.s, this script was from Anti. RE: I think I am learing how to script (Sort of the realy basics) - Qwertygiy - 05-14-2011 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 RE: I think I am learing how to script (Sort of the realy basics) - Fish - 05-14-2011 (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: Thanks. I am also hosting a sever. http://buildism.net/game.php?id=4582 :3 Feel free to join. RE: I think I am learing how to script (Sort of the realy basics) - toast - 05-14-2011 (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: 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 RE: I think I am learing how to script (Sort of the realy basics) - Chaos - 05-14-2011 Scripting forum? RE: I think I am learing how to script (Sort of the realy basics) - noob007 - 05-14-2011 (05-14-2011, 10:20 PM)Qwertygiy Wrote: [lua] Why not just do: [lua] count = 0 while count <= 10 do print("Looping.") count = count + 1 end [/lua] RE: I think I am learing how to script (Sort of the realy basics) - Qwertygiy - 05-14-2011 Because that works in this case, but it only works if count <= 10 when the loop starts. It's easier when just beginning to do something that will always work than try to figure out which way to do it (especially when editing an existing, usually long, script). RE: I think I am learing how to script (Sort of the realy basics) - noob007 - 05-14-2011 (05-14-2011, 10:55 PM)Qwertygiy Wrote: Because that works in this case, but it only works if count <= 10 when the loop starts. >_> That's why you explicitly say "count = 0" in the beginning... RE: I think I am learing how to script (Sort of the realy basics) - Micky - 05-14-2011 Scripting Mumbo-Jumbo O.o RE: I think I am learing how to script (Sort of the realy basics) - Player - 05-15-2011 Woah, you guys are codemasters. I suck at scripting! |