11-01-2011, 02:18 PM
For Mustachio:
[lua]
local target = game.World.Box
local bullet = game.World.Circle
local ups = 10 --units per second
--change those three variables as needed
while true do
sleep(0.01)
local xdistance = target.Position.x - bullet.Position.x
if xdistance < 0 then
xdistance = xdistance * -1
end
local ydistance = target.Position.y - bullet.Position.y
if ydistance < 0 then
ydistance = ydistance * -1
end
if xdistance < 0.1 and ydistance < 0.1 then break end
if target.Position.x > bullet.Position.x then
if target.Position.y > bullet.Position.y then
bullet.Position = bullet.Position + Vec2D(ups/100, ups/100)
else
bullet.Position = bullet.Position + Vec2D(ups/100, ups/-100)
end
else
if target.Position.y > bullet.Position.y then
bullet.Position = bullet.Position + Vec2D(ups/-100, ups/100)
else
bullet.Position = bullet.Position + Vec2D(ups/-100, ups/-100)
end
end
end
print("Parts reached")
[/lua]
[lua]
local target = game.World.Box
local bullet = game.World.Circle
local ups = 10 --units per second
--change those three variables as needed
while true do
sleep(0.01)
local xdistance = target.Position.x - bullet.Position.x
if xdistance < 0 then
xdistance = xdistance * -1
end
local ydistance = target.Position.y - bullet.Position.y
if ydistance < 0 then
ydistance = ydistance * -1
end
if xdistance < 0.1 and ydistance < 0.1 then break end
if target.Position.x > bullet.Position.x then
if target.Position.y > bullet.Position.y then
bullet.Position = bullet.Position + Vec2D(ups/100, ups/100)
else
bullet.Position = bullet.Position + Vec2D(ups/100, ups/-100)
end
else
if target.Position.y > bullet.Position.y then
bullet.Position = bullet.Position + Vec2D(ups/-100, ups/100)
else
bullet.Position = bullet.Position + Vec2D(ups/-100, ups/-100)
end
end
end
print("Parts reached")
[/lua]