Ok, so here's a summary of your current code, focusing on the structuring:
local function skyblock1()
-- Write page 1 of the skyblock note.
-- Wait for input. Based on which button is pushed, either:
-- Go back to the main menu, or
-- go to the next page.
end
local function skyblock2()
-- Write page 2 of the skyblock note.
-- Wait for input. Based on which button is pushed, either:
-- Go back to the main menu, or
-- go to the first page.
end
-- Draw the main menu.
-- Wait for input. Based on which button is pushed, either:
-- Go to the first page of the rules
-- Go to the first page of skyblock
-- Go to the first page of the commands
-- etc
What I'm suggesting is that you use function parameters and return values to allow the different areas of your code to communicate with each other. For example:
local function drawPage(pageName, pageNum)
if pageName == "command" then
if pageNum == 1 then
-- Write the first "command" page.
elseif pageNum == 2 then
-- Write the second "command" page.
end
else if pageName == "rules" then
if pageNum == 1 then
-- Write the first "rules" page.
elseif pageNum == 2 then
-- Write the second "rules" page.
end
end
-- Render buttons at the bottom.
-- Only render a back button if not on the first page, etc.
-- Wait for the user to push a button:
while true do
local event, side, x, y = os.pullEvent("monitor_touch")
if (back a page button pushed) and pageNum > 1 then
return pageNum - 1
elseif (forward button pushed) and pageNum < 3 then -- If you're thinking "but some subjects have more than two pages", then now'd be a good time for you to start researching tables.
return pageNum + 1
elseif (main menu button pushed) then
return
end
end
end
-- Draw the main menu.
-- Wait for input:
while true do
local event, side, x, y = os.pullEvent("monitor_touch")
local pageName
local pageNum = 1
if (rules button pushed) then
pageName = "rules"
elseif (commands button pushed) then
pageName = "command"
end
while pageName and pageNum do -- Keep showing pages until one of these values becomes undefined.
pageNum = drawPage(pageName, pageNum)
end
end
Bear in mind that there are an immeasurable number of ways you can do this. The above isn't the most efficient; it's merely an example I'm hoping will make sense to you. It's geared towards demonstrating use of parameters and return values, but truth be told, once you understand them, you should be able to see why a function call isn't needed here in the first place.