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

Process touch-event and WirelessRedstone input

Question

Hey,

i'm new here and a programming noob but I would like to process touch-events from the monitor and WirelessRedstone input signals in parallel for my program. My question is, how this can be implemented technically.

The touch event is currently:

while true do
local component = require("component")
local rs = component.redstone
local gpu = component.gpu
local colors = require("colors")
local event = require("event")
local id , _, x, y = event.pull("touch")
if id == "touch" and x == 97 and y == 2 then --1
    term.setCursor(1,49)
    term.clearLine()
    print("Verbindungen: 1->23 | 1->105 | 1->12 | 1->20 | 1->21")
    local id , _, x, y = event.pull("touch")
    if id == "touch" and x > 70 and x < 73 and y == 20 then --23
        term.setCursor(1,49)
        term.clearLine()
        print("1->23")
        rs.setWirelessFrequency(101)
        rs.setWirelessOutput(true)
        os.sleep(1)
        rs.setWirelessOutput(false)
    elseif id == "touch" and x > 106 and x < 110  and y == 30 then --105
        term.setCursor(1,49)
        term.clearLine()
        print("1->105")
        rs.setWirelessFrequency(102)
        rs.setWirelessOutput(true)
        os.sleep(1)
        rs.setWirelessOutput(false)
-- reduced
    else
        term.setCursor(1,49)
        term.clearLine()
    end
elseif id == "touch" and x == 94 and y == 2 then --2
    term.setCursor(1,49)
    term.clearLine()
    print("Verbindungen: 2->23 | 2->105 | 2->12 | 2->20 | 2->21")
    local id , _, x, y = event.pull("touch")
    if id == "touch" and x > 70 and x < 73 and y == 20 then --23
        term.setCursor(1,49)
        term.clearLine()
        print("2->23")
        rs.setWirelessFrequency(106)
        rs.setWirelessOutput(true)
        os.sleep(1)
        rs.setWirelessOutput(false)
    elseif id == "touch" and x > 106 and x < 110  and y == 30 then --105
        term.setCursor(1,49)
        term.clearLine()
        print("2->105")
        rs.setWirelessFrequency(107)
        rs.setWirelessOutput(true)
        os.sleep(1)
        rs.setWirelessOutput(false)
-- reduced
    else
        term.setCursor(1,49)
        term.clearLine()
    end
-- reduced a lot
elseif id == "touch" and x == 1 and y == 1 then
    term.clear()
    break
else
    term.setCursor(1,49)
    term.clearLine()
end
end

Now the WirelessRedstone Input Part should come. There I have no idea how to implement it. In general, this would also have to run via an if then query, since I would have to listen for around 187 frequencies. I need the input for printing stuff on the screen. Of course, there is also the question of how performant it will be in the end. If someone had an idea, it would be really nice.
 
Thank you in advance!
 
Mc_Jeronimo

 

And sorry for my english :)

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

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