-- ** Project: A Trip to the Pool **
-- Note: This may look like a lot at first, but just take the time to read it line by line,
-- along with all the comments, and it should make sense.
-- Also, it should make sense as you read it from top to bottom and refer back to the variables as they show up.
-- variables used (Feel free to change the values of these to see how it affects the output)
local temperature = 75 -- number (any number, wheter it's an integer or a number with a decimal. Could be positive or negative)
local isPoolOpen = true -- boolean (true or false)
local weather = "sunny" -- string (any words or letters, or digits, anything you can write down)
local hasSunscreenOn = false -- boolean (true or false)
local projectTitle = "A Trip to the Pool" -- String: Title of our project
-- Printing out temperature (we use ".." to connect the string with the value of "temperature" so it prints out as a whole)
print("Current Temperature: " .. temperature)
-- For the conditionals below, along with the loop,
-- take note of the allignment since every "if" has an "end", unless you have an "else", as you see at the end of the outer conditional
-- The loop also has its corresponding 'end"
-- Outside Conditional: Check if pool is open
if isPoolOpen == true then
print("Pool is open.")
-- Inner Conditional 1: Check if it's too cold
if temperature < 60 or weather == "snowy" then
print("It's too cold to swim!")
end
-- Inner Conditional 2: Check if you will get a sunburn
if weather == "sunny" and hasSunscreenOn == false then
print("You got a sunburn!")
-- Loop inside of inner conditional 2:
-- Tells person to apply aloe vera 5 times
for count = 1, 5 do -- loop goes through values 1-5
print("Apply aloe vera x" .. count) -- variable "count is used so the number matches the iteration"
end
end
else
-- This happens if outer conditional is false, while means the pool is closed
-- if the outer conditional is false, then this code below is the only code that runs
-- this means that all of the code abode is skipped because it only runs if the condition is true.
print("sorry, the pool is closed!")
end
To embed this project on your website, copy the following code and paste it into your website's HTML: