Compare commits

...

2 Commits

Author SHA1 Message Date
Jay 6840ac51c1 variabletutorial 2020-05-09 00:11:25 +01:00
Jay a554a87f84 added ryan's tutorials 2020-05-08 23:15:01 +01:00
5 changed files with 159 additions and 11 deletions

View File

@ -1,4 +1,5 @@
return {
require("tevgit:core/tutorials/lessons/helloworld.lua"),
require("tevgit:core/tutorials/lessons/strings.lua")
require("tevgit:core/tutorials/lessons/simplemaths.lua"),
require("tevgit:core/tutorials/lessons/variables.lua")
}

View File

@ -0,0 +1,97 @@
local framework = require("tevgit:core/tutorials/framework.lua")
return {
name = "Simple Mathematics",
description = "Simple mathematic operations",
pages = {
framework.exampleCode("Arithmetic Operators",
[[Arithmetic operations are sometimes necessary to determine how to handle arguments or conditions.
Lua can handle the typical maths operators:
"+" for addition, "-" for subtractions, "*" for multiplication, and "/" for division.
For our example, we are using the 'print()' function to display the results of these maths operations.
The console is what you see on the right of the screen.
When you're ready to continue, press next at the bottom of your screen.
Example Output from the script on the left:]],
[[--Addition
print(1+2)
--Subtraction
print(3-1)
--Multiplication
print(4*2)
--Division
print(2/1)
]],
[[
3
2
8
2
]]),
framework.interactiveCode("Try it: Arithmetic Operations",
[[Now that you know the basic operators, let's try to use them.
For each of the following samples, make the output equal 20, using the operation in between the two quotation marks.
You may need to include numbers as well. When you think you have it, press run.]],
[[print(12 "addition" __ )
-- Friendly reminder: print(1 + 1) will display 2]],
function(script, logs)
local answer = "print(12+8)"
local correct = script.text:lower():gsub(" ", ""):sub(0, answer:len()) == answer
if not correct then
print("Try again thats not quite right...\n")
else
print("Well done! Press next!\n")
end
return correct
end),
framework.interactiveCode("Try it: Arithmetic Operations",
[[Now that you know the basic operators, let's try to use them.
For each of the following samples, make the output equal 20, using the operation in between the two quotation marks.
You may need to include numbers as well. When you think you have it, press run.]],
[[print(2000 "division" __ )]],
function(script, logs)
local answer = "print(2000/100)"
local correct = script.text:lower():gsub(" ", ""):sub(0, answer:len()) == answer
if not correct then
print("Try again thats not quite right...\n")
else
print("Well done! Press next!\n")
end
return correct
end),
framework.interactiveCode("Try it: Arithmetic Operations",
[[Now that you know the basic operators, let's try to use them.
For each of the following samples, make the output equal 20, using the operation in between the two quotation marks.
You may need to include numbers as well. When you think you have it, press run.]],
[[print(10 "multiplication" __ )]],
function(script, logs)
local answer = "print(10*2)"
local correct = script.text:lower():gsub(" ", ""):sub(0, answer:len()) == answer
if not correct then
print("Try again thats not quite right...\n")
else
print("Well done! Press next!\n")
end
return correct
end),
framework.interactiveCode("Try it: Arithmetic Operations",
[[Now that you know the basic operators, let's try to use them.
For each of the following samples, make the output equal 20, using the operation in between the two quotation marks.
You may need to include numbers as well. When you think you have it, press run.]],
[[print(__ "subtraction" 40)]],
function(script, logs)
local answer = "print(60-40)"
local correct = script.text:lower():gsub(" ", ""):sub(0, answer:len()) == answer
if not correct then
print("Try again thats not quite right...\n")
else
print("Well done! Press next!\n")
end
return correct
end),
}
}

View File

@ -1,10 +0,0 @@
local framework = require("tevgit:core/tutorials/framework.lua")
return {
name = "String Manipulation",
description = "test test test",
pages = {
framework.titleDesc("Test ", "Description"),
framework.titleDesc("Test2 ", "Description2")
}
}

View File

@ -0,0 +1,56 @@
local framework = require("tevgit:core/tutorials/framework.lua")
return {
name = "Variables",
description = "Learning Variables",
pages = {
framework.interactiveCode("Naming things in our world ",
[[Variables are a way of storing data in your code. In Lua, a variable can contain any 'type' - for example: numbers, strings and tables.
Try pressing run right now and take note of what displays in the console.
Then type testVariable between the two quotation marks, and press run again]],
[[local newVariable = "example"
print(newVariable)]],
function(script, logs)
local answer = "localnewvariable=\"testvariable\""
local correct = script.text:lower():gsub(" ", ""):sub(0, answer:len()) == answer
if not correct then
local answer = "localnewvariable=\"example\""
correct = script.text:lower():gsub(" ", ""):sub(0, answer:len()) == answer
if correct then
print("As you can see, print(newVariable) displays the contents of the variable - AKA: example\n\nChange the value from example to testVariable\n")
else
print("Try again!\n")
end
return false
else
print("Well done, isn't setting variables a blast? Press next!\n")
end
return correct
end),
framework.exampleCode("Dissecting your script",
[[A variable is a way to assign a name to something.
Variables can come in the form of multiple types: strings, numbers, booleans, tables, functions, and much more!
In the first section, you declared the variable "newVariable" as a string "testVariable"; a string is usually a phrase or non-numeric set of characters.
The print function simply outputs the variables in the console. The console is what you see on the right of the screen.
When you're ready to continue, press next at the bottom of your screen.
Example Output from the script on the left:]],
[[local newPhrase = "This is a string"
local newNumber = 4
print(newPhrase)
print(newNumber)
]], [["This is a string"
4
]]),
}
}

View File

@ -215,6 +215,10 @@ local function loadTutorialPage(tutorial, pagei, lessonFrame)
textColour = colour.white(),
dropShadowAlpha = 0.2
})
btn:on("mouseLeftUp", function()
reload()
end)
else
btn = teverse.construct("guiTextBox", {
parent = lessonFrame,