Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lua Syntax Highlighting in Posts
#1
Use [ lua ] tags:

[lua]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 = [[
exploded = false
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)
if exploded then return end
exploded = true
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)[/lua]
Reply
#2
That's a um,pretty big script.
Reply
#3
That's the script for the rocket.
Reply
#4
(02-01-2011, 12:36 AM)Jacob_ Wrote: Use [ lua ] tags:

[lua]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 = [[
exploded = false
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)
if exploded then return end
exploded = true
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)[/lua]

*Blank stare*
Reply
#5
:O-0.0
Reply
#6
Update explosions, PL0X?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)