From 4eb5c7c8cc4cc8992700fdd04cec2e9a3ffb98dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 8 Feb 2021 22:16:04 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20=20@=2030745?= =?UTF-8?q?36999d9d84024bb1a712af634e59afcd49a=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Day 1/index.html | 4 +- Day 2/index.html | 25 +++++----- Day 3/index.html | 61 ++++++++++++------------ Day 4/index.html | 102 +++++++++++++++++++++------------------- Day 5/index.html | 7 +-- Hall of Fame/index.html | 4 +- index.html | 4 +- 7 files changed, 109 insertions(+), 98 deletions(-) diff --git a/Day 1/index.html b/Day 1/index.html index 3635f27..8c0f4cb 100644 --- a/Day 1/index.html +++ b/Day 1/index.html @@ -47,7 +47,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
@@ -109,7 +109,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
diff --git a/Day 2/index.html b/Day 2/index.html index ce10e94..381aaa9 100644 --- a/Day 2/index.html +++ b/Day 2/index.html @@ -47,7 +47,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
@@ -109,7 +109,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
@@ -207,32 +207,34 @@

When we are done, our scripts should resemble the following samples:

ServerStorage > ModuleScripts > GameSettings

local GameSettings = {}
-
+ 
 -- Game Variables
 GameSettings.intermissionDuration = 5
 GameSettings.matchDuration = 10
 GameSettings.minimumPlayers = 2
 GameSettings.transitionTime = 5
-
-return GameSettings
+ +return GameSettings +

ServerStorage > ModuleScripts > MatchManager

local MatchManager = {}
-
+ 
 function MatchManager.preparePlayers()
     print("Game starting!")
 end
-
-return MatchManager
+ +return MatchManager +

ServerScriptService > GameManager

-- Services
 local ServerStorage = game:GetService("ServerStorage")
 local Players = game:GetService("Players")
-
+ 
 -- Module Scripts
 local moduleScripts = ServerStorage:WaitForChild("ModuleScripts")
 local matchManager = require(moduleScripts:WaitForChild("MatchManager"))
 local gameSettings = require(moduleScripts:WaitForChild("GameSettings"))
-
+ 
 while true do
     repeat
         wait(gameSettings.intermissionDuration)
@@ -241,7 +243,8 @@ while true do
     print("Intermission over")
     wait(gameSettings.transitionTime)
     matchManager.prepareGame()
-end
+end +

A complete example project of the scripting we have done in class today can be found here.

Optional Homework 📄

diff --git a/Day 3/index.html b/Day 3/index.html index 2bbb080..12ebddd 100644 --- a/Day 3/index.html +++ b/Day 3/index.html @@ -47,7 +47,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
@@ -109,7 +109,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
@@ -207,87 +207,89 @@
-- Services
 local ServerStorage = game:GetService("ServerStorage")
 local Players = game:GetService("Players")
-
+ 
 -- Module Scripts
 local moduleScripts = ServerStorage:WaitForChild("ModuleScripts")
 local matchManager = require(moduleScripts:WaitForChild("MatchManager"))
 local gameSettings = require(moduleScripts:WaitForChild("GameSettings"))
-
+ 
 -- Events
 local events = ServerStorage:WaitForChild("Events")
 local matchEnd = events:WaitForChild("MatchEnd")
-
+ 
 while true do
     repeat
         wait(gameSettings.intermissionDuration)
         print("Restarting intermission")
     until Players.NumPlayers >= gameSettings.minimumPlayers
-
+ 
     print("Intermission over")
     wait(gameSettings.transitionTime)
-
+    
     matchManager.prepareGame()
     -- Placeholder wait for the length of the game.
     matchEnd.Event:Wait()
-
-end
+ +end +

ServerStorage > ModuleScripts > MatchManager

local MatchManager = {}
-
+ 
 -- Services
 local ServerStorage = game:GetService("ServerStorage")
-
+ 
 -- Module Scripts
 local moduleScripts = ServerStorage:WaitForChild("ModuleScripts")
 local playerManager = require(moduleScripts:WaitForChild("PlayerManager"))
 local gameSettings = require(moduleScripts:WaitForChild("GameSettings"))
 local timer = require(moduleScripts:WaitForChild("Timer"))
-
+ 
 -- Events
 local events = ServerStorage:WaitForChild("Events")
 local matchStart = events:WaitForChild("MatchStart")
 local matchEnd = events:WaitForChild("MatchEnd")
-
+ 
 -- Creates a new timer object to be used to keep track of match time. 
 local myTimer = timer.new()
-
+ 
 -- Local Functions
 local function timeUp()
     print("Time is up!")
 end
-
+ 
 local function startTimer()
     print("Timer started")
     myTimer:start(gameSettings.matchDuration)
     myTimer.finished:Connect(timeUp)    
 end
-
+ 
 -- Module Functions
 function MatchManager.prepareGame()
     playerManager.sendPlayersToMatch()
     matchStart:Fire()
 end
