|
Post by Tag365 on Jul 9, 2015 18:26:54 GMT
{"Images\/Tower3.lua":"draw.fillcircle(24, 24, 16, draw.black)\nfor k=14, 0, -1 do\n draw.fillcircle(24, 24, k, Color.new(.1, .1, .1, 1, true)*(2-(k\/8)))\nend\ndraw.fillroundedrect(18, 0, 30, 24, 4, draw.gray)\ndraw.filltriangle(18, 8, 24, 2, 30, 8, draw.black)\ndraw.fillcircle(24, 10, 8, draw.blue*.1)\nfor k=-0, 16, .05 do\n draw.fillcircle(24 + k*.25, 10 + k*.25, math.max(8 - (k*1), 0), draw.blue*(.125*(k+1.7)))\nend\ndraw.circle(24, 10, 8, draw.lightgray)\nreturn {0, 0, 48, 48}","Images\/Tower5.lua":"draw.setscreen(1)\ndraw.fillrect(2, 30, 46, 46, draw.black)\ndraw.fillrect(20, 28, 28, 30, draw.gray)\ndraw.fillrect(22, 24, 26, 30, draw.gray)\ndraw.fillrect(4, 2, 44, 28, draw.gray)\n-- Draw screen contents\ndraw.fillrect(6, 4, 42, 26, draw.white)\ndraw.fillcircle(24, 15, 10.5, draw.lightgray)\ndraw.fillrect(22, 6, 26, 24, draw.orange)\ndraw.fillrect(15, 13, 33, 17, draw.orange)\n\nif not Color then sys.sleep(math.huge) end\nreturn {0, 0, 48, 48}","PublishScript.lua":"print('Generating Installer Stubs!')\nlocal FileTable = {}\n\nfunction requireFromRoot(File)\n local Handle, err = io.open(\"..\/\"..File..\".lua\")\n local String, Funct = \"\", nil\n if Handle then\n String = \"require = requireFromRoot\\n\"..Handle:read(\"*a\")\n Handle:close()\n Funct = load(String)\n end\n --local Funct, err = loadfile(\"..\"..File..\".lua\")\n if Funct then\n local var1 = Funct()\n require = Require\n return var1 or true\n else\n print(err)\n end\nend\n\nlfs = require \"lfs\"\n\nJSON = require(\"JSON\")\nlocal files = sys.dir()\n\nfunction lfs.isDirectory(Path)\n return lfs.attributes(Path, \"mode\") == \"directory\"\nend\n\nfor k, v in ipairs(files) do\n if v ~= \".\" and v ~= \"..\" and v ~= \"Publish\" and v~= \"savedData.txt\" and v~= \"PublisScript.lua\" then\n if lfs.isDirectory(v) then\n local sub = sys.dir(v)\n for k2, v2 in ipairs(sub) do\n if v2 ~= \".\" and v2 ~= \"..\" and string.sub(v, -8)~=\"stub.lua\" then\n files[#files + 1] = v..\"\/\"..v2\n end\n end\n end\n end\nend\n\nfor k, v in ipairs(files) do\n if v ~= \".\" and v ~= \"..\" and string.sub(v, -8)~=\"stub.lua\" then\n local file = io.open(v)\n if file then\n FileTable[v] = file:read(\"*a\")\n file:close()\n end\n end\nend\n\n\nlocal String = JSON.EncodeJSON(FileTable)\nprint(\"Extractable file is \"..#String..\" bytes\")\n\nif not lfs.isDirectory(\"Publish\") then\n lfs.mkdir(\"Publish\")\nend\n\nprint(\"Saving...\")\nlocal Chunk = 8192*16\nfor i=1, math.ceil(#String\/Chunk) do\n file = io.open(\"Publish\/ScriptDefender\"..i..\"stub.lua\", \"w\")\n file:write(string.sub(String, ((i - 1)*Chunk) + 1, math.min(i*Chunk, #String)))\n file:close()\nend\nprint(\"Done!\")","Classes\/Stage.lua":"if not scWidth then\n local lfs = require \"lfs\"\n local dir = lfs.currentdir()\n local newdir = dir:sub(0, -8)\n lfs.chdir(newdir)\n dofile(\"main.lua\")\nend\nlocal Stage = {}\nStage.__index = Stage -- failed table lookups on the instances should fallback to the class table, to get methods\nStage.classtype = \"Stage\"\n\nlocal cos, sin = math.cos(1), math.sin(1)\n\n-- This function constructs a new object of this type.\nStage.new = function()\n local self = setmetatable({}, Stage)\n self.health = 10\n self.coins = 100\n self.score = self.coins\n self.round = 1\n self.roundTick = 30*30\n self.speed = 4\n self.roundEnemies = {}\n self.running = false\n self.spawnEnemies = true\n self.background = drawBackground\n self.towers = {}\n self.enemies = {}\n self.projectiles = {}\n self.deadTowers = {}\n self.deadEnemies = {}\n self.deadProjectiles = {}\n return self\nend\n\n-- Stage Functions --\nfunction Stage:UpdateDifficulty()\n if selectedDif >= 5 + (2.5*5) then\n self.instaDeath = true\n round[1].hint = \"The anti-malware program that is installed on the network is out of date and is oblivious to the threats that you will be facing. You must not allow any malware to be installed or your project is toast.\"\n end\n if selectedDif >= 5 + (2.5*4) then\n self.decayingHealth = (selectedDif - (5 + (2.5*4)) + 1)*.00001*(self.round*self.round*.85)*math.max((self.health - 10000)*.00000007, 1)\n end\nend\n\nfunction Stage:skipRound()\n Hud.SkippingRound = true\n -- Skip round\n local ilt = 0\n local redrawTime = 60\n local v = self.towers[Hud.CurrentTower]\n while self:Update() and self.running and Hud.SkippingRound do\n draw.doevents()\n ilt = ilt + 1\n if ilt >= redrawTime then\n ilt = 0\n draw.beginframe()\n Hud.DrawStatusWindow()\n draw.fillarc(scWidth*.5, scHeight*.5, 48, 0, math.pi*2, draw.green)\n draw.fillarc(scWidth*.5, scHeight*.5, 48, 0, (stage.roundTick\/stage.roundTime)*math.pi*2, draw.white)\n draw.endframe()\n end\n if v then\n Upgrade(v)\n end\n end\n Hud.SkippingRound = false\nend\n\n-- Handles Stage for this frame.\nfunction Stage:Update()\n if self.gameOver then\n self.health = 0\n return false\n end\n if self.running then\n if self.decayingHealth then\n self.health = self.health - self.decayingHealth\n end\n -- Loop through towers\n for key, value in pairs(self.towers) do\n value:HandleAI()\n end\n -- Loop through enemies\n for key, value in pairs(self.enemies) do\n value:HandleAI()\n end\n -- Loop through projectiles\n for key, value in pairs(self.projectiles) do\n value:HandleAI()\n end\n end\n if #self.deadTowers > 0 then\n for k, v in ipairs(self.deadTowers) do\n table.remove(self.towers, v - (k-1))\n end\n for k, v in pairs(self.towers) do\n v.id = k\n end\n self.deadTowers = {}\n end\n for k, v in pairs(self.deadEnemies) do\n self.enemies[v] = nil\n end\n for k, v in pairs(self.deadProjectiles) do\n self.projectiles[v] = nil\n end\n self.deadEnemies = {}\n self.deadProjectiles = {}\n if self.spawnEnemies and self.running then\n self:SpawnEnemies()\n end\n if self.roundTick > 0 then\n self.spawnEnemies = true\n else\n self.spawnEnemies = false\n end\n if self.roundTick > 0 and self.running then\n self.roundTick = self.roundTick - 1\n end\n -- Check if it is game over\n if self.health <= 0 then\n self.gameOver = true\n sound.stopeverything()\n sound.playeffect(\"@resources\/BigBomb.mp3\", .5)\n sound.playeffect(\"@resources\/Alert.mp3\")\n --draw.beginframe()\n Hud.DrawStatusWindow()\n --draw.endframe()\n return false\n end\n -- Attempt to end the round\n if self.running and not self.spawnEnemies then\n local enemies = 0\n for k, v in pairs(self.enemies) do\n enemies = enemies + 1\n break\n end\n if enemies <= 0 then\n self:UpdateDifficulty()\n self.running = false\n self.spawnEnemies = true\n self.round = self.round + 1\n for k, v in pairs(self.projectiles) do\n self.projectiles[k] = nil\n end\n sound.playeffect(\"@resources\/Pickup3.wav\", .2)\n saveGame()\n Hud.ShowTip = true\n end\n end\n return true\nend\n\nfunction Stage:SpawnEnemies()\n local tick = self.roundTick\n if self.roundEnemies[tick] then\n math.randomseed(tick)\n for k, v in pairs(self.roundEnemies[tick]) do\n table.insert(stage.enemies, Enemies[v]:new(400, 160 + (math.random()*2 - 1)*120))\n end\n end\nend\n\nfunction Stage:Draw()\n -- Draw the background\n if type(self.background) == \"function\" then\n self.background()\n elseif type(self.background) == \"string\" then\n draw.image(self.background, 0, 0)\n end\n --draw.setantialias(false)\n -- Loop through towers\n for key, tower in pairs(self.towers) do\n tower:draw()\n end\n -- Loop through enemies\n for key, enemy in pairs(self.enemies) do\n enemy:draw()\n end\n -- Loop through projectiles\n for key, shot in pairs(self.projectiles) do\n shot:draw()\n end\n --draw.setantialias(true)\nend\n\nreturn Stage","savedData.txt":"if not scWidth then require \"main\" end--[[\n12.5\n29\n12887.545636817\n131.87057213116\n14069427.545637\n--Towers--\n1\n3\n160\n176\n187\n1\n3\n160\n128\n163\n1\n2\n160\n240\n110\n1\n2\n64\n160\n48\n1\n1\n48\n224\n28\n1\n1\n80\n256\n13\n1\n5\n96\n96\n58\n1\n2\n112\n192\n47\n1\n3\n176\n64\n38\n1\n1\n160\n272\n11\n1\n3\n256\n144\n80\n1\n3\n288\n224\n61\n1\n3\n288\n80\n63\n1\n3\n224\n208\n60\n1\n3\n224\n96\n75\n4\n3\n240\n272\n0\n3\n7\n16\n112\n212\n3\n12\n16\n160\n170\n4\n3\n272\n272\n0\n3\n9\n16\n208\n232\n4\n3\n304\n272\n0\n5\n3\n16\n288\n0\n4\n3\n336\n288\n0\n4\n4\n336\n272\n0\n4\n3\n304\n304\n0\n4\n3\n272\n304\n0\n4\n3\n240\n304\n0\n2\n5\n288\n112\n40\n2\n3\n288\n144\n23\n2\n1\n288\n160\n22\n2\n1\n288\n128\n32\n3\n3\n16\n240\n63\n3\n6\n0\n176\n104\n3\n4\n0\n128\n84\n3\n1\n0\n224\n50\n4\n3\n208\n272\n0\n4\n3\n208\n288\n0\n4\n3\n336\n256\n0\n4\n3\n288\n256\n0\n4\n3\n256\n256\n0\n5\n3\n64\n288\n0\n4\n3\n208\n240\n0\n5\n3\n112\n304\n0\n2\n3\n288\n192\n10\n4\n3\n240\n240\n0\n4\n3\n256\n240\n0\n4\n3\n320\n224\n0\n4\n3\n352\n224\n0\n5\n3\n160\n304\n0\n5\n3\n128\n256\n0\n5\n3\n80\n208\n0\n3\n16\n16\n80\n269\n3\n4\n16\n48\n64\n3\n4\n0\n0\n22\n4\n3\n176\n208\n0\n5\n4\n112\n160\n0\n4\n232\n192\n176\n0\n5\n3\n128\n48\n0\n5\n3\n80\n48\n0\n5\n3\n48\n96\n0\n5\n3\n80\n96\n0\n5\n32\n176\n32\n0\n]]","ObjectFunctions.lua":"function GetObjectType(object)\n if type(object) ~= \"table\" then\n return type(object)\n elseif not object.classtype then\n return type(object)\n end\n return object.classtype\nend\n\nfunction MustBeAnObject(self)\n if not self.IsObject then\n error(\"A function you called for \"..GetObjectType(self)..\" can only be called on objects created using \"..GetObjectType(self)..\".new().\", 3)\n end\nend","Enemies\/enemy06Worm.lua":"local enemy = Enemy:new(0, 0)\nenemy.name = \"Worm\"\nenemy.sprites = {\n default = \"Enemy5\",\n lowhealth = \"Enemy5\",\n}\nenemy.health = 80\nenemy.speed = 2.2\nenemy.score = 350\nenemy.config = {\n sprites = enemy.sprites,\n health = enemy.health,\n speed = enemy.speed,\n score = enemy.score,\n}\n\nreturn enemy","Enemies\/enemy02Virus.lua":"local enemy = Enemy:new(0, 0)\nenemy.name = \"Virus\"\nenemy.sprites = {\n default = \"Enemy1\",\n lowhealth = \"Enemy1\",\n}\nenemy.health = 100\nenemy.speed = 1.8\nenemy.score = 400\nenemy.config = {\n sprites = enemy.sprites,\n health = enemy.health,\n speed = enemy.speed,\n score = enemy.score,\n}\n\nreturn enemy","Enemies\/enemy11AdvancedTrojan.lua":"local enemy = Enemy:new(0, 0)\nenemy.name = \"Trojan Horse\"\nenemy.sprites = {\n default = \"Enemy9\",\n lowhealth = \"Enemy9\",\n}\nenemy.health = 500\nenemy.speed = 1\nenemy.score = 1250\nenemy.config = {\n sprites = enemy.sprites,\n health = enemy.health,\n speed = enemy.speed,\n score = enemy.score,\n}\n\nreturn enemy","Images\/Projectile2.lua":"draw.setscreen(1)\n--print((32-20)*.5)\ndraw.fillrect(4, 10, 16, 28, draw.gray)\nif Color then\n for k=0, 4 do\n draw.fillrect(4+k, 10, 16-k, 28, draw.gray*(1 + (k*.1)))\n end\nend\ndraw.filltriangle(10, 22, 20, 32, 0, 32, draw.black)\nif Color then\n for k=1, 10 do\n draw.filltriangle(10, 22+k, 20-k, 32, 0+k, 32, Color.new(k, k, k)*20)\n end\nend\ndraw.filltriangle(10, 4, 17, 10, 3, 10, draw.red)\nif Color then\n for k=1, 5 do\n draw.filltriangle(10, 4+k, 17-k, 10, 3+k, 10, Color.new(255 + ((5-k)*20), 0, 0))\n end\nend\nif not Color then sys.sleep(math.huge) end\n\nreturn {0, 0, 20, 32}","Enemies\/enemy04BossVirus.lua":"local enemy = Enemy:new(0, 0)\nenemy.name = \"Super Advanced Virus\"\nenemy.sprites = {\n default = \"Enemy1\",\n lowhealth = \"Enemy1\",\n}\nenemy.health = 50000\nenemy.speed = .1\nenemy.score = 10000\nenemy.config = {\n sprites = enemy.sprites,\n health = enemy.health,\n speed = enemy.speed,\n score = enemy.score,\n}\n\nreturn enemy","Classes\/Vector2.lua":"if not scWidth then\n require \"TestAngle\"\n local lfs = require \"lfs\"\n local dir = lfs.currentdir()\n local newdir = dir:sub(0, -8)\n lfs.chdir(newdir)\n dofile(\"main.lua\")\nend\nlocal Vector2 = {}\nVector2.__index = Vector2 -- failed table lookups on the instances should fallback to the class table, to get methods\nVector2.classtype = \"Vector2\"\n\nlocal cos, sin = math.cos(1), math.sin(1)\n\n-- This function constructs a new object of this type.\nVector2.new = function(x, y)\n local self = setmetatable({}, Vector2)\n self.x = x\n self.y = y\n return self\nend\n\n-- Adds a vector to this vector.\nfunction Vector2.addVectorToVector(self, vector2)\n local output = Vector2.new(self.x, self.y)\n output.x = self.x + vector2.x\n output.y = self.y + vector2.y\n return output\nend\n\n-- Subtracts a vector from this vector.\nfunction Vector2.subtractVectorFromVector(self, vector2)\n local output = Vector2.new(self.x, self.y)\n output.x = self.x - vector2.x\n output.y = self.y - vector2.y\n return output\nend\n\n-- Multiplies a vector by this vector.\nfunction Vector2.multiplyVectorByVector(self, vector2)\n local output = Vector2.new(self.x, self.y)\n output.x = self.x * vector2.x\n output.y = self.y * vector2.y\n return output\nend\n\n-- Divides a vector by this vector.\nfunction Vector2.divideVectorByVector(self, vector2)\n local output = Vector2.new(self.x, self.y)\n output.x = self.x \/ vector2.x\n output.y = self.y \/ vector2.y\n return output\nend\n\n-- The rotation functions should return a vector.\n\n-- Rotates a vector around the XY plane.\nfunction Vector2.rotate(self, degrees)\n local output = Vector2.new(self.x, self.y)\n local cos, sin = math.cos, math.sin\n local radians = math.rad(degrees)\n output.x = cos(radians)*self.x + -sin(radians)*self.y\n output.y = sin(radians)*self.x + cos(radians)*self.y\n return output\nend\n\n-- Scales a vector using the scaling 3-tuple and returns an output vector that is scaled.\nfunction Vector2.scale(self, s0, s1)\n local output = Vector2.new(self.x, self.y)\n output.x = output.x * s0\n output.y = output.y * s1\n return output\nend\n\n-- Returns the length of the vector.\nfunction Vector2:length()\n return math.sqrt(self.x*self.x + self.y*self.y)\nend\n\n-- Normalizes the vector.\nfunction Vector2:normalize()\n local output = Vector2.new(self.x, self.y)\n local length = output:length()\n if length ~= 0 then\n output.x = output.x\/length\n output.y = output.x\/length\n end\n return output\nend\n\nfunction Vector2:dotProduct(vector2)\n return (self.x*vector2.x) + (self.y*vector2.y)\nend\n\nlocal abs = math.abs\n-- Returns a radian value that is the angle an object at this position would be when looking at vector2.\n-- This function is bugged, please post a corrected version that looks at the target 100% of the time please.\nfunction Vector2:pointTowards(vector2)\n local origin = self:normalize()\n local A = self - origin\n local B = vector2 - origin\n\n --A = A:normalize()\n --B = B:normalize()\n\n local thetaA = math.atan2(A.x, A.y)\n local thetaB = math.atan2(B.x, B.y)\n\n local thetaAB = thetaB - thetaA\n while (thetaAB <= -math.pi) do\n thetaAB = thetaAB + (math.pi*2)\n end\n\n while (thetaAB > math.pi) do\n thetaAB = thetaAB - (math.pi*2)\n end\n\n return -thetaAB + (math.pi*.5)\n --[[\n local U = self - self*1.01\n local V = vector2 - self*1.01\n\n local magU = U:length()\n local magV = V:length()\n local magUmagV = magU*magV\n\n local cosT = U:dotProduct(V) \/ magUmagV\n local theta = math.acos(cosT)\n return theta]]\n --[=[\n --local offset = vector2 - self\n --local dif = offset\/math.max(offset:raw())\n --local x, y = offset:raw()\n local a, b = self:normalize(), vector2:normalize()\n --[[local xflip, yflip = false, false\n if b.x > a.x then\n xflip = true\n b, a = a, b\n end\n if b.y > a.y and not xflip then\n yflip = true\n b, a = a, b\n end]]\n --local ax, ay, bx, by\n local ax, ay = a:raw()\n local bx, by = b:raw()\n --[[if by - ay > 0 then\n ax, ay = a:raw()\n bx, by = b:raw()\n else\n ax, ay = b:raw()\n bx, by = a:raw()\n end]]\n local atimesb = (ax*bx) + (ay*by)\n local angle = math.cos(atimesb)\n local magnitude = a:length()*b:length()*math.sin(angle)\n --math.atan2(by, bx) - math.atan2(ay, ax)\n return math.atan2(angle, magnitude)\n --[[\n local absa = abs(math.sqrt((ax^2) + (ay^2)))\n local absb = abs(math.sqrt((bx^2) + (by^2)))\n local answer = atimesb\/(absa*absb)\n return (answer*math.pi)\/2]]\n --[[\n if offset.x < 0 then\n dif.x = math.abs(dif.x)\n end\n return math.cos(dif.x)--math.sin(dif.y)]]]=]\nend\n\n-- Returns the raw position for this vector2.\nfunction Vector2:raw()\n return self.x, self.y\nend\n\n-- Set up metatables\nVector2.__tostring = function(self)\n return self.x..\", \"..self.y\nend\nVector2.__add = function(self, other)\n if GetObjectType(other) ~= \"Vector2\" then\n return self\n end\n return self:addVectorToVector(other)\nend\nVector2.__sub = function(self, other)\n if GetObjectType(other) ~= \"Vector2\" then\n return self\n end\n return self:subtractVectorFromVector(other)\nend\nVector2.__mul = function(self, other)\n if GetObjectType(other) ~= \"Vector2\" then\n if type(other) == \"number\" then\n return Vector2.new(self.x*other, self.y*other)\n end\n return self\n end\n return self:multiplyVectorByVector(other)\nend\nVector2.__div = function(self, other)\n if GetObjectType(other) ~= \"Vector2\" then\n if type(other) == \"number\" then\n return Vector2.new(self.x\/other, self.y\/other)\n end\n return self\n end\n return self:divideVectorByVector(other)\nend\n\nVector2.__eq = function(self, other)\n if GetObjectType(other) ~= \"Vector2\" then\n return false\n end\n if self.x == other.x and self.y == other.y then\n return true\n end\n return false\nend\nVector2.__lt = function(self, other)\n if GetObjectType(other) ~= \"Vector2\" then\n return false\n end\n if self.x < other.x and self.y < other.y then\n return true\n end\n return false\nend\nVector2.__le = function(self, other)\n if GetObjectType(other) ~= \"Vector2\" then\n return false\n end\n if self.x <= other.x and self.y <= other.y then\n return true\n end\n return false\nend\n\nreturn Vector2","Classes\/Projectile.lua":"local Projectile = {}\nProjectile.__index = Projectile -- failed table lookups on the instances should fallback to the class table, to get methods\nProjectile.classtype = \"Projectile\"\n\nlocal cos, sin = math.cos(1), math.sin(1)\n\n-- This function constructs a new object of this type.\nProjectile.new = function(self, x, y, key, myTower)\n if not self then\n error(\"self is nil\", 2)\n end\n local config = self.config\n local self = setmetatable({}, Projectile)\n self.myTower = myTower\n self.position = Vector2.new(x, y)\n if stage then\n self.enemyTarget = stage.enemies[key]\n end\n self.target = Vector2.new(tx, ty)\n self.speed = 8\n self.sprite = \"default\"\n self.sprites = {\n default = \"Projectile1\",\n }\n self.power = 4\n if stage then\n self.id = #stage.projectiles + 1\n end\n if config then\n for k, v in pairs(config) do\n self[k] = v\n end\n end\n return self\nend\n\n-- Projectile Object Functions --\n-- Handles the Projectile AI for this frame.\nfunction Projectile:HandleAI()\n if self.enemyTarget then\n self.target = self.enemyTarget.position\n else\n return self:destroy()\n end\n if self.target then\n self.rotation = self.position:pointTowards(self.target)\n -- Move projectile closer to target position\n local offset = self.position - self.target\n if math.abs(offset.x) > 0 or math.abs(offset.y) > 0 then\n local g = math.max(math.abs(offset.x), math.abs(offset.y))\n local moveValue = Vector2.new((offset.x\/g)*self.speed, (offset.y\/g)*self.speed)--self.speed\n self.position = self.position - moveValue\n if self.position.x - moveValue.x > self.target.x and moveValue.x < 0 then\n self.position.x = self.target.x\n elseif self.position.x - moveValue.x < self.target.x and moveValue.x > 0 then\n self.position.x = self.target.x\n end\n if self.position.y - moveValue.y > self.target.y and moveValue.y < 0 then\n self.position.y = self.target.y\n elseif self.position.y - moveValue.y < self.target.y and moveValue.y > 0 then\n self.position.y = self.target.y\n end\n else\n return self:destroy()\n end\n end\n local destroy = false\n -- Destroy enemies\n for k, v in pairs(stage.enemies) do\n if math.abs(self.position.x - v.position.x) < v.size and math.abs(self.position.y - v.position.y) < v.size then\n if v:damage(self.power, self.knockback or 0) then\n destroy = true\n self.myTower.vanquishes = self.myTower.vanquishes + 1\n end\n if not self.splashDamage then\n self:destroy()\n return\n end\n end\n end\n if destroy then self:destroy() end\nend\n\n-- This function will destroy the projectile on the next frame.\nfunction Projectile:destroy()\n table.insert(stage.deadProjectiles, self.id)\nend\n\n-- This function is called to draw this projectile.\nfunction Projectile:draw()\n local x, y = self.position:raw()\n local imagel = self.sprites[self.sprite] or self.sprites[\"default\"]\n draw.transformedimage(image(imagel), x, y, imgres(), self.rotation or 0)\nend\n\nreturn Projectile","Enemies\/enemy08BossWorm.lua":"local enemy = Enemy:new(0, 0)\nenemy.name = \"Boss Worm\"\nenemy.sprites = {\n default = \"Enemy5\",\n lowhealth = \"Enemy5\",\n}\nenemy.health = 48600\nenemy.speed = .8\nenemy.score = 12500\nenemy.config = {\n sprites = enemy.sprites,\n health = enemy.health,\n speed = enemy.speed,\n score = enemy.score,\n instaDeath = true,\n}\n\nreturn enemy","Images\/Enemy5.lua":"-- Draw body\nlocal body = draw.orange\ndraw.setscreen(1)\n--draw.fillrect(0,0,48,48,draw.magenta)\n--draw.fillroundedrect(18, 8, 30, 40, 4.5, draw.orange)\ndraw.setlinestyle(8, \"round\")\n--draw.setlinestyle(4, \"round\")\ndraw.line(24, 16, 24, 19, body)\ndraw.lineto(22, 23, body)\ndraw.lineto(20, 25, body)\ndraw.lineto(18, 28, body)\ndraw.lineto(17, 30, body)\ndraw.lineto(16, 33, body)\ndraw.lineto(18, 35, body)\ndraw.lineto(19, 36.6, body)\ndraw.lineto(20.2, 38.4, body)\ndraw.lineto(23.5, 39.8, body)\ndraw.lineto(28, 38.8, body)\n--draw.fillrect(18, 24, 30, 40, draw.orange)\n--draw.filltriangle(18, 40, 24, 48, 30, 40, draw.orange)\n-- Draw face\ndraw.fillroundedrect(15, 4, 33, 16, 6, body)\n--draw.filltriangle(18, 4, 24, 7, 30, 4, draw.gray)\ndraw.setlinestyle(1, \"round\")\ndraw.fillcircle(20, 8, 3.1, draw.black)\ndraw.fillcircle(20, 7.75, 2, draw.white)\ndraw.fillcircle(28, 8, 3.1, draw.black)\ndraw.fillcircle(28, 7.75, 2, draw.white)\nif not Color then sys.sleep(math.huge) end\nreturn {0, 0, 48, 48}","Towers\/tower5MaliciousSoftwareRepairTool.lua":"local tower = Tower:new(0, 0)\ntower.name = \"MalwareRepairTool\"\ntower.sprites = {\n default = \"Tower5\",\n}\ntower.power = 0\ntower.firerate = 60\ntower.baserepair = .022\ntower.cost = 2000 - 930\ntower.projectile = nil\ntower.upgrades = {\n {\n name = \"Level 2\",\n cost = 400,\n upgrade = {\n [\"baserepair\"] = {upgradetype = \"percent\", value = 100},\n }\n },\n {\n name = \"Level 3\",\n cost = 2000,\n upgrade = {\n [\"baserepair\"] = {upgradetype = \"percent\", value = 100},\n }\n },\n {\n name = \"Level 4\",\n cost = 8000,\n upgrade = {\n [\"baserepair\"] = {upgradetype = \"percent\", value = 100},\n [\"firerate\"] = {upgradetype = \"percent\", value = -10}\n }\n },\n {\n name = \"Level 5\",\n cost = 40000,\n upgrade = {\n [\"baserepair\"] = {upgradetype = \"percent\", value = 100},\n [\"firerate\"] = {upgradetype = \"percent\", value = -25}\n }\n },\n}\ntower.config = {\n name = tower.name,\n projectile = 0,\n upgrades = tower.upgrades,\n sprites = tower.sprites,\n power = tower.power,\n firerate = tower.firerate,\n baserepair = tower.baserepair,\n coingen = tower.coingen,\n cost = tower.cost,\n}\nreturn tower","Classes\/Enemy.lua":"if not scWidth then\n local lfs = require \"lfs\"\n local dir = lfs.currentdir()\n local newdir = dir:sub(0, -8)\n lfs.chdir(newdir)\n dofile(\"main.lua\")\nend\nlocal Enemy = {}\nEnemy.__index = Enemy -- failed table lookups on the instances should fallback to the class table, to get methods\nEnemy.classtype = \"Enemy\"\n\nlocal cos, sin = math.cos(1), math.sin(1)\n\n-- This function constructs a new object of this type.\nEnemy.new = function(self, x, y)\n if not self then\n error(\"self is nil\", 2)\n end\n local config = self.config\n local self = setmetatable({}, Enemy)\n self.position = Vector2.new(x, y)\n self.target = Vector2.new(-70, 160 + ((math.random() - .5)*160))\n self.size = 32\n self.speed = 4\n self.health = 10\n self.score = 100\n self.sprite = \"default\"\n self.sprites = {\n default = \"Enemy1\",\n fire = \"Enemy1\",\n damaged = \"Enemy1\",\n lowhealth = \"Enemy1\",\n }\n if config then\n for k, v in pairs(config) do\n self[k] = v\n end\n end\n self.affectedByKnockback = self.health < 10000\n self.boss = self.health >= 10000\n if stage then\n self.id = #stage.enemies + 1\n if stage.round then\n local roundNum = stage.round - 19.1\n self.health = self.health*math.max((-6 + ((roundNum*selectedDif)*.75))\/((self.boss and 23.33333) or 1), 1)\n end\n end\n self.maxHealth = self.health\n -- Rotate the enemy towards the target\n self.rotation = self.position:pointTowards(self.target)-math.pi\n return self\nend\n\n-- Enemy Functions --\n-- Handles the enemy AI for this frame.\nfunction Enemy:HandleAI()\n -- Move enemy closer to target position.\n local offset = self.position - self.target\n if math.abs(offset.x) > 0 or math.abs(offset.y) > 0 then\n local g = math.max(math.abs(offset.x), math.abs(offset.y))\n local moveValue = Vector2.new((offset.x\/g)*self.speed, (offset.y\/g)*self.speed)\n self.position = self.position - moveValue\n if self.position.x < -48 then\n stage.health = stage.health - 1\n if self.instaDeath or stage.instaDeath then\n stage.health = 0\n end\n return self:infect()-- destroy enemy\n end\n if self.position.x - moveValue.x > self.target.x and moveValue.x < 0 then\n self.position.x = self.target.x\n elseif self.position.x - moveValue.x < self.target.x and moveValue.x > 0 then\n self.position.x = self.target.x\n end\n if self.position.y - moveValue.y > self.target.y and moveValue.y < 0 then\n self.position.y = self.target.y\n elseif self.position.y - moveValue.y < self.target.y and moveValue.y > 0 then\n self.position.y = self.target.y\n end\n end\nend\n\n-- This function when called will damage this enemy.\nfunction Enemy:damage(power, knockback)\n if self.affectedByKnockback then\n self.position.x = math.min(self.position.x + (knockback*(1-(self.health\/self.maxHealth))), 400)\n end\n self.health = self.health - power\n if (self.health <= 0 and self.health~=math.huge) or power == math.huge then\n return self:destroy()\n end\nend\n\n-- This function will destroy an enemy.\nfunction Enemy:destroy()\n table.insert(stage.deadEnemies, self.id)\n stage.score = stage.score + (self.score\/20)\n stage.coins = stage.coins + (self.score\/20)\n sound.playeffect(\"@resources\/Blast.mp3\", .1)\n return true\nend\n\n-- This function is called when an enemy reaches the goal position.\nfunction Enemy:infect()\n table.insert(stage.deadEnemies, self.id)\n return true\nend\n\n-- This function is called automaticly to draw the enemy.\nfunction Enemy:draw()\n local x, y = self.position:raw()\n local imagel = self.sprites[self.sprite] or self.sprites[\"default\"]\n draw.transformedimage(image(imagel), x, y, imgres(), self.rotation or 0)\n draw.fillrect(x - 25, y - 33, x + 25, y - 23, draw.black)\n if self.health < math.huge then\n local healthbar = ((self.health\/self.maxHealth)*48)\n local g = math.min(6, healthbar)\n for k=1, g do\n draw.fillrect(x - 24, y - 32, x - 24 + (healthbar*(1-(k-1)\/g)), y - 24, draw.green*(1-(k\/(g*1.25))))\n end\n else\n draw.fillrect(x - 24, y - 32, x + 24, y - 24, draw.white)\n end\n draw.rect(x - 25, y - 33, x + 25, y - 23, draw.black)\n draw.stringinrect(string.shortNum(self.health), x - 48, y - 48, x + 48, y - 24, draw.white)\nend\n\nreturn Enemy","Classes\/TestAngle.lua":"if scWidth then return end\nscWidth = true\ndofile(\"..\/ObjectFunctions.lua\")\nVector2 = require \"Vector2\"\nlocal width, height = draw.getport()\nlocal vect = Vector2.new(width*.5, height*.5)\nlocal touch = vect.new(vect.x, vect.y*.5)\nlocal angle = vect:pointTowards(touch)\ndraw.setscreen(1)\ndraw.settitle(\"The tower should look at the ball 100% of the time.\")\n\nfunction moveVector(x, y)\n touch = touch.new(x, y)\n angle = vect:pointTowards(touch)\nend\n\ndraw.tracktouches(moveVector,moveVector,moveVector)\nwhile true do\n draw.doevents()\n draw.beginframe()\n draw.clear(draw.green)\n draw.line(vect.x, vect.y, touch.x, touch.y, draw.white)\n draw.transformedimage(\"@resources\/Tower1.png\", vect.x, vect.y, 1, angle*math.pi)\n draw.string(\"Current Angle: \"..(math.floor(angle*1000)\/1000)..\" radians (\"..(math.floor(math.deg(angle)*10000)\/10000)..\" degrees)\", 0, 48, draw.black)\n draw.fillcircle(touch.x, touch.y, 8, draw.black)\n draw.endframe()\nend","UpdateNotes.txt":"-- Update Notes --\n--[===[\n[=[Version 1.0.3]=]\n[[Added items]]\n*None.\n\n[[Changes]]\n*Changes to rebalance the game.\n*Changed some rounds past round 20 to be easier.\n*Reduced the health of enemies.\n*Increased the damage limit of turrets to 1,000,000.\n*\n\n[[Bug Fixes]]\n*Fixed bug where draw.tracktouches would cause the game to throw an error and not work if Touch Lua was updated to 1.3.9.\n\n[=[Version 1.0.2]=]\n[[Added items]]\n*None.\n\n[[Changes]]\n*You can now restart the current round on the Game Over screen.\n*\n\n[[Bug Fixes]]\n*\n\n[=[Version 1.0.1]=]\n[[Added items]]\n*Almost no new stuff except extra hints.\n\n[[Changes]]\n*Fixed the screen region to 480x320.\n*Rebalanced the game slightly.\n*Made some rounds between round 13 and round 19 longer.\n*Made round 20 more dangerous.\n*Upgraded the appearance of the MalwareRemovalTool.\n*Renamed some of the turrets.\n*Renamed the difficulty settings.\n\n[[Bug fixes]]\n*Removed unused commented code.\n*Fixed bug where images would not be automatically generated if they did not exist.\n*Fixed hint strings to have the word \"Scripts\" with the casing of a proper noun.\n*Added the text \"Undo Build\" to the \"Remove\" button.\n*The game now cannot be loaded if no save file is present.\n*The game will reset the stage if there is an error loading the save file, instead of crashing.\n\n[[Missing features]]\n*The Legion of Doom removed the Read Me file that was supposed to be in the updated version.\n]===]","gameRounds.lua":"if not scWidth then require \"main\" end\nround = {}\nfunction genRounds()\n round[1] = {\n hint = \"The firewall is the last defence blocking malicious software from being installed on your network by the Legion of Doom. If a computer is infected with malware the malware will spread and format the hard drives on the network, destroying your work. Build a MacroScript Turret to destroy the malware.\",\n time = 40,\n enemies = {\n [40] = {1},\n [35] = {1},\n [30] = {1},\n [25] = {1},\n [20] = {1},\n [15] = {1},\n [10] = {1},\n [5] = {1},\n [1] = {1, 1},\n }\n }\n round[2] = {\n hint = \"Defeating malware has earned you some Scripts which can be used to purchase more towers.\",\n time = 30,\n enemies = {\n [30] = {1, 1},\n [25] = {1, 1},\n [20] = {1, 1},\n [15] = {1, 1},\n [10] = {1, 1},\n [5] = {1, 1},\n [2] = {1, 1},\n }\n }\n round[3] = {\n hint = \"That turret won't be enough to ward against the next wave of viruses. Fortunately you have collected enough Scripts to build another turret. Try building another one.\",\n time = 20,\n enemies = {}\n }\n for k=20, .5, -.5 do\n round[3].enemies[k] = {1, 1}\n end\n\n round[4] = {\n hint = \"You have collected enough Scripts for an upgrade to your turrets. Tap on a turret to select it, then tap the upgrade button.\",\n time = 20,\n enemies = {\n [20] = {1},\n [17] = {1, 1},\n [14] = {1, 1, 1},\n [11] = {1, 1, 1, 1},\n [8] = {1, 1, 1, 1, 1},\n [5] = {1, 1, 1, 1, 1, 1},\n [2] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},\n }\n }\n round[5] = {\n hint = \"Your game is automatically saved after each round. You can also manually save when a round is not running by rubbing the Start Round button until it shows Save.\",\n time = 1,\n enemies = {\n [1] = {5, 5, 5, 5},\n }\n }\n round[6] = {\n hint = \"The Legion of Doom is using four different classes of malware to attack your firewall. The classes are Viruses, Worms, Trojan Horses, and Rootkits.\",\n time = 15,\n enemies = {}\n }\n for k=15, 5.5, -.5 do\n round[6].enemies[k] = {1, 1}\n end\n for k=5, .5, -.5 do\n round[6].enemies[k] = {5, 5}\n end\n round[7] = {\n hint = \"Nice job defending against the last wave of malware. I think that they should have already figured out that it will take more dangerous malware to destroy this network. You should prepare for the next wave.\",\n time = 15,\n enemies = {\n [15] = {2, 2},\n [12] = {2, 2},\n [9] = {2, 2},\n [6] = {2, 2},\n [3] = {2, 2},\n }\n }\n round[8] = {\n time = 20,\n enemies = {\n [20] = {5},\n [15] = {1, 1, 1, 1},\n [10] = {1, 1, 1},\n [5] = {2, 2},\n }\n }\n round[9] = {\n time = 25,\n enemies = {\n [25] = {6},\n [20] = {5, 5, 5, 5},\n [15] = {5, 5, 5, 5},\n [10] = {1, 1, 1, 1},\n [5] = {2, 2, 2, 2},\n }\n }\n round[10] = {\n time = 40,\n enemies = {\n [40] = {6},\n [30] = {5, 5, 5, 5, 5, 5},\n [20] = {5, 5},\n [10] = {6, 6},\n [5] = {2, 2, 2, 2, 2, 2},\n }\n }\n round[11] = {\n hint = \"The Legion of Doom has sent a huge wave of viruses to attack the firewall. Make sure you are ready to defend! If you succeed you will earn a lot of Scripts.\",\n time = 200,\n enemies = {\n [99*2] = {1,1,1,1,1,1,1,1,1,1,1,1,1},\n [98*2] = {1,1,1,1,1,1,1,1,1,1,1,1,2},\n [97*2] = {1,1,1,1,1,1,1,1,1,1,1,1,2},\n [96*2] = {1,1,1,1,1,1,1,1,1,1,1,1,2},\n [95*2] = {1,1,1,1,1,1,1,1,1,1,1,1,2},\n [94*2] = {1,1,1,1,1,1,1,1,1,1,1,1,2},\n [93*2] = {1,1,1,1,1,1,1,1,1,1,1,1,2},\n [92*2] = {1,1,1,1,1,1,1,1,1,1,1},\n [90*2] = {2,2,2,2,2,2,2,2},\n [88*2] = {2,2,2,2,2,2,2,2},\n [86*2] = {2,2,2,2,2,2,2,2},\n [84*2] = {2,2,2,2,2,2,2,2},\n [82*2] = {2,2,2,2,2,2,2,2},\n [80*2] = {2,2,2,2,2,2,2,2},\n [78*2] = {2,2,2,2,2,2,2,2},\n [76*2] = {2,2,2,2,2,2,2,2},\n [74*2] = {2,2,2,2,2,2,2,2},\n [72*2] = {2,2,2,2,2,2,2,2},\n [70*2] = {2,2,2,2,2,2,2,2},\n [65*2] = {2,2,2,2,2,2,2,2},\n [60*2] = {2,2,2,2,2,2,2,2},\n [55*2] = {2,2,2,2,2,2,2,2},\n [50*2] = {2,2,2,2,2,2,2,2},\n [40*2] = {6, 6, 6, 6, 6},\n [35*2] = {2,2,2,2,2,2,2,2},\n [30*2] = {2, 6, 2, 6, 2},\n [20*2] = {3},\n [10*2] = {2},\n }\n }\n round[12] = {\n hint = \"Please consider purchasing the ScriptMiner. It will generate Scripts as you defend against the malware.\",\n time = 50,\n enemies = {\n [50] = {5, 5, 5, 5, 5},\n [45] = {6, 6, 6, 6, 6},\n [40] = {2, 6, 2, 6, 2},\n [30] = {3},\n [10] = {3},\n }\n }\n round[13] = {\n time = 50,\n enemies = {}\n }\n for k=50, 1, -1 do\n round[13].enemies[k] = {6, 2}\n end\n round[14] = {\n hint = \"The Legion of Doom is sending out more powerful variants of the malware that you are seeing here. It only gets harder from here on out.\",\n time = 40,\n enemies = {\n [40] = {6, 6, 6, 6},\n [30] = {6, 6, 6, 6},\n [20] = {6, 6, 6, 6},\n [10] = {6, 6, 6, 6},\n }\n }\n round[15] = {\n time = 45,\n enemies = {\n [45] = {3, 3, 3, 3, 3},\n [30] = {6, 6, 6, 6, 6},\n [15] = {3, 3, 3, 3, 3},\n }\n }\n round[16] = {\n hint = [[Placed a turret in the wrong position? You can remove a turret by tapping on it and pressing the \"Undo Build\" button.]],\n time = 50,\n enemies = {\n [45] = {3, 3, 3, 3, 3},\n [35] = {7, 7, 7, 7, 7},\n [25] = {3, 3, 3, 3, 3},\n [15] = {7, 7, 7, 7, 7},\n }\n }\n round[17] = {\n time = 60,\n enemies = {\n [60] = {10, 10, 11, 10, 10},\n [50] = {1,1,1,1,1,1,1,1,1,1,1},\n [40] = {1,1,1,1,1,1,1,1,1,1,1},\n [30] = {1,1,1,1,1,1,1,1,1,1,1},\n [20] = {1,1,1,1,1,1,1,1,1,1,1},\n [10] = {2,2,2,2,2,2,2,2,2,2,2},\n }\n }\n round[18] = {\n hint = \"Nice job defending against the trojan horses.\",\n time = 75,\n enemies = {\n [75] = {10},\n [65] = {2, 6, 2, 6},\n [55] = {9, 9, 9, 9},\n [50] = {2, 6, 2, 6},\n [40] = {2, 2, 3, 2, 2},\n [30] = {7},\n [20] = {2, 6, 2, 6},\n [10] = {7}\n }\n }\n round[19] = {\n time = 90,\n enemies = {\n [90] = {3, 2, 2, 2, 3},\n [70] = {2, 6, 2, 6},\n [60] = {10},\n [55] = {9, 9, 9, 9},\n [50] = {2, 6, 2, 6},\n [40] = {2, 2, 3, 2, 2},\n [30] = {7},\n [20] = {2, 6, 2, 6},\n [10] = {7}\n }\n }\n round[20] = {\n hint = \"Watch out, defender, this round is going to be a dangerous one. You will want to place down some Rocket Launchers or Energy Blasters.\",\n time = 150,\n enemies = {\n [150] = {3, 3, 3, 3, 3, 3, 3},\n [145] = {3, 3, 3, 3, 3, 3, 3},\n [140] = {3, 3, 3, 3, 3, 3, 3},\n [135] = {3, 3, 3, 3, 3, 3, 3},\n [130] = {3, 3, 3, 3, 3, 3, 3},\n [125] = {7, 7, 7, 7, 7},\n [120] = {3, 3, 3, 3, 3},\n [115] = {7, 7, 7, 7, 7},\n [110] = {3, 3, 3, 3, 3},\n [105] = {7, 7, 7, 7, 7},\n [100] = {3, 3, 3, 3, 3},\n [95] = {3, 3, 3, 3, 3},\n [90] = {3, 3, 3, 3, 3},\n [85] = {3, 3, 3, 3, 3},\n [80] = {3, 3, 3, 3, 3},\n [75] = {3, 3, 3, 3, 3},\n [70] = {7, 7, 7, 7, 7},\n [60] = {3, 3, 3, 3, 3},\n [50] = {7, 7, 7, 7, 7},\n [35] = {3, 7, 3},\n [20] = {6, 3, 6},\n [0] = {4},\n }\n }\n -- End of normal rounds, generate additional rounds using logic. --\n for roundNum = 21, 100 do\n local time = 100 + ((roundNum - 20)*10)\n round[roundNum] = {\n time = time,\n enemies = {}\n }\n -- Do enemy additions --\n if roundNum <= 29 then\n for k=time, 1, -2 do\n round[roundNum].enemies[k] = {2, 2, 2}\n end\n elseif roundNum <= 30 then\n for k=time, 1, -2 do\n round[roundNum].enemies[k] = {2, 3, 5, 2}\n end\n elseif roundNum < 40 then\n for k=time, 1, -2 do\n round[roundNum].enemies[k] = {3, 6, 3}\n end\n elseif roundNum == 40 then\n round[roundNum].time = 1\n elseif roundNum <= 50 then\n for k=time, 1, -2 do\n round[roundNum].enemies[k] = {3, 6, 3}\n end\n elseif roundNum < 60 then\n for k=time, 1, -2 do\n round[roundNum].enemies[k] = {7, 6, 3}\n end\n elseif roundNum == 60 then\n round[roundNum].time = 1\n else\n for k=time, 1, -2 do\n round[roundNum].enemies[k] = {3, 6, 3}\n end\n end\n if roundNum == 40 then\n round[roundNum].enemies[0] = {4}\n elseif roundNum == 60 then\n round[roundNum].enemies[0] = {8}\n elseif roundNum == 80 then\n round[roundNum].enemies[0] = {12}\n elseif roundNum == 100 then\n round[roundNum].enemies[0] = {16}\n elseif roundNum > 40 then\n round[roundNum].enemies[0] = {8}\n end\n coroutine.yield(roundNum)\n end\n\n -- Clone the already existing rounds --\n function table.clone(tab)\n local newTab = {}\n for k, v in pairs(tab) do\n if type(v) == \"table\" then\n newTab[k] = table.clone(v)\n elseif type(v) == \"number\" then\n newTab[k] = v + 1 - 1\n else\n newTab[k] = v\n end\n end\n return newTab\n end\n for k, v in pairs(round) do\n local newEnemies = {}\n for k2, v2 in pairs(v.enemies) do\n newEnemies[math.floor(k2*30)] = v2\n end\n v.enemies = newEnemies\n end\n if true then\n local tr = #round\n for k=1, 1 do\n for r = 1 + (k*tr), tr + (k*tr) do\n local rn = table.clone(round[r - (k*tr)])\n for t, tv in pairs(rn.enemies) do\n for en, ev in pairs(tv) do\n for l = 1, math.min(k - 1, 2) do\n if ev\/4 == math.floor(ev\/4) then\n else\n ev = ev + 1\n end\n end\n tv[en] = ev\n end\n end\n round[r] = rn\n coroutine.yield(r)\n end\n end\n end\n print(\"Rounds loaded\")\nend\nlocal genRounds = coroutine.wrap(genRounds)\ncontinueGenOfRounds = function()\n local ok, rounds = pcall(genRounds)\n if ok then\n return rounds\n else\n Hud.roundsLoaded = true\n return #round\n end\nend","Images\/Projectile3.lua":"draw.setscreen(1)\n--print((32-20)*.5)\nif Color then\n for k=0.1, 16, .1 do\n draw.fillcircle(16, 16, 16-k, Color.new(0, 0, 1, 1\/(160), true))\n end\nelse\n draw.fillcircle(16, 16, 16, draw.blue)\nend\nif not Color then sys.sleep(math.huge) end\n\nreturn {0, 0, 32, 32}","Enemies\/enemy05BasicWorm.lua":"local enemy = Enemy:new(0, 0)\nenemy.name = \"Basic Worm\"\nenemy.sprites = {\n default = \"Enemy5\",\n lowhealth = \"Enemy5\",\n}\nenemy.health = 20\nenemy.speed = 2\nenemy.config = {\n sprites = enemy.sprites,\n health = enemy.health,\n speed = enemy.speed,\n}\n\nreturn enemy","Towers\/tower2RocketLauncher.lua":"local tower = Tower:new(0, 0)\ntower.name = \"Lua Rocket Launcher\"\ntower.sprites = {\n default = \"Tower2\",\n}\ntower.power = 100\ntower.firerate = 30\ntower.range = 60\ntower.cost = 400\ntower.knockback = 3\ntower.projectile = Projectile:new()\ntower.projectile.sprites = {\n default = \"Projectile2\",\n}\ntower.projectile.config = {\n sprites = tower.projectile.sprites\n}\ntower.upgrades = {\n {\n name = \"Level 2\",\n cost = 600,\n upgrade = {\n [\"power\"] = {upgradetype = \"percent\", value = 33},\n [\"range\"] = {upgradetype = \"percent\", value = 17}\n }\n },\n {\n name = \"Level 3\",\n cost = 1200,\n upgrade = {\n [\"power\"] = {upgradetype = \"percent\", value = 33},\n [\"range\"] = {upgradetype = \"percent\", value = 17}\n }\n },\n {\n name = \"Level 4\",\n cost = 2000,\n upgrade = {\n [\"power\"] = {upgradetype = \"percent\", value = 33},\n [\"range\"] = {upgradetype = \"percent\", value = 17},\n [\"firerate\"] = {upgradetype = \"percent\", value = -17}\n }\n },\n {\n name = \"Level 5\",\n cost = 3000,\n upgrade = {\n [\"power\"] = {upgradetype = \"percent\", value = 33},\n [\"range\"] = {upgradetype = \"percent\", value = 17},\n [\"firerate\"] = {upgradetype = \"percent\", value = -10}\n }\n }\n}\ntower.config = {\n name = tower.name,\n upgrades = tower.upgrades,\n sprites = tower.sprites,\n power = tower.power,\n range = tower.range,\n knockback = tower.knockback,\n firerate = tower.firerate,\n baserepair = tower.baserepair,\n coingen = tower.coingen,\n cost = tower.cost,\n projectile = tower.projectile\n}\nreturn tower","Enemies\/enemy01BasicVirus.lua":"local enemy = Enemy:new(0, 0)\nenemy.name = \"Basic Virus\"\nenemy.sprites = {\n default = \"Enemy1\",\n lowhealth = \"Enemy1\",\n}\nenemy.health = 6\nenemy.speed = 1.25\nenemy.config = {\n sprites = enemy.sprites,\n health = enemy.health,\n speed = enemy.speed,\n}\n\nreturn enemy","sound.lua":"sound = {}\nsound.isAudioEnabled = true\n\n-- Copy functions from audio library --\nsound.audioFunctions = {\n \"playbg\",\n \"playeffect\",\n \"playbuffer\",\n \"savebuffer\",\n \"stopbg\",\n \"stopalleffects\",\n \"stopeverything\",\n \"preloadeffect\",\n \"preloadbg\",\n \"unloadeffect\",\n \"unloadalleffects\",\n \"pausepg\",\n \"pauseall\",\n \"resumepg\",\n \"resumeall\",\n \"mutepg\",\n \"muteall\",\n \"unmuteall\",\n \"unmutepg\",\n \"setbgvolume\",\n \"bgplaying\",\n \"bgmuted\",\n \"allmuted\",\n \"bgpaused\",\n \"allpaused\",\n \"bgvolume\",\n}\n\n-- This is the function that attempts to call the audio library's functions if possible.\nlocal callAudioFunction = function(funct, ...)\n if sound.isAudioEnabled then\n return audio[funct](...)\n end\n return false\nend\n\n-- Now we copy the audio functions to sound.\nfor k, v in pairs(sound.audioFunctions) do\n sound[v] = function(...)\n return callAudioFunction(v, ...)\n end\nend","Images\/Tower2.lua":"draw.fillcircle(24, 24, 16, draw.black)\nfor k=14, 0, -1 do\n draw.fillcircle(24, 24, k, Color.new(.1, .1, .1, 1, true)*(2-(k\/8)))\nend\ndraw.fillroundedrect(16, 0, 32, 24, 4, draw.darkgray)\ndraw.fillcircle(24, 24, 12, {.25, .28, .3, 1})\nreturn {0, 0, 48, 48}","Images\/Tower4.lua":"draw.fillcircle(24, 24, 16, draw.black)\nfor k=14, 0, -1 do\n draw.fillcircle(24, 24, k, Color.new(.1, .1, .1, 1, true)*(2-(k\/8)))\nend\ndraw.fillcircle(24, 24, 12, draw.yellow)\nreturn {0, 0, 48, 48}","Towers\/tower1Turret.lua":"local tower = Tower:new(0, 0)\ntower.name = \"MacroScript Turret\"\ntower.sprites = {\n default = \"Tower1\",\n}\ntower.power = 4\ntower.firerate = 8\ntower.upgrades = {\n {\n name = \"Level 2\",\n cost = 200,\n upgrade = {\n [\"power\"] = {upgradetype = \"percent\", value = 50},\n [\"range\"] = {value = 110}\n }\n },\n {\n name = \"Level 3\",\n cost = 400,\n upgrade = {\n [\"power\"] = {upgradetype = \"percent\", value = 75},\n [\"range\"] = {value = 128},\n [\"firerate\"] = {value = 7}\n }\n },\n {\n name = \"Level 4\",\n cost = 800,\n upgrade = {\n [\"power\"] = {upgradetype = \"percent\", value = 100},\n [\"range\"] = {value = 140},\n [\"firerate\"] = {value = 6}\n }\n },\n {\n name = \"Level 5\",\n cost = 3000,\n upgrade = {\n [\"power\"] = {upgradetype = \"percent\", value = 100},\n [\"range\"] = {value = 160},\n [\"firerate\"] = {value = 5}\n }\n }\n}\ntower.config = {\n name = tower.name,\n upgrades = tower.upgrades,\n sprites = tower.sprites,\n power = tower.power,\n firerate = tower.firerate,\n baserepair = tower.baserepair,\n coingen = tower.coingen,\n cost = tower.cost,\n}\nreturn tower","Enemies\/enemy07AdvancedWorm.lua":"local enemy = Enemy:new(0, 0)\nenemy.name = \"Advanced Worm\"\nenemy.sprites = {\n default = \"Enemy5\",\n lowhealth = \"Enemy5\",\n}\nenemy.health = 240\nenemy.speed = 3.2\nenemy.score = 700\nenemy.config = {\n sprites = enemy.sprites,\n health = enemy.health,\n speed = enemy.speed,\n score = enemy.score,\n}\n\nreturn enemy","gameRegenImages.lua":"-- This script will regenerate images. --\nrequire \"ObjectFunctions\"\nColor = require \"Classes\/Color\"\ndraw.setscreen(1)\nlocal scWidth, scHeight = draw.getport()\nprint(\"Generating images\")\n\n-- search for images\nfor k, v in ipairs(sys.dir(\"Images\")) do\n if v~=\".\" and v~=\"..\" then\n draw.beginframe()\n draw.setclearcolor(draw.black)\n draw.clearscreen()\n if gDraw then\n draw.setlinestyle(1, \"butt\")\n draw.setfont(\"Arial\", 16)\n gDraw.Window(\"Generating Images...\", scWidth*.1, scHeight*.7, scWidth*.8, scHeight*.2)\n draw.setfont(\"Arial\", 24)\n draw.stringinrect(\"Please Wait...\", scWidth*.1, scHeight*.7 + 32, scWidth*.9, scHeight*.9, draw.black)\n draw.setfont(\"Arial\", 16)\n end\n local region = require (\"Images\/\"..v:sub(0, -5))\n draw.endframe()\n sys.sleep(400)\n local x1, y1, x2, y2 = region[1], region[2], region[3], region[4]\n draw.imagesave(\"@resources\/\"..v:sub(0, -5)..\".png\", x1, y1, x2, y2)\n -- Make lower resolution image\n draw.beginframe()\n draw.clearscreen()\n draw.transformedimage(\"@resources\/\"..v:sub(0, -5)..\".png\", x1 + (x2 - x1)*.25, y1 + (y2 - y1)*.25, .5, 0)\n draw.endframe()\n draw.imagesave(\"@resources\/\"..v:sub(0, -5)..\"lowres.png\", x1, y1, x2 - (x2 - x1)*.5, y2 - (y2 - y1)*.5)\n print(\"Generated \"..v:sub(0, -5)..\".png\")\n end\nend","Images\/Tower1.lua":"draw.fillcircle(24, 24, 16, draw.black)\nfor k=14, 0, -1 do\n draw.fillcircle(24, 24, k, Color.new(.1, .1, .1, 1, true)*(2-(k\/8)))\nend\ndraw.fillroundedrect(20, 0, 28, 24, 2, draw.darkgray)\ndraw.fillcircle(24, 24, 6, {.25, .28, .3, 1})\nreturn {0, 0, 48, 48}","Enemies\/enemy09BasicTrojan.lua":"local enemy = Enemy:new(0, 0)\nenemy.name = \"Basic Trojan\"\nenemy.sprites = {\n default = \"Enemy9\",\n lowhealth = \"Enemy9\",\n}\nenemy.health = 125\nenemy.speed = 1\nenemy.score = 150\nenemy.config = {\n sprites = enemy.sprites,\n health = enemy.health,\n speed = enemy.speed,\n score = enemy.score,\n}\n\nreturn enemy","Towers\/tower4ResourceGen.lua":"local tower = Tower:new(0, 0)\ntower.name = \"ScriptMiner\"\ntower.sprites = {\n default = \"Tower4\",\n}\ntower.power = 0\ntower.firerate = 60\ntower.coingen = 20\ntower.cost = 2000\ntower.projectile = nil\ntower.upgrades = {\n {\n name = \"Level 2\",\n cost = 400,\n upgrade = {\n [\"coingen\"] = {upgradetype = \"percent\", value = 25},\n }\n },\n {\n name = \"Level 3\",\n cost = 2000,\n upgrade = {\n [\"coingen\"] = {upgradetype = \"percent\", value = 100},\n }\n },\n {\n name = \"Level 4\",\n cost = 8000,\n upgrade = {\n [\"coingen\"] = {upgradetype = \"percent\", value = 40},\n [\"firerate\"] = {upgradetype = \"percent\", value = -10}\n }\n },\n {\n name = \"Level 5\",\n cost = 40000,\n upgrade = {\n [\"coingen\"] = {upgradetype = \"percent\", value = 150},\n [\"firerate\"] = {upgradetype = \"percent\", value = -25}\n }\n },\n}\ntower.config = {\n name = tower.name,\n projectile = 0,\n upgrades = tower.upgrades,\n sprites = tower.sprites,\n power = tower.power,\n firerate = tower.firerate,\n baserepair = tower.baserepair,\n coingen = tower.coingen,\n cost = tower.cost,\n}\nreturn tower","Images\/Projectile1.lua":"draw.fillcircle(8, 8, 4, draw.black)\nif Color then\n for k=4, 0, -.1 do\n draw.fillcircle(8, 8, k, draw.darkgray*(1-((1\/4)*k)))\n end\nend\nreturn {0, 0, 16, 16}","Images\/Enemy1.lua":"draw.setscreen(1)\n-- Draw legs\nlocal col\nif Color then\n col = Color.new(0, 0, .7, 1, true)\nelse\n col = {0, 0, .7, 1}\nend\n--draw.rect(0,0,48,48,draw.blue)\ndraw.setlinestyle(3, \"round\")\ndraw.line(2, 14, 10, 18, col)\ndraw.line(2, 21, 10, 22, col)\ndraw.line(2, 27, 10, 26, col)\ndraw.line(48-2, 14, 48-10, 18, col)\ndraw.line(48-2, 21, 48-10, 22, col)\ndraw.line(48-2, 27, 48-10, 26, col)\n-- Draw body\nfor k=20, 21 do\n if Color then\n for r=16, 0, -1 do\n draw.fillpolygon(24, k, r, 20, 0, col*(1-(r\/40)))\n end\n else\n draw.fillpolygon(24, k, 16, 20, 0, col)\n end\nend\n-- Draw eyes\ndraw.fillcircle(18, 15, 4.8, {.9,.9,.9, 1})\ndraw.fillcircle(18.4, 14.2, 3.7, {1,0,0,.2})\ndraw.fillcircle(18.4, 14.2, 2.5, draw.black)\ndraw.fillcircle(48-18, 15, 4.8, {.9,.9,.9, 1})\ndraw.fillcircle(48-18.4, 14.2, 3.7, {1,0,0,.2})\ndraw.fillcircle(48-18.4, 14.2, 2.5, draw.black)\nif not Color then sys.sleep(math.huge) end\nreturn {0, 0, 48, 48}","Images\/Enemy9.lua":"draw.setscreen(1)\n-- Draw tail\ndraw.setlinestyle(6, \"butt\")\ndraw.line(24, 32, 24, 48, draw.gray)\ndraw.setlinestyle(1, \"butt\")\nif Color then\n for x=0, 6 do\n draw.line(21+x, 32, 21+x, 48, draw.gray*((x+2)\/6))\n end\nend\n-- Draw head\ndraw.fillroundedrect(18, 4, 30, 20, 4.7, draw.brown)\ndraw.fillroundedrect(21, 4, 27, 20, 1, draw.gray)\nfor y=0, 16, 8 do\n draw.fillroundedrect(21, 4+y, 27, 8+y, 1, draw.darkgray)\nend\ndraw.line(18, 4, 20, 8, draw.brown)\ndraw.line(48-18, 4, 48-20, 8, draw.brown)\n-- Draw body\nif Color then\n for r=9, 0, -.1 do\n for y=22, 33 do\n draw.fillcircle(24, y, r, draw.brown*(1-((r - 4)\/10)) )\n end\n end\nelse\n for y=22, 33 do\n draw.fillcircle(24, y, 9, draw.brown)\n end\nend\nif not Color then sys.sleep(math.huge) end\nreturn {0, 0, 48, 48}","Classes\/Tower.lua":"if not scWidth then\n local lfs = require \"lfs\"\n local dir = lfs.currentdir()\n local newdir = dir:sub(0, -8)\n lfs.chdir(newdir)\n dofile(\"main.lua\")\nend\nlocal Tower = {}\nTower.__index = Tower -- failed table lookups on the instances should fallback to the class table, to get methods\nTower.classtype = \"Tower\"\n\nlocal cos, sin = math.cos(1), math.sin(1)\n\n-- This function constructs a new object of this type.\nTower.new = function(self, x, y)\n if not self then\n error(\"self is nil\", 2)\n end\n local config = self.config\n local self = setmetatable({}, Tower)\n self.position = Vector2.new(x, y)\n self.target = Vector2.new(0, 0)\n self.size = 20\n self.health = 10\n self.cost = 100\n self.firerate = 10\n self.range = 100\n self.power = 4\n self.baserepair = 0\n self.coingen = 0\n self.level = 1\n self.vanquishes = 0\n self.upgrades = {}\n self.projectile = Projectile\n self.attackType = \"Closest\"\n self.sprite = \"default\"\n self.sprites = {\n default = \"Tower1\",\n fire = \"Tower1\",\n damaged = \"Tower1\",\n lowhealth = \"Tower1\",\n }\n if stage then\n self.id = #stage.towers + 1\n end\n if config then\n for k, v in pairs(config) do\n self[k] = v\n end\n end\n self.value = self.cost\n return self\nend\n\n-- Tower Functions --\n-- Sells a tower.\nfunction Tower:Sell()\n table.insert(stage.deadTowers, self.id)\n stage.coins = stage.coins + self.value\nend\n\nfunction Tower:GetUpgradeCost()\n if self.level <= #self.upgrades then\n return self.upgrades[self.level].cost\n end\n return self.level*500\nend\n\n--\nfunction Tower:Upgrade()\n if self.level <= #self.upgrades then\n self.value = self.value + self.upgrades[self.level].cost\n for k, v in pairs(self.upgrades[self.level].upgrade) do\n if type(v.value) == \"string\" or type(v.value) == \"table\" or type(v.value) == \"boolean\" then\n self[k] = v.value\n elseif type(v.value) == \"number\" then\n if type(self[k]) == \"number\" then\n if v.upgradetype == \"percent\" then\n self[k] = self[k]*(v.value\/100 + 1)\n elseif v.upgradetype == \"add\" then\n self[k] = self[k] + v.value\n else\n self[k] = v.value\n end\n end\n end\n end\n else\n local mult = math.max(10\/(self.level\/self.level*9000), 1.001)\n self.value = self.value + self:GetUpgradeCost()\n -- self.power = self.power*math.min(mult*1.05, 900000) + 2.5\n self.power = math.min(self.power*math.max((mult*1.15)\/math.max((self.power-12500)\/150, 1), mult*1.025), 10000000) + 2.5\n self.baserepair = (self.baserepair*math.max(mult*1.03662, 1.000078))\/(math.max(1, self.baserepair\/1900)*.988)\n self.coingen = math.min(self.coingen*mult*1.083, 200000)\n self.firerate = math.max(self.firerate*.998, 1)\n end\n self.knockback = math.min((self.knockback or .01)*1.01, 200)\n self.level = self.level + 1\nend\n\nfunction Tower:CreateProjectile(x, y, key, self, fireProjectile)\n local newProjectile = self.projectile:new(x, y, key, self)\n newProjectile.power = self.power\n newProjectile.knockback = self.knockback\n table.insert(stage.projectiles, newProjectile)\n self.rotation = self.position:pointTowards(fireProjectile.position)\nend\n\nfunction Tower:AttackStrongest()\n local strongest = -9001\n local infinite, fireProjectile, key\n local x, y = self.position:raw()\n for k, v in pairs(stage.enemies) do\n -- Check if range is infinite\n infinite = (self.range < 0 and v)\n if not infinite then\n -- Check if target is within range\n local offset = v.position - self.position\n if math.abs(offset.x) + math.abs(offset.y) < self.range*1.25 then\n if v.health > strongest then\n strongest = v.health\n fireProjectile = v\n key = k\n end\n end\n else\n fireProjectile = infinite\n break\n end\n end\n if fireProjectile then\n return self:CreateProjectile(x, y, key, self, fireProjectile)\n end\nend\n\nfunction Tower:AttackWeakest()\n local weakest = 200000000\n local infinite, fireProjectile, key\n local x, y = self.position:raw()\n for k, v in pairs(stage.enemies) do\n -- Check if range is infinite\n infinite = (self.range < 0 and v)\n if not infinite then\n -- Check if target is within range\n local offset = v.position - self.position\n if math.abs(offset.x) + math.abs(offset.y) < self.range*1.25 then\n if v.health < weakest then\n weakest = v.health\n fireProjectile = v\n key = k\n end\n end\n else\n fireProjectile = infinite\n break\n end\n end\n if fireProjectile then\n return self:CreateProjectile(x, y, key, self, fireProjectile)\n end\nend\n\nfunction Tower:AttackFirst()\n local x, y = self.position:raw()\n for k, v in pairs(stage.enemies) do\n -- Check if range is infinite\n local fireProjectile = self.range < 0\n if not fireProjectile then\n -- Check if target is within range\n local offset = v.position - self.position\n if math.abs(offset.x) + math.abs(offset.y) < self.range*1.25 then\n fireProjectile = true\n end\n else\n break\n end\n if fireProjectile then\n self:CreateProjectile(x, y, key, self, fireProjectile)\n return v\n end\n end\nend\n\nfunction Tower:AttackLast()\n local infinite, fireProjectile, key\n local x, y = self.position:raw()\n for k, v in pairs(stage.enemies) do\n -- Check if range is infinite\n infinite = (self.range < 0 and v)\n if not infinite then\n -- Check if target is within range\n local offset = v.position - self.position\n if math.abs(offset.x) + math.abs(offset.y) < self.range*1.25 then\n fireProjectile = v\n key = k\n end\n else\n fireProjectile = infinite\n break\n end\n end\n if fireProjectile then\n self:CreateProjectile(x, y, key, self, fireProjectile)\n return fireProjectile\n end\nend\n\nfunction Tower:AttackClosest()\n local closest = self.range*1.25\n local infinite, fireProjectile, key\n local x, y = self.position:raw()\n for k, v in pairs(stage.enemies) do\n -- Check if range is infinite\n infinite = (self.range < 0 and v)\n if not infinite then\n -- Check if target is within range\n local offset = v.position - self.position\n if math.abs(offset.x) + math.abs(offset.y) < closest then\n fireProjectile = v\n key = k\n closest = math.abs(offset.x) + math.abs(offset.y)\n end\n else\n fireProjectile = infinite\n break\n end\n end\n if fireProjectile then\n self:CreateProjectile(x, y, key, self, fireProjectile)\n return fireProjectile\n end\nend\n\nfunction Tower:AttackFurthest()\n local furthest = 0\n local infinite, fireProjectile, key\n local x, y = self.position:raw()\n for k, v in pairs(stage.enemies) do\n -- Check if range is infinite\n infinite = (self.range < 0 and v)\n if not infinite then\n -- Check if target is within range\n local offset = v.position - self.position\n if math.abs(offset.x) + math.abs(offset.y) > furthest then\n fireProjectile = v\n key = k\n furthest = math.abs(offset.x) + math.abs(offset.y)\n end\n else\n local offset = v.position - self.position\n if math.abs(offset.x) + math.abs(offset.y) > furthest then\n fireProjectile = v\n key = k\n furthest = math.abs(offset.x) + math.abs(offset.y)\n end\n end\n end\n if fireProjectile then\n self:CreateProjectile(x, y, key, self, fireProjectile)\n return fireProjectile\n end\nend\n\n-- Handles tower ai for this frame.\nfunction Tower:HandleAI()\n -- Attempt to shoot an enemy\n self.cooldown = (self.cooldown or self.firerate) - 1\n -- Fire a projectile if it is ready\n if self.cooldown <= 0 then\n if type(self.projectile) ~= \"number\" then\n self[\"Attack\"..self.attackType](self, self)\n end\n if self.baserepair > 0 then\n stage.health = stage.health + self.baserepair*((stage.decayingHealth and 10) or 1)\n end\n if self.coingen > 0 then\n stage.coins = stage.coins + self.coingen\n stage.score = stage.score + self.coingen\n end\n self.cooldown = self.firerate - self.cooldown\n end\nend\n\n-- This function draws the tower.\nfunction Tower:draw()\n local x, y = self.position:raw()\n local imagel = self.sprites[self.sprite] or self.sprites[\"default\"]\n draw.transformedimage(image(imagel), x, y, imgres(), self.rotation or 0)--(math.pi*.5)-((self.rotation or 0)))\n if Hud.CurrentTower == self.id then\n draw.circle(x, y, math.max(self.range, 20), draw.white)\n end\nend\n\nreturn Tower","gameDraw.lua":"-- Draw functions --\nif not scWidth then require \"main\" end\ngDraw = {}\nfunction gDraw.Button(title, x, y, w, h)\n\nend\n\nfunction gDraw.Window(title, x, y, w, h)\n -- Draw background\n draw.fillrect(x, y, x + w, y + h, draw.lightgray)\n draw.fillrect(x, y, x + w, y + 24, draw.gray)\n -- Draw title\n draw.string(title, x + 4, y + 2, draw.black)\n -- Draw close button\n draw.fillrect(x + w - 24, y, x + w, y + 24, draw.red)\n draw.line(x + w - 24, y, x + w, y + 24, draw.black)\n draw.line(x + w - 24, y + 24, x + w, y, draw.black)\n -- Draw border\n draw.setantialias(false)\n draw.rect(x, y, x + w, y + h, draw.black)\n draw.rect(x, y, x + w, y + 24, draw.black)\n draw.setantialias(true)\nend\nreturn gDraw","Images\/Microchip1.lua":"-- Draw body\ndraw.setscreen(1)\nfor x=3, 10, 2.5 do\n draw.fillrect(x*4, 6, (x+1)*4, 42, draw.lightgray)\nend\nfor y=3, 10, 2.5 do\n draw.fillrect(6, y*4, 42, (y+1)*4, draw.lightgray)\nend\ndraw.fillrect(10, 10, 38, 38, draw.darkgray)\n\nif not Color then sys.sleep(math.huge) end\nreturn {6, 6, 42, 42}","gameHud.lua":"if not scWidth then require \"main\" end\nHud = {}\nHud.CurrentTower = nil\nHud.Width = 100\nHud.Height = scHeight\nHud.X = scWidth - Hud.Width\nHud.Y = 0\nHud.StatusX = 0\nHud.StatusY = 16\nHud.MaxSpeed = 4\nHud.MinTowerWinWidth = 160\nHud.ShowTip = true\nHud.Difficulties = {\n \"First time Script Defender\",\n \">Average Script Defender<\",\n \"Script Defender Wizard\",\n \"Script Defender Master\",\n \"Defending on a Broken Firewall\",\n}\nlocal saveCounter = 0\n\nfunction Hud.DrawSelectDifficulty()\n draw.setfont(\"Arial\", 16)\n gDraw.Window(\"Select Difficulty\", scWidth*.1, scHeight*.1, scWidth*.8, scHeight*.8, draw.darkgray)\n draw.setfont(\"Arial\", 24)\n for k, v in ipairs(Hud.Difficulties) do\n draw.fillroundedrect(1 + scWidth*.1, (scHeight*.1 + 24) + ((k-1)*40), scWidth*.9, (scHeight*.1 + 24) + (k*40), 4, Color.new(1, 1 - (k\/#Hud.Difficulties), 1 - (k\/#Hud.Difficulties), 1, true))\n draw.stringinrect(v, scWidth*.1, scHeight*.1 + 32 + ((k-1)*40), scWidth*.9, scHeight*.1 + 32 + (k*40), draw.black)\n end\nend\n\nfunction Hud.DrawStatusWindow()\n local x, y = Hud.StatusX, Hud.StatusY\n gDraw.Window(\"Round: \"..stage.round, x, y, 160, 96 - 16, draw.darkgray)\n draw.string(\"Scripts: \"..(math.floor(stage.coins*100)\/100), x + 4, y + 24, draw.white)\n draw.string(\"Score: \"..(math.floor(stage.score*100)\/100), x + 4, y + 40, draw.white)\n if not stage.gameOver then\n draw.string(\"Health: \"..(math.floor(stage.health*100)\/100)..((stage.decayingHealth and \" (-\"..(math.floor(stage.decayingHealth*100000)\/100000)..\")\") or \"\"), x + 4, y + 56, (stage.instaDeath and draw.red) or draw.white)\n else\n draw.string(\"INFECTED. LOD has won:)\", x + 4, y + 56, draw.red)\n end\nend\n\nfunction Hud.Draw()\n -- Draw game status window\n Hud.DrawStatusWindow()\n -- Draw hud elements\n draw.fillrect(Hud.X, Hud.Y, Hud.X + Hud.Width, Hud.Y + Hud.Height, draw.darkgray)\n if not Hud.CurrentTower then\n -- Draw current listing of turrets\n for k, v in pairs(Towers) do\n if k < 6 then\n -- Draw on the left side\n draw.fillroundedrect(Hud.X, Hud.Y + 80 + ((k - 1)*48), Hud.X + Hud.Width*.5, Hud.Y + 80 + (k*48), 6, draw.lightgray)\n draw.image (image(v.sprites[\"default\"], true), Hud.X + 1, Hud.Y + 80 + ((k - 1)*48))\n else\n -- Draw on the right side\n draw.fillroundedrect(Hud.X + Hud.Width*.5, Hud.Y + 80 + ((k - 1)*48), Hud.X + Hud.Width, Hud.Y + 80 + (k*48), 6, draw.lightgray)\n draw.image (image(v.sprites[\"default\"], true), Hud.X + 1 + Hud.Width*.5, Hud.Y + 80 + ((k - 6)*48))\n end\n end\n else\n -- Draw current tower\n local v = stage.towers[Hud.CurrentTower]\n local w = draw.stringsize(v.name) + 48\n w = math.max(w, Hud.MinTowerWinWidth)\n gDraw.Window(v.name, 0, scHeight - 100, w, 100)\n draw.image(image(v.sprites[\"default\"], true), 8, scHeight - 72)\n -- Draw the stats of this tower\n if v.coingen > 0 then\n draw.string(\"Coins: \"..math.floor(v.coingen*1000)\/1000, 56, scHeight - 76, draw.black)\n elseif v.baserepair > 0 then\n draw.string(\"Repair: \"..math.floor(v.baserepair*100000)\/100000, 56, scHeight - 76, draw.black)\n elseif v.power > 0 then\n draw.string(\"Power: \"..math.floor(v.power*1000)\/1000, 56, scHeight - 76, draw.black)\n end\n draw.string(\"Fire rate: \"..math.floor(v.firerate*100)\/100, 56, scHeight - 60, draw.black)\n draw.string(\"Range: \"..((v.range >= 0 and tostring(math.floor(v.range*100)\/100)) or \"Infinite\"), 56, scHeight - 44, draw.black)\n draw.string(\"Level \"..(v.level or 1), 4, scHeight - 24, draw.black)\n -- Draw the upgrade button\n if v.upgrades then\n draw.fillroundedrect(Hud.X, 64, Hud.X + Hud.Width, 64 + 48, 4, draw.gray)\n local cost = v:GetUpgradeCost()\n if v.upgrades[v.level] then\n draw.string(v.upgrades [v.level].name, Hud.X + 4, 64, draw.black)\n if stage.coins >= cost then\n draw.string(\"Cost: \"..cost, Hud.X + 4, 92, draw.black)\n else\n draw.string(\"Cost: \"..cost, Hud.X + 4, 92, draw.red)\n end\n else\n draw.string(\"Level \"..v.level + 1, Hud.X + 4, 64, draw.black)\n if stage.coins >= cost then\n draw.string(\"Cost: \"..cost, Hud.X + 4, 92, draw.black)\n else\n draw.string(\"Cost: \"..cost, Hud.X + 4, 92, draw.red)\n end\n end\n end\n -- Draw the remove button\n draw.fillroundedrect(Hud.X, 114, Hud.X + Hud.Width, 114 + 48, 4, draw.gray)\n draw.string(\"Undo Build\", Hud.X + 4, 115, draw.black)\n draw.string(\"Value: \"..v.value, Hud.X + 4, 115 + 24, draw.black)\n draw.string(\"Vanquishes\", Hud.X + 4, 115 + 48, draw.black)\n draw.string(v.vanquishes, Hud.X + 4, 115 + 72, draw.black)\n end\n if Hud.PlacingTower then\n -- Show prompt of tower about to be placed\n local v = Towers[Hud.PlacingTower]\n local w = draw.stringsize(v.name) + 48\n w = math.max(w, Hud.MinTowerWinWidth)\n gDraw.Window(v.name, 0, scHeight - 100, w, 100)\n draw.image(image(v.sprites[\"default\"], true), 8, scHeight - 72)\n -- Draw the stats of this tower\n if v.coingen > 0 then\n draw.string(\"Coins: \"..v.coingen, 56, scHeight - 76, draw.black)\n elseif v.baserepair > 0 then\n draw.string(\"Repair: \"..v.baserepair, 56, scHeight - 76, draw.black)\n elseif v.power > 0 then\n draw.string(\"Power: \"..v.power, 56, scHeight - 76, draw.black)\n end\n draw.string(\"Fire rate: \"..v.firerate, 56, scHeight - 60, draw.black)\n draw.string(\"Range: \"..((v.range >= 0 and tostring(v.range)) or \"Infinite\"), 56, scHeight - 44, draw.black)\n if stage.coins - v.cost < 0 then\n draw.string(\"Cost: \"..v.cost..\" (\"..v.cost - stage.coins..\")\", 4, scHeight - 24, draw.red)\n else\n draw.string(\"Cost: \"..v.cost, 4, scHeight - 24, draw.black)\n end\n end\n -- Draw stage speed button\n if saveCounter < 40 then\n if not stage.running then\n draw.filltriangle(Hud.X + 16, Hud.Y + 16, Hud.X + 16, Hud.Y + 48 + 16, Hud.X + 48 + 16, Hud.Y + 24 + 16, draw.green)\n else\n for k=1, (stage.speed <= Hud.MaxSpeed and stage.speed) or 1 do\n draw.filltriangle(Hud.X + 12*k, Hud.Y + 16, Hud.X + 12*k, Hud.Y + 48 + 16, Hud.X + 40 + 12*k, Hud.Y + 24 + 16, draw.blue)\n end\n end\n else\n draw.setfont(\"Arial\", 32)\n if not stage.running then\n draw.string(\"Save\", Hud.X + 12, Hud.Y + 20, draw.white)\n else\n draw.fillarc(Hud.X + 48, Hud.Y + 40, 24, 0, (stage.roundTick\/stage.roundTime)*math.pi*2, draw.white)\n end\n draw.setfont(\"Arial\", 16)\n end\n -- Draw a hint only when we should\n local hintText\n if not stage.running and round[stage.round] and Hud.ShowTip then\n if round[stage.round].hint then\n hintText = round[stage.round].hint\n end\n elseif not stage.running and not round[stage.round] and not Hud.roundsLoaded then\n hintText = \"Please wait for the rounds to load. Round \"..(#round+1)..\" is loading.\"\n end\n if hintText then\n local width = scWidth - 160 - 128\n local height = (math.ceil((draw.stringsize(hintText)\/(width*.75)) + 1)*16)\n gDraw.Window(\"Tip\", 160, 16, scWidth - 160 - 128, 20 + height)\n draw.stringinrect(hintText, 161, 40, 160 + scWidth - 160 - 128, 40 + height, draw.black)\n end\nend\n\nfunction Hud.onBeginTouch(x, y)\n if Hud.canLoadGame and not Hud.loadedGame and Hud.fileToLoad then\n local ok, err = pcall(loadGame)\n if ok then\n drawTitle(\"Loaded Game at Round \"..stage.round)\n sound.playeffect(\"@resources\/Pickup4.wav\", .4)\n Hud.loadedGame = true\n else -- We have encountered an error while loading data\n drawTitle(\"Error loading saved data\")\n print(err)\n stage = Stage.new()\n end\n end\n if Hud.canLoadGame or stage.gameOver then return end\n if x > Hud.StatusX and x < Hud.StatusX + 160 then\n if y > Hud.StatusY and y <= Hud.StatusY + 16 then\n Hud.MoveStatusWindow = true\n Hud.OldSX, Hud.OldSY = Hud.StatusX, Hud.StatusY\n Hud.StTapX, Hud.StTapY = x, y\n end\n end\nend\n\nfunction Hud.onHoldTouch(x, y)\n if Hud.canLoadGame or stage.gameOver then\n return\n end\n if Hud.MoveStatusWindow then\n Hud.StatusX, Hud.StatusY = Hud.OldSX + (x - Hud.StTapX), Hud.OldSY + (y - Hud.StTapY)\n end\n if x > Hud.X then\n if y < Hud.Y + 48 + 16 then\n saveCounter = (saveCounter or 0) + 1\n end\n end\nend\n\nfunction Upgrade(v)\n if v.upgrades then\n if v.upgrades[v.level] then\n if stage.coins >= v:GetUpgradeCost() then\n stage.coins = stage.coins - v:GetUpgradeCost()\n v:Upgrade()\n sound.playeffect(\"@resources\/Pickup1.wav\", .4)\n return true\n end\n else\n if stage.coins >= v:GetUpgradeCost() then\n stage.coins = stage.coins - v:GetUpgradeCost()\n v:Upgrade()\n sound.playeffect(\"@resources\/Pickup1.wav\", .4)\n return true\n end\n end\n end\nend\n\nfunction Hud.onEndTouch(x, y)\n if stage.gameOver then\n stage = Stage.new()\n local ok, err = pcall(loadGame)\n if ok then\n stage.gameOver = false\n stage.running = false\n drawTitle(\"Prepare to defend!\")\n sound.stopeverything()\n sound.playbg(\"@resources\/SciFiOpenMusic.mp3\", true)\n sound.playeffect(\"@resources\/Pickup4.wav\", .4)\n sys.sleep(500)\n end\n end\n if Hud.SkippingRound then\n Hud.SkippingRound = false\n return\n end\n Hud.MoveStatusWindow = false\n if Hud.selectDifficulty then\n if x > scWidth*.1 and x < scWidth*.9 and y > scHeight*.1 + 24 and y < scHeight*.9 then\n local difficulty = math.min(math.floor((y - (scHeight*.1 + 24))\/40) + 1, #Hud.Difficulties)\n selectedDif = (difficulty*2.5) + 5\n stage:UpdateDifficulty()\n Hud.selectDifficulty = false\n end\n return\n end\n if Hud.canLoadGame then\n return\n end\n if x > 320 and y > 24 and x < 320 + 48 and y < 24 + 48 then\n Hud.ShowTip = false\n end\n if x > Hud.X then -- Select a tower to place\n if not Hud.CurrentTower then\n local TowerTapped = math.ceil((y - 80)\/48) + (math.floor((x - Hud.X)\/50)*5)\n if Towers[TowerTapped] and y > 80 then\n Hud.PlacingTower = TowerTapped\n end\n else\n local v = stage.towers[Hud.CurrentTower]\n if y > 64 and y < 64 + 48 then\n Upgrade(v)\n elseif y > 110 and y < 110 + 48 then\n v:Sell()\n Hud.CurrentTower = nil\n elseif y > 110+48 and y < 110+48*2 then\n while Upgrade(v) do end\n end\n end\n -- Has the player tapped the start round button?\n if y < Hud.Y + 48 + 16 and not stage.running and saveCounter < 40 then\n if round[stage.round] then\n stage.roundTick = round[stage.round][\"time\"]*30 + 1\n stage.roundTime = stage.roundTick\n stage.roundEnemies = round[stage.round][\"enemies\"]\n stage.running = true\n elseif Hud.roundsLoaded then\n stage.roundTick = 2\n stage.roundTime = stage.roundTick\n stage.roundEnemies = {[1] = {8}}\n stage.running = true\n end\n elseif y < Hud.Y + 48 + 16 and saveCounter < 40 then\n stage.speed = (stage.speed or 1) + 1\n if stage.speed > Hud.MaxSpeed then\n stage.speed = 1\n end\n elseif y < Hud.Y + 48 + 16 and saveCounter >= 40 and not stage.running then\n saveGame()\n elseif y < Hud.Y + 48 + 16 then\n stage:skipRound()\n end\n else -- Select a tower on map\n if Hud.PlacingTower then\n local TowerTapped = Hud.PlacingTower\n local g = 16\n if stage.coins >= Towers[TowerTapped].cost then\n table.insert(stage.towers, Towers[TowerTapped]:new(math.floor(x\/g)*g, math.floor(y\/g)*g))\n stage.coins = stage.coins - Towers[TowerTapped].cost\n sound.playeffect(\"@resources\/Pickup4.wav\", .1)\n end\n Hud.PlacingTower = nil\n else\n local selTower = nil\n for key, tower in pairs(stage.towers) do\n local tx, ty = tower.position:raw()\n if math.abs(x - tx) < tower.size then\n if math.abs(y - ty) < tower.size then\n --if key > (Hud.CurrentTower or 0) then\n selTower = key\n break\n --end\n end\n end\n end\n Hud.CurrentTower = selTower\n end\n end\n saveCounter = 0\nend","saveLoad.lua":"if not scWidth then require \"main\" end\nlocal name = \"savedData.txt\"\n\nfunction saveGame()\n local file = io.open(name, \"w\")\n if file then\n file:write('if not scWidth then require \"main\" end--[[\\n')\n file:write(tostring(selectedDif)..\"\\n\")\n file:write(tostring(stage.round)..\"\\n\")\n file:write(tostring(stage.coins)..\"\\n\")\n file:write(tostring(stage.health)..\"\\n\")\n file:write(tostring(stage.score)..\"\\n\")\n file:write(\"--Towers--\\n\")\n for k, v in ipairs(stage.towers) do\n file:write(v.ID..\"\\n\")\n file:write(v.level..\"\\n\")\n file:write(v.position.x..\"\\n\")\n file:write(v.position.y..\"\\n\")\n file:write(v.vanquishes..\"\\n\")\n end\n file:write(\"]]\")\n file:close()\n sound.playeffect(\"@resources\/Pickup2.wav\", .4)\n return true\n end\n return false\nend\n\nfunction loadGame()\n local file = io.open(name)\n if file then\n file:read()\n selectedDif = tonumber(file:read()) or selectedDif\n stage.round = tonumber(file:read()) or 1\n stage.coins = tonumber(file:read()) or 100\n stage.health = tonumber(file:read()) or 10\n stage.score = tonumber(file:read()) or stage.coins\n file:read()\n while true do\n local towerId = tonumber(file:read())\n if towerId then\n local towerLevel = tonumber(file:read())\n local towerX = tonumber(file:read())\n local towerY = tonumber(file:read())\n local towerVanquishes = tonumber(file:read())\n if not towerVanquishes then\n error(\"There is an error with the saved data's tower information. Canceling load.\")\n end\n local tower = Towers[towerId]:new(towerX, towerY)\n for k=1, towerLevel - 1 do\n tower:Upgrade()\n end\n tower.vanquishes = towerVanquishes\n table.insert(stage.towers, tower)\n else\n break\n end\n end\n file:close()\n stage:UpdateDifficulty()\n return true\n end\n return false\nend","main.lua":"-----------------------------------\n-- Script Defender Version 1.0.3 --\n-- By Tag365 --\n-----------------------------------\n-- Set up Graphics Screen and other variable --\nsys.clear()\ndraw.setscreen(1)\ndraw.settitle(\"Script Defender\")\nscWidth, scHeight = draw.getport()\nlocal iPhone4s = scWidth*scHeight <= (480*320)\nscWidth, scHeight = 480, 320\nlocal framesLastSecond = 30\nlocal framesThisSecond = 0\nselectedDif = math.huge\n\n-- Draw Black Screen --\ndraw.beginframe()\ndraw.clear(draw.black)\ndraw.endframe()\n\nif draw.showtitle then\n draw.showtitle( false )\n draw.setantialias(not iPhone4s)\nend\n\nfunction string.shortNum(num)\n if num > 1000000000000000000000 then\n return math.floor(num\/10000000000000000)..\"Q\"\n elseif num > 1000000000000000000 then\n return math.floor(num\/10000000000000)..\"T\"\n elseif num > 1000000000000000 then\n return math.floor(num\/10000000000)..\"B\"\n elseif num > 1000000000000 then\n return math.floor(num\/1000000)..\"M\"\n elseif num > 1000000000 then\n return math.floor(num\/1000)..\"k\"\n end\n return math.floor(num*10)\/10\nend\n\n-- Set up timing functions\nlocal oldPrint = print\nlocal tI = 10000\nfunction getTime()\n return sys.gettime() - startTime\nend\nfunction print(...)\n oldPrint((math.floor(getTime()*tI)\/tI)..\": \", table.unpack({...}))\nend\nfunction sleep(time)\n sys.sleep(time*1000)\nend\nfunction image(image, override)\n --[[if iPhone4s and not override then\n return \"@resources\/\"..image..\"lowres.png\"\n end]]\n return \"@resources\/\"..image..\".png\"\nend\nfunction imgres()\n return 1\n --return (iPhone4s and 2) or 1\nend\nstartTime = sys.gettime()\nimageCache = {}\n\n-- Require stuff --\n-- Load Classes.\nrequire \"ObjectFunctions\"\nfor k, v in ipairs(sys.dir(\"Classes\")) do\n if v ~= \".\" and v ~= \"..\" then\n _G[v:sub(1, -5)] = require(\"Classes\/\"..v:sub(1, -5))\n print(\"Class \"..v:sub(1, -5)..\" has loaded\")\n end\nend\n-- Load Towers.\nTowers = {}\nfor k, v in ipairs(sys.dir(\"Towers\")) do\n if v ~= \".\" and v ~= \"..\" then\n Towers[#Towers + 1] = require(\"Towers\/\"..v:sub(1, -5))\n Towers[#Towers].config.ID = #Towers\n print(\"Tower \"..v:sub(1, -5)..\" has loaded\")\n end\nend\n\n-- Load Enemies.\nEnemies = {}\nfor k, v in ipairs(sys.dir(\"Enemies\")) do\n if v ~= \".\" and v ~= \"..\" then\n Enemies[#Enemies + 1] = require(\"Enemies\/\"..v:sub(1, -5))\n print(\"Enemy \"..v:sub(1, -5)..\" has loaded\")\n end\nend\n\nfunction loadImage(image)\n imageCache[image] = {draw.cacheimage(image)}\n if (imageCache[image][1] or -1) < 0 then\n require(\"gameRegenImages\")\n imageCache[image] = {draw.cacheimage(image)}\n end\nend\n\n-- require more scripts\nrequire \"sound\"\nrequire \"gameDraw\"\nrequire \"gameHud\"\nrequire \"gameRounds\"\nrequire \"saveLoad\"\n\n-- Preload images\nfor k, v in ipairs(sys.dir(\"Images\")) do\n if v ~= \".\" and v ~= \"..\" then\n loadImage(\"@resources\/\"..v:sub(1, -5)..\".png\")\n if iPhone4s then\n loadImage(\"@resources\/\"..v:sub(1, -5)..\"lowres.png\")\n end\n end\nend\nprint(\"Loaded images\")\n\nlocal bgColor = Color.new(0, .625, .1, 1, true)\nlocal shadowColor = Color.new(0, 0, 0, .9)\n\n-- Draws the background.\nfunction drawBackground()\n if not iPhone4s then\n for k=1, 6 do\n draw.tiledimage (image(\"ScriptDefenderBackground\", true), (k-1)*64, -64*2+((k-1)*24), k*64, 320)\n end\n else\n draw.tiledimage (image(\"ScriptDefenderBackground\", true), 0, 0, scWidth - 64, scHeight)\n end\nend\n\n-- Prepare objects --\nstage = Stage.new()\n\n-- Show the title screen where you can load a game. --\nfunction drawTitle(message)\n draw.beginframe()\n draw.setfont(\"Arial\", 16)\n draw.clear(draw.black)\n gDraw.Window(\"Script Defender Firewall\", scWidth*.1, scHeight*.1, scWidth*.8, scHeight*.8)\n -- Draw logo\n local w, h = 48, 12\n local w1, h1 = 3, 4\n draw.setclip(2 + scWidth*.1, 0, scWidth*.4, scHeight)\n for y=0, h1, 2 do\n for x=1, w1 do\n draw.fillrect(2 + scWidth*.1 + ((x - 1)*w), scHeight*.3 + ((y - 1)*h)*2, 2 + scWidth*.1 + ((x)*w) - 2, scHeight*.3 + (y*h)*2 - 2, draw.red)\n end\n end\n for y=1, h1, 2 do\n for x=.5, w1 + 1 do\n draw.fillrect(2 + scWidth*.1 + ((x - 1)*w), scHeight*.3 + ((y - 1)*h)*2, 2 + scWidth*.1 + ((x)*w) - 2, scHeight*.3 + (y*h)*2 - 2, draw.red)\n end\n end\n draw.clearclip()\n -- Draw text\n draw.setfont(\"Arial\", 32)\n draw.string(\"Script Defender\", scWidth*.42, scHeight*.2, draw.black)\n draw.setfont(\"Arial\", 24)\n draw.string(\"Version 1.0.2\", scWidth*.42, scHeight*.33, draw.black)\n draw.stringinrect(message, scWidth*.1, scHeight*.8, scWidth*.9, scHeight*.9, draw.black)\n draw.endframe()\nend\n\nlocal file = io.open(\"savedData.txt\")\nif file then\n file:close()\n Hud.fileToLoad = true\nend\ndrawTitle((Hud.fileToLoad and \"Tap to load save...\") or \"\")\n\nif not pcall(draw.tracktouches, Hud.onBeginTouch, Hud.onHoldTouch, Hud.onEndTouch) then\n function draw.tracktouches(x, y, z)\n draw.touchbegan = function(d)\n for k = 1, #d do\n x(d[k].x, d[k].y)\n end\n end\n draw.touchmoved = function(d)\n for k = 1, #d do\n y(d[k].x, d[k].y)\n end\n end\n draw.touchended = function(d)\n for k = 1, #d do\n z(d[k].x, d[k].y)\n end\n end\n end\nend\ndraw.tracktouches(Hud.onBeginTouch, Hud.onHoldTouch, Hud.onEndTouch)\n\nsound.playbg(\"@resources\/SciFiOpenMusic.mp3\", true)\nlocal pastTime = sys.gettime()*1000\nwhile sys.gettime()*1000 < pastTime + 1670 do\n continueGenOfRounds()\n draw.doevents()\n Hud.canLoadGame = true\nend\nHud.canLoadGame = false\n\nif not Hud.loadedGame then\n Hud.selectDifficulty = true\n draw.beginframe()\n for k=1, 8 do\n draw.tiledimage(\"@resources\/ScriptDefenderBackground.png\", (k-1)*64, -64*3+((k-1)*24), k*64, 320)\n end\n Hud.DrawSelectDifficulty()\n draw.endframe()\n while Hud.selectDifficulty do\n draw.doevents()\n end\nend\n\n-- Main loop --\nlocal lastSecond = sys.gettime()\nlocal lastFrame = sys.gettime()\nwhile true do\n continueGenOfRounds()\n lastFrame = sys.gettime()\n --pcall(coroutine.yield)\n draw.doevents()\n -- Update the game\n for loops=1, stage.speed or 1 do\n stage:Update()\n end\n -- Draw the frame\n draw.beginframe()\n draw.setfont(\"Arial\", 16)\n if not stage.gameOver then\n stage:Draw()\n Hud.Draw()\n else\n draw.clear(shadowColor)\n gDraw.Window(\"Network Offline\", scWidth*.2, scHeight*.2, scWidth*.6, scHeight*.6)\n draw.setfont(\"Arial\", 48)\n draw.stringinrect(\"Game Over!\", 0, scHeight*.5 - 32, scWidth, scHeight, draw.red)\n draw.setfont(\"Arial\", 20)\n draw.stringinrect(\"Score: \"..stage.score, 0, scHeight*.5 + 20, scWidth, scHeight, draw.white)\n draw.stringinrect(\"Tap to try again\", 0, scHeight*.5 + 40, scWidth, scHeight, draw.white)\n draw.setfont(\"Arial\", 16)\n end\n draw.string(\"FPS: \"..framesLastSecond, 1, 97, draw.black)\n draw.string(\"FPS: \"..framesLastSecond, 0, 96, draw.white)\n draw.string(\"Memory: \"..math.floor(collectgarbage(\"count\"))..\" KB\", 1, 129, draw.black)\n draw.string(\"Memory: \"..math.floor(collectgarbage(\"count\"))..\" KB\", 0, 128, draw.white)\n draw.endframe()\n -- Calculate framerate\n framesThisSecond = framesThisSecond + 1\n if sys.gettime() > lastSecond + 1 then\n lastSecond = sys.gettime()\n framesLastSecond = framesThisSecond\n framesThisSecond = 0\n end\n -- Sleep to maintain a framerate of 30 FPS\n local timeTaken = sys.gettime() - lastFrame\n if timeTaken < 1\/30 then\n sleep(1\/30 - timeTaken)\n end\nend","Enemies\/enemy03AdvancedVirus.lua":"local enemy = Enemy:new(0, 0)\nenemy.name = \"Advanced Virus\"\nenemy.sprites = {\n default = \"Enemy1\",\n lowhealth = \"Enemy1\",\n}\nenemy.health = 300\nenemy.speed = 1.75\nenemy.score = 900\nenemy.config = {\n sprites = enemy.sprites,\n health = enemy.health,\n speed = enemy.speed,\n score = enemy.score,\n}\n\nreturn enemy","Enemies\/enemy10TrojanHorse.lua":"local enemy = Enemy:new(0, 0)\nenemy.name = \"Trojan Horse\"\nenemy.sprites = {\n default = \"Enemy9\",\n lowhealth = \"Enemy9\",\n}\nenemy.health = 250\nenemy.speed = 1\nenemy.score = 250\nenemy.config = {\n sprites = enemy.sprites,\n health = enemy.health,\n speed = enemy.speed,\n score = enemy.score,\n}\n\nreturn enemy","Enemies\/enemy12BossTrojan.lua":"local enemy = Enemy:new(0, 0)\nenemy.name = \"Trojan Horse\"\nenemy.sprites = {\n default = \"Enemy9\",\n lowhealth = \"Enemy9\",\n}\nenemy.health = 75000\nenemy.speed = 1\nenemy.score = 30000\nenemy.config = {\n sprites = enemy.sprites,\n health = enemy.health,\n speed = enemy.speed,\n score = enemy.score,\n}\n\nreturn enemy","Images\/ScriptDefenderBackground.lua":"-- Draw body\ndraw.setscreen(1)\ndraw.setantialias(false)\ndraw.fillrect(0, 0, 64, 64, {0, .625, .1, 1})\nfunction hole(x, y, sz)\n local metal\n if Color then\n metal = Color.new(.8, .8, .85, 1, true)\n else\n metal = {.8, .8, .85, 1}\n end\n draw.fillcircle(x, y, sz, metal)\n if Color then\n for k=sz, sz*.6, -.1 do\n draw.fillcircle(x, y, k, metal*((1\/sz)*k))\n end\n end\n draw.fillcircle(x, y, sz*.6, draw.black)\nend\nif Color then\n local bg = Color.new(0, .625, .1, 1, true)\n for x=0, 64 do\n for y=0, 64 do\n math.randomseed(x*(y*9032.283736)+44)\n draw.point(x, y, bg*(1 + ((math.random()-.5)*.125)))\n end\n end\nend\nlocal lin = {.575, .775, 0, 1}\nfor k=0, 8, 8 do\n draw.line(0-k, 16+k, 8-k, 16+k, lin)\n draw.lineto(16-k, 24+k, lin)\n draw.lineto(16-k, 40+k, lin)\n draw.lineto(24-k, 48+k, lin)\n draw.lineto(40+k, 48+k, lin)\n if k ~= 0 then\n draw.lineto(56+k, 32+k, lin)\n draw.line(48+k, 40+k, 64+k, 40+k, lin)\n else\n draw.lineto(52+k, 36+k, lin)\n end\nend\ndraw.line(0, 16, 28, 16, lin)\ndraw.circle(32, 16, 3, lin)\ndraw.circle(55, 33, 3, lin)\ndraw.setantialias(true)\nhole(40, 8, 6)\nhole(56, 8, 6)\n--draw.clearclip()\n\nif not Color then sys.sleep(math.huge) end\nreturn {0, 0, 64, 64}","Towers\/tower3EnergyBlaster.lua":"local tower = Tower:new(0, 0)\ntower.name = \"Energy Blaster\"\ntower.sprites = {\n default = \"Tower3\",\n}\ntower.power = 50\ntower.firerate = 30\ntower.range = -1\ntower.knockback = 8\ntower.cost = 400\ntower.projectile = Projectile:new()\ntower.projectile.sprites = {\n default = \"Projectile3\",\n}\ntower.projectile.config = {\n sprites = tower.projectile.sprites,\n knockback = tower.knockback\n}\ntower.upgrades = {\n {\n name = \"Level 2\",\n cost = 600,\n upgrade = {\n [\"power\"] = {upgradetype = \"percent\", value = 44},\n }\n },\n {\n name = \"Level 3\",\n cost = 1200,\n upgrade = {\n [\"power\"] = {upgradetype = \"percent\", value = 55},\n }\n },\n {\n name = \"Level 4\",\n cost = 2000,\n upgrade = {\n [\"power\"] = {upgradetype = \"percent\", value = 66},\n }\n },\n {\n name = \"Level 5\",\n cost = 3000,\n upgrade = {\n [\"power\"] = {upgradetype = \"percent\", value = 77},\n }\n }\n}\ntower.config = {\n attackType = \"Furthest\",\n name = tower.name,\n upgrades = tower.upgrades,\n sprites = tower.sprites,\n power = tower.power,\n firerate = tower.firerate,\n range = tower.range,\n knockback = tower.knockback,\n baserepair = tower.baserepair,\n coingen = tower.coingen,\n cost = tower.cost,\n projectile = tower.projectile\n}\nreturn tower","Classes\/Color.lua":"local Color = {}\nColor.__index = Color -- failed table lookups on the instances should fallback to the class table, to get methods\nColor.classtype = \"Color\"\n\nlocal cos, sin = math.cos(1), math.sin(1)\n\n-- This function constructs a new object of this type.\nColor.new = function(red, green, blue, alpha, dontdivide)\n local self = setmetatable({}, Color)\n if dontdivide then\n self.red = red\n self.green = green\n self.blue = blue\n self.alpha = alpha or 1\n else\n self.red = red\/255\n self.green = green\/255\n self.blue = blue\/255\n self.alpha = (alpha or 255)\/255\n end\n return self\nend\n\n-- Adds a vector to this color.\nfunction Color.addColorToColor(self, vector2)\n local output = Color.new(self.red, self.green, self.blue, self.alpha)\n output.red = self.red + vector2.red\n output.green = self.green + vector2.green\n output.blue = self.blue + vector2.blue\n output.alpha = self.alpha + vector2.alpha\n return output\nend\n\n-- Subtracts a vector from this vector.\nfunction Color.subtractColorFromColor(self, vector2)\n local output = Color.new(self.red, self.green, self.blue, self.alpha)\n output.red = self.red - vector2.red\n output.green = self.green - vector2.green\n output.blue = self.blue - vector2.blue\n output.alpha = self.alpha - vector2.alpha\n return output\nend\n\n-- Multiplies a vector by this vector.\nfunction Color.multiplyColorByColor(self, vector2)\n local output = Color.new(self.red, self.green, self.blue, self.alpha)\n output.red = self.red * vector2.red\n output.green = self.green * vector2.green\n output.blue = self.blue * vector2.blue\n output.alpha = self.alpha * vector2.alpha\n return output\nend\n\n-- Divides a vector by this vector.\nfunction Color.divideColorByColor(self, vector2)\n local output = Color.new(self.red, self.green, self.blue, self.alpha)\n output.red = self.red \/ vector2.red\n output.green = self.green \/ vector2.green\n output.blue = self.blue \/ vector2.blue\n output.alpha = self.alpha \/ vector2.alpha\n return output\nend\n\n-- Returns the raw values for this color.\nfunction Color.raw(self)\n return self.red, self.green, self.blue, self.alpha\nend\n\n-- Set up metatables\nColor.__tostring = function(self)\n return self.red..\", \"..self.green..\", \"..self.blue..\", \"..self.alpha\nend\nColor.__add = function(self, other)\n if GetObjectType(other) ~= \"Color\" then\n if type(other) == \"number\" then\n return Color.new(self.red+other, self.green+other, self.blue+other, self.alpha+other)\n end\n return self\n end\n return self:addColorToColor(other)\nend\nColor.__sub = function(self, other)\n if GetObjectType(other) ~= \"Color\" then\n if type(other) == \"number\" then\n return Color.new((self.red*255)-other, (self.green*255)-other, (self.blue*255)-other, (self.alpha*255)-other)\n end\n return self\n end\n return self:subtractColorFromColor(other)\nend\nColor.__mul = function(self, other)\n if GetObjectType(other) ~= \"Color\" then\n if type(other) == \"number\" then\n return Color.new(self.red*other, self.green*other, self.blue*other, self.alpha, true)\n end\n return self\n end\n return self:multiplyColorByColor(other)\nend\nColor.__div = function(self, other)\n if GetObjectType(other) ~= \"Color\" then\n if type(other) == \"number\" then\n return Color.new((self.red)\/other, (self.green)\/other, (self.blue)\/other, self.alpha, true)\n end\n return self\n end\n return self:divideColorByColor(other)\nend\n\nColor.__eq = function(self, other)\n if GetObjectType(other) ~= \"Color\" then\n return false\n end\n if self.red == other.red and self.green == other.green and self.blue == other.blue then\n return true\n end\n return false\nend\nColor.__lt = function(self, other)\n if GetObjectType(other) ~= \"Color\" then\n return false\n end\n if self.red < other.red and self.green < other.green and self.blue < other.blue then\n return true\n end\n return false\nend\nColor.__le = function(self, other)\n if GetObjectType(other) ~= \"Color\" then\n return false\n end\n if self.red <= other.red and self.green <= other.green and self.blue <= other.blue then\n return true\n end\n return false\nend\n\n-- Enhance default draw colors table\nfor k, v in pairs(draw) do\n if type(v) == \"table\" then\n --print(\"Table \"..k)\n if v.red then\n draw[k] = Color.new(v.red, v.green, v.blue, v.alpha, true)\n end\n end\nend\n\nreturn Color"}
|
|