Jump to content

Recommended Posts

  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

Posted

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")

Posted

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.

Posted

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.

Posted

Oh Reece, I simply meant that since this topic mostly turned into a discussion between the two of us that technically could have taken place in PMs, could you post the basic code that finally worked with engine_state and buffer_state so that everyone could benefit. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   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.

Announcements

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



×
×
  • Create New...