Posted 05 January 2015 - 08:50 PM
I wrote a program (http://pastebin.com/rqQxwaPw) using the touchpoint API (http://pastebin.com/pFHeia96). No crashes (yay) and it's sending the proper redstone for Test 7-12 but pressing page 2 does nothing, while I'm expecting it to change pages: where did I go wrong?
I read through the touchpoint forum thread and I saw some example code of multiple pages
Thanks for any help/pointers.
My program only:
I read through the touchpoint forum thread and I saw some example code of multiple pages
Thanks for any help/pointers.
My program only:
Spoiler
-- load the touchpoint API
os.loadAPI("touchpoint")
-- name/location of monitor
monName = "monitor_2"
-- the side to output redstone signal
rsDirection = "bottom"
-- establish two pages of buttons
local page_1 = touchpoint.new(monName)
local page_2 = touchpoint.new(monName)
-- one variable to put each page into in order to simplify switching
local t
-- functions to switch pages
function page1()
t = page_1
end
function page2()
t = page_2
end
-- array for targets
target = {
["Page 1"] = 0,
["Page 2"] = 0,
["Test 7"] = 1,
["Test 8"] = 2,
["Test 9"] = 3,
["Test 10"] = 4,
["Test 11"] = 5,
["Test 12"] = 6,
["Test 1"] = 7,
["Test 2"] = 8,
["Test 3"] = 9,
["Test 4"] = 10,
["Test 5"] = 11,
["Test 6"] = 12,
}
-- a function to send redstone for appropriate buttons
function rsOut()
redstone.setAnalogOutput(rsDirection, target[p1])
end
do
-- page 1
-- left column
page_1:add("Test 7", rsOut, 2, 2, 18, 4)
page_1:add("Test 8", rsOut, 2, 6, 18, 8)
page_1:add("Test 9",rsOut, 2, 10, 18, 12)
-- right column
page_1:add("Test 10", rsOut, 22, 2, 38, 4)
page_1:add("Test 11", rsOut, 22, 6, 38, 8)
page_1:add("Test 12", rsOut, 22, 10, 38, 12)
page_1:add("Page 2", page2, 22, 16, 38, 18)
-- page 2
-- left column
page_2:add("Test 1", nil, 2, 2, 18, 4)
page_2:add("Test 2", nil, 2, 6, 18, 8)
page_2:add("Test 3", nil, 2, 10, 18, 12)
page_2:add("Page 1", page1(), 2, 16, 18, 12)
-- right column
page_2:add("Test 4", nil, 22, 2, 38, 4)
page_2:add("Test 5", nil, 22, 6, 38, 8)
page_2:add("Test 6", nil, 22, 10, 38, 12)
end
-- Starts with page 1, checks for button clicks, flashes them and runs the program it has
--page1()
t:draw()
while true do
-- handleEvents will convert monitor_touch events to button_click if it was on a button
local event, p1 = t:handleEvents(os.pullEvent())
if event == "button_click" then
t:flash(p1)
end
end