![]() |
Lua Syntax Highlighting in Posts - 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: Lua Syntax Highlighting in Posts (/showthread.php?tid=1172) |
Lua Syntax Highlighting in Posts - Jacob__mybb_import1 - 02-01-2011 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] RE: Lua Syntax Highlighting in Posts - Tyler - 02-01-2011 That's a um,pretty big script. RE: Lua Syntax Highlighting in Posts - Jacob__mybb_import1 - 02-01-2011 That's the script for the rocket. RE: Lua Syntax Highlighting in Posts - Paradox - 02-01-2011 (02-01-2011, 12:36 AM)Jacob_ Wrote: Use [ lua ] tags: *Blank stare* RE: Lua Syntax Highlighting in Posts - Asai - 02-06-2011 :O-0.0 RE: Lua Syntax Highlighting in Posts - Eliuser12 - 02-10-2011 Update explosions, PL0X? |