Posted 31 December 2016 - 07:51 PM
Hello,
I'm trying to create a list of pages to load with the touchpoint API and then cycle through them so I can scroll through the pages like the next or previous buttons in an online book. Here is the basic code I am trying to get to work:
When I try to run the code it draws the first button and sets up the pages. However, when I try to click the button and proceed to the next page, it gives an error saying that on line 10, it is expecting a string but receiving a table. I do not know how to convert what the current page is into a string so it can run. I have tried using concat and serialize/unserialize, but neither way works and I'm not sure how to do it. Thank you.
I'm trying to create a list of pages to load with the touchpoint API and then cycle through them so I can scroll through the pages like the next or previous buttons in an online book. Here is the basic code I am trying to get to work:
os.loadAPI("touchpoint")
monitor = peripheral.wrap("left")
local a = touchpoint.new("left")
local b = touchpoint.new("left")
local currentPage = a
function nextPage()
local pageList = 'ab'
local index = pageList:find(currentPage)
if index then
currentPage = index + 1
end
currentPage:draw()
end
a:add("--->", function() nextPage() end, 1, 1, 10, 10, colors.red, colors.green)
b:add("placeholder", nil, 1 ,1 , 10, 10, colors.red, colors.green)
currentPage:draw()
currentPage:run()
When I try to run the code it draws the first button and sets up the pages. However, when I try to click the button and proceed to the next page, it gives an error saying that on line 10, it is expecting a string but receiving a table. I do not know how to convert what the current page is into a string so it can run. I have tried using concat and serialize/unserialize, but neither way works and I'm not sure how to do it. Thank you.