2DWorlds Forums
2/4/11 - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4)
+--- Forum: News (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=8)
+--- Thread: 2/4/11 (/showthread.php?tid=1262)



2/4/11 - Jacob__mybb_import1 - 02-05-2011

  • Tool picking up/dropping works again, and
  • Tools are now dropped where you are pointing instead of on your head
  • getAngle() member function for tools; this returns the angle between the player's body and the mouse
  • moveTo(position, part) member function for models. The specified part will be moved to the given position, and the other parts in the model will be moved with it.

Here is an example of getAngle(). Put this script in a tool, then click to throw balls.

Code:
player = script.Parent.Parent.Parent
character = player.Character
body = character.Body
link(script.Parent.MouseDown, function(b)
    if b == 1 then
        local a = math.rad(script.Parent:getAngle()) --it returns degrees, we need radians to use sin and cos
        local x = math.cos(a) --get the x and y components of the angle
        local y = math.sin(a)
        local position = Vec2D(body.Position.x + x * 4, body.Position.y + y * 4) --Position of the ball
        local p = create("Circle")
        p.Position = position
        p.Velocity = Vec2D(x * 20, y * 20) --Give it some velocity
        p.Color = Color(200, 0, 0)
        p.Parent = game.World
    end
end)



RE: 2/4/11 - ryan - 02-05-2011

Thats cool, thanks for sharing with us Jacob!


RE: 2/4/11 - Asai - 02-06-2011

God. The type of scripting on this site is CONFUSING!


RE: 2/4/11 - Jacob__mybb_import1 - 02-06-2011

Does this page make it any clearer? http://buildism.net/wiki/w/index.php?title=Scripting_Help


RE: 2/4/11 - Asai - 02-07-2011

(02-06-2011, 10:56 PM)Jacob_ Wrote: Does this page make it any clearer? http://buildism.net/wiki/w/index.php?title=Scripting_Help

Yes. Big Grin thanks Smile


RE: 2/4/11 - Jacob__mybb_import1 - 02-08-2011

Next update will be a tutorial of some sort.