Main Menu

Touchpoint api

Started by DarksideVT, Jan 06, 2021, 12:20 AM

Previous topic - Next topic

DarksideVT

I'm trying to use this api with CC:tweaked http://www.computercraft.info/forums2/index.php?/topic/14784-touchpoint-api/

I tried to use multiple pages like suggested on post #14 but it keeps giving me an error saying "button out of bounds"

If I remove the other 2 pages, it start fine but obviously, the menus don't change. Is there a modification that I can make to the example to get this thing to work?

Lupus590

Post your code please. Use pastebin or another service if it's long.

DarksideVT

Thanks so much for taking a look at this, I've been so confused as to why this isn't working.

os.loadAPI("/api/touchpoint")
--establish two "pages" of buttons
local page1 = touchpoint.new("back")
local page2 = touchpoint.new("back")
local page3 = touchpoint.new("back")
local page

function rsRight()
    page1:toggleButton("Activate Right")
    rs.setOutput("right", not rs.getOutput("right"))
end

function rsLeft()
    page1:toggleButton("Activate Left")
    rs.setOutput("left", not rs.getOutput("left"))
end

function redMenu()
    page = page2
end

function testMenu()
    page = page3
end

function mainTable()
    page = page1
end

do
    page1:add("Redstone", redMenu, 2,2,10,14)
    page1:add("Test Menu", testMenu, 12,2,20,14)

    page2:add("Left", rsLeft,2,2,10,14)
    page2:add("Right", rsRight, 12,2,20,14)
    page2:add("Back", mainTable, 16,2,20,29)
    page3:add("Dummy1", rsLeft,2,2,10,14)
    page3:add("Dummy2", rsRight, 12,2,20,14)
    page3:add("Back", mainTable, 16,2,20,29)
end

mainTable()

while true do
    page:draw()
    local event, p1 = page:handleEvents(os.pullEvent())   ---button_click, name
    if event == "button_click" then
        --remove toggling and simplify button running
        page.buttonList[p1].func()
    end
end

Lupus590

How big is your monitor? It could be that you are trying to draw a button off the screen.

DarksideVT

dang it. Thanks so much...making the screen bigger fixed the issue.