-
+ 
 matchStart.Event:Connect(startTimer)
-
-return MatchManager
+ +return MatchManager +

ServerStorage > ModuleScripts > Timer

local Timer = {}
 Timer.__index = Timer
-
+ 
 function Timer.new()
     local self = setmetatable({}, Timer)
-
+ 
     self._finishedEvent = Instance.new("BindableEvent")
     self.finished = self._finishedEvent.Event
-
+    
     self._running = false
     self._startTime = nil
     self._duration = nil
-
+    
     return self
 end
-
+ 
 function Timer:start(duration)
     if not self._running then
         local timerThread = coroutine.wrap(function()
@@ -308,7 +310,7 @@ function Timer:start(duration)
         warn("Warning: timer could not start again as it is already running.")
     end
 end
-
+ 
 function Timer:getTimeLeft()
     if self._running then
         local now = tick()
@@ -321,16 +323,17 @@ function Timer:getTimeLeft()
         warn("Warning: could not get remaining time, timer is not running.")
     end
 end
-
+ 
 function Timer:isRunning()
     return self._running
 end
-
+ 
 function Timer:stop()
     self._running = false
 end
-
-return Timer
+ +return Timer +

A complete example project of the scripting we have done in class today can be found here.

Optional Homework 📄

diff --git a/Day 4/index.html b/Day 4/index.html index 52a9908..a4c377c 100644 --- a/Day 4/index.html +++ b/Day 4/index.html @@ -47,7 +47,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
@@ -109,7 +109,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
@@ -207,141 +207,144 @@
-- Services
 local ServerStorage = game:GetService("ServerStorage")
 local Players = game:GetService("Players")
-
+ 
 -- Module Scripts
 local moduleScripts = ServerStorage:WaitForChild("ModuleScripts")
 local matchManager = require(moduleScripts:WaitForChild("MatchManager"))
 local gameSettings = require(moduleScripts:WaitForChild("GameSettings"))
 local displayManager = require(moduleScripts:WaitForChild("DisplayManager"))
-
+ 
 -- Events
 local events = ServerStorage:WaitForChild("Events")
 local matchEnd = events:WaitForChild("MatchEnd")
-
+ 
 while true do
     displayManager.updateStatus("Waiting for Players")
-
+ 
     repeat
         wait(gameSettings.intermissionDuration)
     until Players.NumPlayers >= gameSettings.minimumPlayers
-
+ 
     displayManager.updateStatus("Get ready!")
     wait(gameSettings.transitionTime)
-
+    
     matchManager.prepareGame()
     local endState = matchEnd.Event:Wait()
     print("Game ended with: " .. endState)
-end
+end +

ServerStorage > ModuleScripts > MatchManager

local MatchManager = {}
-
+ 
 -- Services
 local ServerStorage = game:GetService("ServerStorage")
 local ReplicatedStorage = game:GetService("ReplicatedStorage")
-
+ 
 -- Module Scripts
 local moduleScripts = ServerStorage:WaitForChild("ModuleScripts")
 local playerManager = require(moduleScripts:WaitForChild("PlayerManager"))
 local gameSettings = require(moduleScripts:WaitForChild("GameSettings"))
 local timer = require(moduleScripts:WaitForChild("Timer"))
-
+ 
 -- Events
 local events = ServerStorage:WaitForChild("Events")
 local matchStart = events:WaitForChild("MatchStart")
 local matchEnd = events:WaitForChild("MatchEnd")
-
+ 
 -- Values
 local displayValues = ReplicatedStorage:WaitForChild("DisplayValues")
 local timeLeft = displayValues:WaitForChild("TimeLeft")
-
+ 
 -- Creates a new timer object to be used to keep track of match time. 
 local myTimer = timer.new()
-
+ 
 -- Local Functions
 local function stopTimer()
     myTimer:stop()
 end
-
+ 
 local function timeUp()
     matchEnd:Fire(gameSettings.endStates.TimerUp)
 end
-
+ 
 local function startTimer()
     print("Timer started")
     myTimer:start(gameSettings.matchDuration)
     myTimer.finished:Connect(timeUp)    
-
+ 
     while myTimer:isRunning() do
         -- Adding +1 makes sure the timer display ends at 1 instead of 0. 
         timeLeft.Value = (math.floor(myTimer:getTimeLeft() + 1))
         -- By not setting the time for wait, it offers more accurate looping  
         wait()
     end
-
+ 
 end
-
+ 
 -- Module Functions
 function MatchManager.prepareGame()
     playerManager.sendPlayersToMatch()
     matchStart:Fire()
 end
-
+ 
 matchStart.Event:Connect(startTimer)
 matchEnd.Event:Connect(stopTimer)
-
-return MatchManager
+ +return MatchManager +

ServerStorage > ModuleScripts > GameSettings

local GameSettings = {}
-
+ 
 -- Game Variables
 GameSettings.intermissionDuration = 5
 GameSettings.matchDuration = 10
 GameSettings.minimumPlayers = 2
 GameSettings.transitionTime = 5
-
+ 
 -- Possible ways that the game can end.
 GameSettings.endStates = {
     TimerUp = "TimerUp",
     FoundWinner = "FoundWinner"
 }
-
-return GameSettings
+ +return GameSettings +

ServerStorage > ModuleScripts > PlayerManager

local PlayerManager = {}
-
+ 
 -- Services
 local Players = game:GetService("Players")
 local ServerStorage = game:GetService("ServerStorage")
 local ReplicatedStorage = game:GetService("ReplicatedStorage")
-
+ 
 -- Modules
 local moduleScripts = ServerStorage:WaitForChild("ModuleScripts")
 local gameSettings = require(moduleScripts:WaitForChild("GameSettings"))
-
+ 
 -- Events
 local events = ServerStorage:WaitForChild("Events")
 local matchEnd = events:WaitForChild("MatchEnd")
-
+ 
 -- Map Variables
 local lobbySpawn = workspace.Lobby.StartSpawn
 local arenaMap = workspace.Arena
 local spawnLocations = arenaMap.SpawnLocations
-
+ 
 -- Values
 local displayValues = ReplicatedStorage:WaitForChild("DisplayValues")
 local playersLeft = displayValues:WaitForChild("PlayersLeft")
-
+ 
 -- Player Variables
 local activePlayers = {}
 local playerWeapon = ServerStorage.Weapon
-
+ 
 -- Local Functions
 local function checkPlayerCount()
     if #activePlayers == 1 then
         matchEnd:Fire(gameSettings.endStates.FoundWinner)
     end
 end
-
+ 
 local function removeActivePlayer(player)
     for playerKey, whichPlayer in pairs(activePlayers) do
         if whichPlayer == player then
@@ -351,52 +354,53 @@ local function removeActivePlayer(player)
         end
     end
 end
-
+ 
 local function respawnPlayerInLobby(player)
     player.RespawnLocation = lobbySpawn
     player:LoadCharacter()
 end
-
-
+ 
+ 
 local function onPlayerJoin(player)
     player.RespawnLocation = lobbySpawn
 end
-
+ 
 local function preparePlayer(player, whichSpawn)
     player.RespawnLocation = whichSpawn
     player:LoadCharacter()
-
+ 
     local character = player.Character or player.CharacterAdded:Wait()
     local sword = playerWeapon:Clone()
     sword.Parent = character
-
+ 
     local humanoid = character:WaitForChild("Humanoid")
-
+ 
     humanoid.Died:Connect(function()
         respawnPlayerInLobby(player)
         removeActivePlayer(player)
     end)
-
+ 
 end
-
+ 
 -- Module Functions 
 function PlayerManager.sendPlayersToMatch()
     local arenaSpawns = spawnLocations:GetChildren()
-
+ 
     for playerKey, whichPlayer in pairs(Players:GetPlayers()) do
         table.insert(activePlayers,whichPlayer)    
         local spawnLocation = arenaSpawns[1]
         preparePlayer(whichPlayer, spawnLocation)
         table.remove(arenaSpawns, 1)
     end
-
+ 
     playersLeft.Value = #activePlayers
 end
-
+ 
 -- Events
 Players.PlayerAdded:Connect(onPlayerJoin)
-
-return PlayerManager
+ +return PlayerManager +

A complete example project of the scripting we have done in class today can be found here.

Optional Homework 📄

diff --git a/Day 5/index.html b/Day 5/index.html index c9d5214..bb229d1 100644 --- a/Day 5/index.html +++ b/Day 5/index.html @@ -47,7 +47,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
@@ -109,7 +109,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
@@ -184,7 +184,8 @@

Download this file and open it in Roblox Studio. Publish it to Roblox (Alt+P) as your final Roblox Royale game, so name it something cool! Change the way that the arena looks by changing the colors, materials, and shapes of existing parts and by adding new parts from the toolbox.

Second Half

Let's open the GameSettings script (ServerStorage > ModuleScripts > GameSettings) and update a configuration variable:

-
GameSettings.matchDuration = 180
+
GameSettings.matchDuration = 180
+

💡 Note: We are changing the match duration variable from 10 seconds to 180 seconds. 180 seconds was calculated by taking the amount of seconds in one minute (60) and multiplying it by 3 to get the amount of seconds there are in 3 minutes.

diff --git a/Hall of Fame/index.html b/Hall of Fame/index.html index 9f9a49a..855b901 100644 --- a/Hall of Fame/index.html +++ b/Hall of Fame/index.html @@ -47,7 +47,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
@@ -109,7 +109,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
diff --git a/index.html b/index.html index 133e0ec..0988ecb 100644 --- a/index.html +++ b/index.html @@ -47,7 +47,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.
@@ -109,7 +109,7 @@
- Last published 12/12/2020,
8:02:40 PM PST. + Last published 2/8/2021,
2:16:02 PM PST.