Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

XFactHD

Members
  • Content Count

    10
  • Joined

  • Last visited

Posts posted by XFactHD

  1. The little program with the empty while loop was just a test program. The while loop just keeps the program running until OC kills it.

    In my Base Control Program I need the while loop for the main code.

    If I use event.listen() then I can't call the listener in the main loop. Every forum post on touch events tells me to do exactly what I did in this program.

  2. In my Base Control Program I define a callback function:

    local function getClick(_, _, x, y, _, _)
      if x > 44 and x < 50 and y == 4 and active == false then
        setStatus(true)
      elseif x > 44 and x < 50 and y == 4 and active == true then
        setStatus(false)
      elseif x > 44 and x < 50 and y == 6 and safety == false then
        safety = true
      elseif x > 44 and x < 50 and y == 6 and safety == true then
        safety = false
      elseif x > 44 and x < 50 and y == 20 and spawnEnder == false then
        setSpawnEnder(true)
      elseif x > 44 and x < 50 and y == 20 and spawnEnder == true then
        setSpawnEnder(false)
      elseif x > 44 and x < 50 and y == 22 and spawnZS == false then
        setSpawnZS(true)
      elseif x > 44 and x < 50 and y == 22 and spawnZS == true then
        setSpawnZS(false)
      elseif x == 82 and y == 1 then
        shutdown()
      end
    end
    

    and just before I start the main loop I create an event listener via event.listen("touch", getClick).

    When I run the program and click on the screen, nothing happens.

     

    If I try the same with the following code:

    local function getClick(_, _, x, y, _, _)
      print("XCoord: " ..x.. " YCoord: " ..y)
    end
    
    event.listen("touch", getClick)
    
    while true do
    
    end
    

    and run the program and click on the screen, at first nothing happens, but as soon as the program crashes with "Too long without yielding!" the x and y coords for all touch events get printed correctly. If I click on the screen after the program crashed, I still get the coords printed on the screen as if the program was running.

  3. I didn't change the pastebin link when writing the EDIT.

    Now I have another problem, if event.listen("touch", getClick) receives a touch signal, the defined callback function doesn't get triggered.

    If I try this in a small test program that prints the results to screen, the coordinates are exactly as expected.

  4. When trying to execute this code (http://pastebin.com/Kujgx5sx), the computer gives me the following error:

    "control.lua:73: 'end' expected (to close 'if' at line 47) near <eof>"

    If I comment out the erroring "if" block with the method to execute and the "end" statement or put an "end" statement at the expected position, it gives me the same error for another of the three "if" blocks. If I comment out all three if blocks, it expects me to put an "end" at <eof> to close the method. I don't get why, because all the "end" statements the computer expects are in the code. If I put all four "end" statements the computer expects, the program runs the way it should.

  5. I don't know how to make code blocks on the mobile.

    As for your suggestion: The check for not nil is just because the program crashes if you add a timeout to event.pull and the if statement then that checks for the coordinates tries to use nil as a number.

    I have briefly looked into event listeners and I am not really sure how to use them.

  6. I have two questions on touch screen events:

    1: Is it possible to make two parallel loops to not slow down the updating of the screen by pulling an event?

    2: I have a program with some rather small buttons. At first I tried to use fixed coordinates in an if statement and then I used a range for the coordinates in the if statement but it still doesn't work for me. Here is the relevant code: http://pastebin.com/KJmUsgD7

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.