The following warnings occurred:
Warning [2] Undefined array key "lockoutexpiry" - Line: 94 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 94 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "lockoutexpiry" - Line: 573 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 573 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $can_access_moderationqueue - Line: 752 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 752 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 892 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 892 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 892 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 892 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $awaitingusers - Line: 34 - File: global.php(959) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/global.php(959) : eval()'d code 34 errorHandler->error
/global.php 959 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 1024 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 1024 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5327 - File: inc/functions.php PHP 8.4.12 (Linux)
File Line Function
/inc/functions.php 5327 errorHandler->error
/global.php 1024 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1474 - File: inc/functions.php PHP 8.4.12 (Linux)
File Line Function
/inc/functions.php 1474 errorHandler->error
/inc/functions.php 1429 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



2DWorlds Forums
12/5/10 - Explosions, weapons, and more! - 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: 12/5/10 - Explosions, weapons, and more! (/showthread.php?tid=1109)



12/5/10 - Explosions, weapons, and more! - Jacob__mybb_import1 - 12-05-2010

Today's update is a big one, if you just want to play with some of the new stuff try this.
  • You can hold tools now. Set the Holdable property to true, then adjust the Texture, TextureOffset and Size to your liking.
  • Explosions! See below for an example
  • Fixed some random bugs
  • Players have health now, if you health reaches 0, you die. Explosions affect your health depending on how close to them you are.

Here is the code for the rocket:

Code:
tool = script.Parent
player = tool.Parent.Parent
character = player.Character
body = character.Body

enabled = true

function enable()
    enabled = true
    tool.Name = "Rocket"
end

function disable()
    enabled = false
    tool.Name = "Reloading..."
end

function playSound(s)
    if game.AssetService:getChild(s) ~= nil and game.AssetService[s]:isA("Sound") then
        game.AssetService[s]:play()
    end
end

function normalizeVector(vec)
    local m = math.sqrt(vec.x * vec.x + vec.y * vec.y)
    return Vec2D(vec.x / m, vec.y / m)
end

function onClick(btn, pos)
if btn == 1 then
    if not enabled then return end
    disable()
    local r = create("Box")
    r.Size = Vec2D(2, 1)
    r.Name="Rocket"
    local v = normalizeVector(Vec2D(pos.x - body.Position.x + 0.1, pos.y - body.Position.y - 1.5))
    local angle = math.atan2(v.y, v.x)
    
    local c = create("FixedVelocity")
    c.Velocity = Vec2D(v.x * 10, v.y * 10)
    c.Parent = r

    r.Rotation = math.deg(angle)
    r.Position = Vec2D(body.Position.x - 0.1 + v.x * 7, body.Position.y + 1.5 + v.y * 7)

    local s = create("Script")
    s.Name = "RocketScript"
    s.Source = [[
function playSound(s)
    if game.AssetService:getChild(s) ~= nil and game.AssetService[s]:isA("Sound") then
        game.AssetService[s]:play()
    end
end
rocket = script.Parent
function onCollide(hit)
    local e = create("Explosion")
    e.Radius = 7
    e.Position = rocket.Position
    e.Parent = game.World
    rocket:remove()
    playSound("Explode")
end
link(rocket.Collided, onCollide)
]]
    s.Parent = r
    r.Parent = game.World
    playSound("Rocket")
    sleep(4)
    enable()
end
end

link(script.Parent.MouseDown, onClick)

The part that creates the explosion is:
Quote: local e = create("Explosion")
e.Radius = 7
e.Force = 1000
e.Position = rocket.Position
e.Parent = game.World

The radius is how many units from the center the explosion force will travel; the force is how hard it will push on nearby parts. Explosions remove themselves automatically.