2DWorlds Forums
Gravity Tool - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: Your Stuff (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=6)
+--- Forum: Current Games (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=11)
+--- Thread: Gravity Tool (/showthread.php?tid=2037)



Gravity Tool - Jacob__mybb_import1 - 04-04-2011

Put this script in a tool:

[lua]
force = 0
target = nil
strength = 5
run = false

function mouseDown(b, pos)
if b == 3 then
force = strength
elseif b == 1 then
force = -strength
end
target = pos
run = true
end

link(script.Parent.MouseDragged, function(b, pos)
mouseDown(b, pos)
end)

link(script.Parent.MouseDown, function(b, pos)
mouseDown(b, pos)
end)

link(script.Parent.MouseUp, function(pos)
force = 0
run = false
end)


while true do
if run and force ~= 0 then
local c = game.World:getChildren()
for i=1, #c do
if (c[i]:isA("Box") or c[i]:isA("Circle")) and c[i].Fixed == false then
d = c[i].PositionConfusedub(target).normalized
c[i].Velocity = d:mul(force)
end
end
end
sleep(0.1)
end
[/lua]

Left click to make black holes, right click to make white holes.

Feel free to make a game with this!


RE: Gravity Tool - Scripter - 04-04-2011

I didn't quite get some of the things used in the while do loop, but oh well.

Thanks!


RE: Gravity Tool - Login - 04-04-2011

Jacob_ I will, gladly. ^_^ I'll make it on my last place.


RE: Gravity Tool - BuildistGuard - 04-04-2011

I will put that in my future arena.


RE: Gravity Tool - Micky - 04-10-2011

So thats what you used for the heli!!


RE: Gravity Tool - Ashely - 04-10-2011

I tried it out, Thanks!