Jump to content

Info Menu


Reece C.

Recommended Posts

  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

So in short I don't have to change anything about these codes. So here they are. I went over them, and I can't see anything wrong. It looks fine to me.

But here they are, maybe you or someone can find the issue.

Sender Code: (computer attached to engines)

rednet.open("left")

while true do

shell.run("clear")

if rs.getInput ("back") then

      rednet.send(21,"engines on")

else

    rednet.send(21,"engines off")

end

os.pullEvent("redstone")

end


 

Receiver code: (main computer with monitor)


rednet.open("top")

local engine_state = false

mon = peripheral.wrap("back")

while true do

    id, message = os.pullEvent("rednet_message")

    if id == 17 then

        if message == "engines on" then

            engine_state = true

        elseif message == "engines off" then

            engine_state = false

        end

    end

 

    mon.clear()

    mon.setCursorPos(5,5)

    if engine_state == true then

        mon.write("Engines: On")

    else

        mon.write("Engines: Off")

    end

end

I can't test this at the moment, but I think the syntax of os.pullEvent returns the Event as the first parameter:

Common syntax

event, param1, param2, param3 = os.pullEvent()

So I would try:

event, id, message = os.pullEvent("rednet_message")

Link to comment
Share on other sites

I can't test this at the moment, but I think the syntax of os.pullEvent returns the Event as the first parameter:

So I would try:

event, id, message = os.pullEvent("rednet_message")

This looks almost identical to the code I used. I don't see much, if any difference between the two.

Link to comment
Share on other sites

The naming is confusing. rednet as Reece is using is strictly about inter-computer communication over (it seems) multiple transmission mediums, wired and wireless. It's not the same as using RedNet Cables with their 16 colors. Yes one could have implemented this with RedNet Cable and that would have been a bit more straight forward to figure the coding portion out since you're testing physical lines for on or off state. This is simply a different way to implement the same thing. It's more powerful than using RedNet cables because you could very easily code something that might have more than on or off states, eg auto, manual, off. Also you would not be limited to running physical lines between all of your outposts. It just requires more know-how to implement.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Announcements

  • Anything claiming to be official Technic servers are not allowed here, for obvious reasons



×
×
  • Create New...