![]() |
Share Your Scripts - Printable Version +- 2DWorlds Forums (http://2dworlds.buildism.net/forum) +-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4) +--- Forum: Scripting (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=13) +--- Thread: Share Your Scripts (/showthread.php?tid=2294) |
Share Your Scripts - Jacob__mybb_import1 - 04-05-2011 Currently the public scripts are scattered randomly throughout the forum... I thought it would be nice if we could keep them all in one place! So, I made a wiki article: http://buildism.net/wiki/w/index.php?title=Code_Fragments RE: Share Your Scripts - Bramwell - 04-05-2011 I edited the reset tool and made a "kill npc on click" tool [lua]npc = game.World.NPC link(script.Parent.MouseDown, function() npc.Health = 0 end)[/lua] I didn't want to put it on the wiki at first because it's a pretty useless too. RE: Share Your Scripts - Scripter - 04-05-2011 Sweet. Here's the script I used for my tool at the end of my falling rocks game. Be sure to put the script in a tool, and also name the Tool "JetBoots". [lua] local mode = 1 names = {"JetBoots", "Exploder"} function md(x,p) if mode == 1 then script.Parent.Parent.Parent.Character.Body.Controller.Velocity = Vec2D(0,5) elseif mode == 2 then y = create("Explosion") y.Parent = game.World y.Position = p end end function mu() if mode == 1 then script.Parent.Parent.Parent.Character.Body.Controller.Velocity = Vec2D(0,0) end end function kd(k) if k == "e" then if mode == #names then mode = 1 else mode = mode + 1 end script.Parent.Name = names[mode] elseif k == "q" then if mode == 1 then mode = #names else mode = mode - 1 end script.Parent.Name = names[mode] end end link(script.Parent.MouseDown, md) link(script.Parent.MouseUp, mu) link(script.Parent.KeyDown, kd) [/lua] RE: Share Your Scripts - Ice - 04-10-2011 Ahhh, cool, thanks. RE: Share Your Scripts - toast - 04-10-2011 Magic carpet script (put in a tool) [lua]local carpet=create("Box") carpet.Name="carpet" local player=script.Parent.Parent.Parent carpet.Size=Vec2D(30,2) carpet.Color=Color(128,0,128) local fv=create("FixedVelocity") create("FixedRotation").Parent=carpet fv.Parent=carpet local l=create("Label") l.Parent=carpet l.Text=player.Name.."'s Magic carpet" function selected() if carpet.Parent~=nil then return end moveto() carpet.Parent=player.Character end function moveto() carpet.Position=player.Character.Body.Position:add(Vec2D(carpet.Size.x/2,0)) end function keydown(k) if k=="r" then fv.Velocity=Vec2D(0,4-fv.Velocity.y):add(fv.Velocity) elseif k=="h" then fv.Velocity=Vec2D(0,0.47-fv.Velocity.y):add(fv.Velocity) elseif k=="f" then fv.Velocity=Vec2D(0,0-fv.Velocity.y):add(fv.Velocity) end if k=="n" then moveto() end local speed=4 if k=="z" then fv.Velocity=Vec2D(-speed-fv.Velocity.x,0):add(fv.Velocity) elseif k=="x" then fv.Velocity=Vec2D(speed-fv.Velocity.x,0):add(fv.Velocity) elseif k=="c" then fv.Velocity=Vec2D(-fv.Velocity.x,0):add(fv.Velocity) carpet.Velocity=Vec2D(-carpet.Velocity.x,0):add(carpet.Velocity) else carpet.Velocity=Vec2D(-carpet.Velocity.x,0):add(carpet.Velocity) end end function keyup(k) end link(script.Parent.Selected,selected) link(script.Parent.KeyDown,keydown) link(script.Parent.KeyUp,keyup)[/lua] RE: Share Your Scripts - Matt - 04-15-2011 Is this lua? RE: Share Your Scripts - Bramwell - 04-15-2011 (04-15-2011, 09:15 PM)Matt Wrote: Is this lua? Yes. It is Lua. If you're familiar with scripting in ROBLOX, you should have no trouble scripting in Buildism. |