This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Kingdaro's profile picture

[1.51+] Using Network Cables (for dummies)

Started by Kingdaro, 18 March 2013 - 09:03 AM
Kingdaro #1
Posted 18 March 2013 - 10:03 AM
Network Interaction
A wired modem has the exact same functions as a wireless modem, so if you already know how to use wireless, you know how to work with wired modems, and vice versa. Wireless modems are just this, but without cables. Old Rednet APIs are even compatible with wired modems.

So let's say we have a setup like this:

Spoiler

We have sending and receiving code for both computers.

Left Computer:

local modem = peripheral.wrap('right')
modem.transmit(1,1,'Hello!')

Here we're wrapping the modem as a peripheral, like we would a monitor or printer. Then we use the .transmit() function to send a message, like rednet.send().

The first number is the frequency to send the message on. Computers that have modems opened on this frequency can receive messages on this frequency. In this example, modems that ran modem.open(1) will be able to receive this message, if they are connected in the wired network. You don't need to open your modem on that frequency to send a message.

The second number is the channel you want your senders to reply on. This is unimportant if you're only trying to send a message, but is helpful for creating servers. To get a reply, you have to open the modem on the frequency you want the reply on. In this example, if we wanted a reply, we would have to do modem.open(1) on this computer.

The message is self-explanatory. It's simply the string we send to other computers, like we would with rednet.send.

Right Computer:

local modem = peripheral.wrap('left')
modem.open(1)

local _, side, freq, rfreq, message = os.pullEvent('modem_message')

print('The message came on the '..side..' modem.')
print('It was on frequency '..freq..' and wants a reply on '..rfreq)
print('The message was: '..message)

Here, we're going to listen for the message that the left computer is sending to us. To do that, we have to open on the frequency that we believe the other computer is sending. We know that the left computer is sending a message on frequency 1, so we .open() on frequency 1.

When we receive our message, it's captured as an event, like 'key', 'char' or 'mouse_click'. The params for the event are side, the side of the modem we got our message from, freq, the frequency it was sent on, rfreq, the frequency we should reply on, and message, what the other computer sent to us.

Afterwards, we're simply printing the information we've received. Running this program first, and the program on the left computer afterwards should yield this result:

Spoiler


[anchor=peripherals]Peripheral Interaction
If, perhaps, you wanted to learn about peripheral interaction through cables, that's way easier. We'll go ahead and connect a regular old monitor to this setup.

Spoiler

In order to "enable" it, you have to right-click the connection to the monitor.

Spoiler

On the left computer, we can have this code:

local mon = peripheral.wrap('monitor_19')

mon.setBackgroundColor(colors.white)
mon.setTextColor(colors.black)
mon.setCursorPos(1,1)
mon.setTextScale(3)
mon.clear()

mon.write('Hello There!')

When we connect the computer to the monitor via modem and cable, then enable the monitor's connection, we instantly have access to the monitor, and instead of connecting to it though its side, we use it's "name". The name is given if you enable or disable the peripheral's connection, and in this case, it's monitor_19. From there, we would use it like any normal peripheral. The bottom is the result of running this script:

Spoiler

That should give a pretty good explanation on how to use the cables. Feel free to ask any questions.
theoriginalbit #2
Posted 18 March 2013 - 10:16 AM
nice tutorial :)/> about time someone did this :P/>
Kingdaro #3
Posted 18 March 2013 - 10:18 AM
nice tutorial :)/> about time someone did this :P/>
Haha, I know right? I feel like cables are like my specialty now, or something. I've been playing with them a lot recently ever since I found out how to use peripherals through them.
theoriginalbit #4
Posted 18 March 2013 - 10:19 AM
Haha, I know right? I feel like cables are like my specialty now, or something. I've been playing with them a lot recently ever since I found out how to use peripherals through them.
Haha yeh I've been meaning to, but I got a little too lazy…

You should reply to this topic
SadKingBilly #5
Posted 18 March 2013 - 03:21 PM
Is that a Windows theme you're running in the screenshot of the "msg" output? Or is it a different OS? It looks amazing.

Oh, and the tutorial is great, too! Is it possible to have a single modem open on more than one frequency at a time, though? I assume it is, since one of the returns from "modem_message" is the frequency it was received on.
Kingdaro #6
Posted 18 March 2013 - 03:36 PM
Is that a Windows theme you're running in the screenshot of the "msg" output? Or is it a different OS? It looks amazing.
It's Ubuntu, Cinnamon Desktop, theme is Boje Blue. Quite nice, yes.

Oh, and the tutorial is great, too! Is it possible to have a single modem open on more than one frequency at a time, though? I assume it is, since one of the returns from "modem_message" is the frequency it was received on.
Yep. You can have up to 128 channels opened on one modem.
Altair357 #7
Posted 18 March 2013 - 03:45 PM
Very nice tutorial, helped me out a lot. I had no clue how to use these things beforehand.

Question: What is a 'reply' here? Does the peripheral have some sort of .reply() function?
Kingdaro #8
Posted 18 March 2013 - 03:46 PM
Eh, I would say that the reply channel is only there for helper/convenience reasons. A reply is simply a modem.transmit() through the reply frequency.
Altair357 #9
Posted 18 March 2013 - 03:51 PM
Alright, thanks.
dan200 #10
Posted 19 March 2013 - 12:33 AM
Good tutorial! One thing worth mentioning, however, is that the peripheral functions exposed by the wired modem are *exactly the same* as those on the wireless modem. So if you already know how to use wireless modes, you know how to use wired modems. You can even use the old "rednet" APIs exactly as you always could.
Kingdaro #11
Posted 19 March 2013 - 12:57 AM
Edited the OP. Thanks dan!
theoriginalbit #12
Posted 19 March 2013 - 12:59 AM
Edited the OP. Thanks dan!
You know its a good tutorial when dan200 replies saying its a good tutorial :P/>
PixelToast #13
Posted 20 March 2013 - 03:46 AM
verry helpful, i was wondering how to get peripherals to work c_c
BigSHinyToys #14
Posted 20 March 2013 - 08:58 AM
There are a lot of useful function that the wired modem can do when used directly.

open
isOpen
close
closeAll
transmit
isWireless
getNamesRemote
isPresentRemote
getTypeRemote
getMethodsRemote
callRemote

broken down

open
isOpen
close
closeAll
transmit
standard rednet functions
isWireless - checks if the modem is WIFI or wire
getNamesRemote - lists all active devices
isPresentRemote - checks if a device is connected example "drive_0" returns true of false
getTypeRemote - tells you the type of the device using its handle
getMethodsRemote - same as peripheral.getMethods() but for remote devices
callRemote - used to actual call a remote peripheral to do something

example
peripheral.call("back","callRemote","monitor_1","write","hello")

That is the underlying structurer to the peripheral wrap system. I can see some interesting hacks based on these calls.
Kingdaro #15
Posted 20 March 2013 - 09:42 AM
I was going to make a separate section for those functions, but I figured that I'd wait until the wiki is updated with more comprehensive information than I can come up with.
Angry1987 #16
Posted 21 March 2013 - 04:38 AM
hey i have 1 problem
i will starts 2 programs from 1 computer,here the startup:

shell.run("disk/test" and "disk/test2")
test first line

m = peripheral.wrap("monitor_5")
test2 first line

m = peripheral.wrap("monitor_6")
but 1 program only starts on monitor_6
theoriginalbit #17
Posted 21 March 2013 - 04:53 AM
hey i have 1 problem
i will starts 2 programs from 1 computer,here the startup:

shell.run("disk/test" and "disk/test2")
test first line

m = peripheral.wrap("monitor_5")
test2 first line

m = peripheral.wrap("monitor_6")
but 1 program only starts on monitor_6
You cannot use shell.run in that way……. you need to use coroutines to achieve what you want. or as shown in this example the parallel api.


local function run1()
  shell.run("disk/test")
end

local function run2()
  shell.run("disk/test2")
end

parallel.waitForAny( run1, run2 )
PixelToast #18
Posted 21 March 2013 - 05:09 AM
i dont think he wanted them to run simotanously
anyway, your code is broken in so many ways

parallel.waitForAll(
function() shell.run("disk/test") end,
function() shell.run("disk/test2") end
)
theoriginalbit #19
Posted 21 March 2013 - 05:12 AM
Uhhh the only difference between your code and mine is that you used waitForAll as opposed to waitForAny and that I did it in a way that is the least confusing for people to understand… How does that make it broken in so many ways? O.o
Angry1987 #20
Posted 21 March 2013 - 05:15 AM
thx @ theOrginalBIT and PixelToast for the help :)/>
PixelToast #21
Posted 21 March 2013 - 05:17 AM
you used parallels and you used unnecicary variables
theoriginalbit #22
Posted 21 March 2013 - 05:30 AM
There are no variables in that code. And if you mean how I declared the functions. Functionally speaking, and memory management wise, your method is no different to mine. Yours are, what's the term, nope can't think 3:30am is stopping me from remembering… In any case yours are still allocated to memory just like mine, both are deallocated, both do the exact same thing, and in terms of byte code/binary wouldn't be any different or processed any different.
AnDwHaT5 #23
Posted 21 March 2013 - 07:30 AM
Thank you this will be very helpful!! I love the new update so much!!!!! Cant wait for the next one to come out.
Kingdaro #24
Posted 21 March 2013 - 09:07 AM
There are no variables in that code. And if you mean how I declared the functions. Functionally speaking, and memory management wise, your method is no different to mine. Yours are, what's the term, nope can't think 3:30am is stopping me from remembering… In any case yours are still allocated to memory just like mine, both are deallocated, both do the exact same thing, and in terms of byte code/binary wouldn't be any different or processed any different.

Technically anonymous functions are slower than declared/local ones, as I've read in an experiment on methods of optimization in lua.

http://web.archive.org/web/20120720221653/http://trac.caspring.org/wiki/LuaPerformance

Using the wayback machine because the website is down, unfortunately. :(/>
theoriginalbit #25
Posted 21 March 2013 - 03:06 PM
Technically anonymous functions are slower than declared/local ones, as I've read in an experiment on methods of optimization in lua.

http://web.archive.o.../LuaPerformance
Anonymous functions!!!! Thank you! it was killing me all night, couldn't sleep.
immibis #26
Posted 21 March 2013 - 04:57 PM
There are no variables in that code. And if you mean how I declared the functions. Functionally speaking, and memory management wise, your method is no different to mine. Yours are, what's the term, nope can't think 3:30am is stopping me from remembering… In any case yours are still allocated to memory just like mine, both are deallocated, both do the exact same thing, and in terms of byte code/binary wouldn't be any different or processed any different.

Technically anonymous functions are slower than declared/local ones, as I've read in an experiment on methods of optimization in lua.

http://web.archive.o.../LuaPerformance

Using the wayback machine because the website is down, unfortunately. :(/>
Actually, that was a comparison between defining the same function once or one million times, and the conclusion was that it's faster to define it once (duh).
Of course they were actually comparing "create a function one million times" to "create a function once and read a local variable one million times", so it wasn't a stupid test.
R167 #27
Posted 21 March 2013 - 07:30 PM
I was going to make a separate section for those functions, but I figured that I'd wait until the wiki is updated with more comprehensive information than I can come up with.
I really wish that the wiki would be updated with the new features. I also was having troubles getting the "external" peripherals to work with the command blocks. This is great for extra large screens/wrap around displays…
R167 #28
Posted 21 March 2013 - 07:38 PM
i dont think he wanted them to run simotanously
anyway, your code is broken in so many ways

parallel.waitForAll(
function() shell.run("disk/test") end,
function() shell.run("disk/test2") end
)

Not wrong, just personal preference.

hey i have 1 problem
i will starts 2 programs from 1 computer,here the startup:

shell.run("disk/test" and "disk/test2")
test first line

m = peripheral.wrap("monitor_5")
test2 first line

m = peripheral.wrap("monitor_6")
but 1 program only starts on monitor_6
You cannot use shell.run in that way……. you need to use coroutines to achieve what you want. or as shown in this example the parallel api.


local function run1()
  shell.run("disk/test")
end

local function run2()
  shell.run("disk/test2")
end

parallel.waitForAny( run1, run2 )

Did probably just want both to finish. waitForAll

Both ways are completely correct.

PS Both of your usernames are awesome.
amtra5 #29
Posted 25 March 2013 - 01:43 AM
Next is going to be "How to turn off others computers using network cables" XD
PixelToast #30
Posted 25 March 2013 - 03:37 AM
you have to enable the computer on the network in order to do that
slango20 #31
Posted 31 March 2013 - 11:28 AM
meh, when will they be released for the mindcrack pack? and why do the FTB packs take so long to update?
Dlcruz129 #32
Posted 31 March 2013 - 12:17 PM
meh, when will they be released for the mindcrack pack? and why do the FTB packs take so long to update?

The process of mod updating:
Minecraft updates
A few days later, Forge is ready for a release.
A while later, you're ready to update your mod.
Multiply that by all the mods in FTB.
Then you need to update config and whatnot.
Then FTB updates.

Factor in human procrastination and laziness, and it makes perfect sense.
TheArchitect #33
Posted 02 April 2013 - 12:54 PM
Can two computers wrap and talk to the same monitor at once, as the screenshot in the OP might suggest?
theoriginalbit #34
Posted 02 April 2013 - 12:58 PM
Can two computers wrap and talk to the same monitor at once, as the screenshot in the OP might suggest?
Yes they indeed can….
TheArchitect #35
Posted 02 April 2013 - 01:11 PM
Ooh. Must test!


…as soon as I upgrade to 1.5. Forgot I'm waiting for RP to update…
Kingdaro #36
Posted 02 April 2013 - 01:23 PM
Next is going to be "How to turn off others computers using network cables" XD
Well, if you connect a disk drive on a wired network of computers, then put a shutdown startup script in it, it'll be really hard for computers on that network to get past it.
TheArchitect #37
Posted 02 April 2013 - 01:42 PM
*takes note*
MudkipTheEpic #38
Posted 02 April 2013 - 01:49 PM
Next is going to be "How to turn off others computers using network cables" XD
Well, if you connect a disk drive on a wired network of computers, then put a shutdown startup script in it, it'll be really hard for computers on that network to get past it.

Just put a disk drive on top that is not connected to the network.
Kingdaro #39
Posted 02 April 2013 - 01:56 PM
And if the computer is connected through the top?

At that point the computer would have to simply break the connection.

To be fair, I usually have my computers connected through the back, but in an office setting where you don't want workers overwriting your antivirus system, you would probably have a bunch of wires running through the ceiling.
Aptik #40
Posted 04 April 2013 - 04:35 AM
What about a situation without modems?
What will be detected by right computer (your screenshot but without modems) on left side? Computer or monitor?
theoriginalbit #41
Posted 04 April 2013 - 05:44 AM
What about a situation without modems?
What will be detected by right computer (your screenshot but without modems) on left side? Computer or monitor?
The modems are required to detect peripherals… if there is no modem nothing will be detected… unless the peripheral is directly beside the computer…
slango20 #42
Posted 05 April 2013 - 02:32 PM
meh, when will they be released for the mindcrack pack? and why do the FTB packs take so long to update?

The process of mod updating:
Minecraft updates
A few days later, Forge is ready for a release.
A while later, you're ready to update your mod.
Multiply that by all the mods in FTB.
Then you need to update config and whatnot.
Then FTB updates.

Factor in human procrastination and laziness, and it makes perfect sense.
I meant for mod updates and network cables were released before the 1.5 update I belive
Aptik #43
Posted 11 April 2013 - 02:06 AM
Is there a chance to connect several devices to one side?
For example like this:
[attachment=1119:5165569ff92ea13e8b00001b.jpeg]
And use any of them:
  • printer
  • monitor
  • floppy
  • or even anather computer too
Kingdaro #44
Posted 11 April 2013 - 02:08 AM
Yes.

Though the floppy can't be wrapped, it's mounted to your filesystem like any regular disk drive.
PixelToast #45
Posted 11 April 2013 - 07:30 AM
to find it you have to wrap the disk drive and see what getMountPath returns
Noiro #46
Posted 12 April 2013 - 07:56 AM
Quick question, I am trying to find a way to get my turtles to communicate with my server, but the turtles will have all their upgrade slots used so no wireless rednet. Is it possible to have a turtle land on top of a modem connected to a wireless computer and have the turtle talk with the computer and the computer will act as the mediator between turtle and server?
Kingdaro #47
Posted 12 April 2013 - 08:08 AM
Turtles can't communicate with computers over networks without a wireless modem. I'm not sure if it's possible, but connecting a wired modem to a turtle wouldn't have much use if the turtle actually needs to go places.

A round-about way would be to have a turtle go to a disk drive to write a message to a disk, then pick up the disk, put it in another computers' disk drive and the computer would detect it via the disk event and read the message, acting on it and sending it to the other computers.

Even better, just have a disk drive (or a couple) wired to a bunch of computers, and when you want the turtle to send a message via disk, it can just hover over it and write it from there, then just remove and replace the disk and the connected computers would detect the change automatically.
Noiro #48
Posted 12 April 2013 - 09:33 AM
Turtles can't communicate with computers over networks without a wireless modem. I'm not sure if it's possible, but connecting a wired modem to a turtle wouldn't have much use if the turtle actually needs to go places.

A round-about way would be to have a turtle go to a disk drive to write a message to a disk, then pick up the disk, put it in another computers' disk drive and the computer would detect it via the disk event and read the message, acting on it and sending it to the other computers.

Even better, just have a disk drive (or a couple) wired to a bunch of computers, and when you want the turtle to send a message via disk, it can just hover over it and write it from there, then just remove and replace the disk and the connected computers would detect the change automatically.

I was looking to have the turtle come 'home'. That's the only time he'd be sending signals is when he landed in his room. I would just need him to be able to know when he should dispatch and the coordinates he needs to fly off to to excavate, and then return home. :D/>
superaxander #49
Posted 14 April 2013 - 09:30 PM
This helped me a lot. Thanks!
Popeye #50
Posted 15 April 2013 - 01:22 AM
Thank you for this Tutorial!

Very Handy!
wilcomega #51
Posted 15 April 2013 - 07:39 AM
very nice tutorial
Chainmanner #52
Posted 23 April 2013 - 03:04 PM
So wait, does this mean it does not really need to involve the remote API that much? Awesome.
NullSchritt #53
Posted 02 May 2013 - 11:22 PM
This contains a lot of helpful info, I was really wondering how to use peripherals in this way, just curious though, if you have mutlpule of 1 type of peripheral, would it be possible to enumerate them all into an array?
Kingdaro #54
Posted 02 May 2013 - 11:39 PM
This contains a lot of helpful info, I was really wondering how to use peripherals in this way, just curious though, if you have mutlpule of 1 type of peripheral, would it be possible to enumerate them all into an array?
Yes. You can get the names of all connected peripherals by using the .getNamesRemote() function on modems, then wrap/use them all accordingly.


local modem = peripheral.wrap('back') -- or whatever side the modem is on that you have your peripherals connected
local names = modem.getNamesRemote()

for i=1, #names do
  local periph = peripheral.wrap(names[i])
  -- do stuff with the peripheral
end

There's also peripheral.getNames(), but this gets any and all possible usable peripherals, including the modems your monitors are connected to, so to me, it's safer and more controlled when using a modem to get peripheral names.
hasunwoo #55
Posted 29 May 2013 - 08:45 AM
is there any alternative command of os.pullevent() for reciving modem message???
ElvishJerricco #56
Posted 29 May 2013 - 12:00 PM
is there any alternative command of os.pullevent() for reciving modem message???

No. Why would you want to do that? If you don't like filtering out all the non-modem_message events, you can use os.pullEvent("modem_message") to tell pullEvent to only give you modem_messages
Alice #57
Posted 05 June 2013 - 03:33 AM
You. Are. Epic. Thank you so much for this. If I ever create a program that detects any peripherals, which I probably will, I will include your names in the program package's credits. :3
hasunwoo #58
Posted 21 June 2013 - 07:34 PM
reason is i wanna make chatting system but coroutine is hard to use and os.pullevent also freeze computer while computer occur event
XxmehlhausenxX #59
Posted 22 June 2013 - 12:51 AM
love the tutorial :D/>
Larandar #60
Posted 27 June 2013 - 01:27 AM
Good tutorial.

BTW can we use the modem.transmit( freq, chan, message ) but with wireless modem ?
Because rednet change and frequency and channel are gone…

Thanks
Kingdaro #61
Posted 27 June 2013 - 01:30 AM
Good tutorial.

BTW can we use the modem.transmit( freq, chan, message ) but with wireless modem ?
Because rednet change and frequency and channel are gone…

Thanks
Wireless modems work in the same way as wired modems, so yes.
kao #62
Posted 29 June 2013 - 02:34 PM
Hello, I am a dummy, which is why I was drawn to your post about network cables. I can't seem to get the program for the right side computer to work. I get the error:

bios:337: [string "modemcompR"]:7: unexpected symbol


Just to be clear, "modemcompR" is the name I gave to the right-side computer program. It is just the code you posted in your tutorial:


local modem = peripheral.wrap('left')
modem.open(1)

local _, side, freq, rfreq, message = os.pullEvent('modem_message')

print('The message came on the '..side..' modem.')
print('It was on frequency '..freq..' and wants a reply on '..rfreq)
print('The message was: '..message)


Any suggestions for what I might need to do? Would greatly appreciate any feedback.
Kingdaro #63
Posted 29 June 2013 - 06:07 PM
Is that the text of your program, or mine? According to the error, there's something off about line 7 or 8 of your program.
kao #64
Posted 01 July 2013 - 12:33 AM
It is the text from your program. I used the code which you listed for the right side computer, and it gave me the error code "bios:337: [string "modemcompR"]:7: unexpected symbol" when I ran it. I have not written any new code of my own, but I saved your code as "modemcompR"
BlankWolf #65
Posted 01 July 2013 - 01:52 AM
Thanks that is an awesome tutorial. But I have 1 question.
Is it possibile to provent a computer in that network to shutdown or reboot by an other?
Kingdaro #66
Posted 01 July 2013 - 03:51 AM
It is the text from your program. I used the code which you listed for the right side computer, and it gave me the error code "bios:337: [string "modemcompR"]:7: unexpected symbol" when I ran it. I have not written any new code of my own, but I saved your code as "modemcompR"
Make sure you copied the code correctly to your program. There's nothing wrong with what you pasted here.

Thanks that is an awesome tutorial. But I have 1 question.
Is it possibile to provent a computer in that network to shutdown or reboot by an other?
Only by deactivating its connection. If it can be seen as a peripheral, once other computers can wrap it, its theirs to control, and there's nothing you can do about it.
BlankWolf #67
Posted 01 July 2013 - 04:27 AM
Thanks that is an awesome tutorial. But I have 1 question.
Is it possibile to provent a computer in that network to shutdown or reboot by an other?
Only by deactivating its connection. If it can be seen as a peripheral, once other computers can wrap it, its theirs to control, and there's nothing you can do about it.
I can't test this yet, but when you have a wireless modem and wrap it like the modem, can you shutdown an other computer with wireless modem?
Kingdaro #68
Posted 01 July 2013 - 04:39 AM
Wireless? No. You can only access another computer through wired modems, and if the computer's wired modem has an active peripheral connection.
BlankWolf #69
Posted 01 July 2013 - 04:53 AM
Wireless? No. You can only access another computer through wired modems, and if the computer's wired modem has an active peripheral connection.
ok thanks
kao #70
Posted 02 July 2013 - 12:10 PM
Thankyou for creating your tutorial, and for your help with my problem. It turns out I was using commas instead of periods for the .. at the end of line 7. They look very similar to my eyes on the CC screen and I couldn't find it after going over it many times.

Do you know if there is a way to copy text directly from the ComputerCraft screen so that I can paste it into something else for troubleshooting purposes in the future? I had to transcribe my code by hand last time, which is of course why the commas didn't show up in the text I showed you since my brain transformed them into periods.

Thanks again for your help!
Kingdaro #71
Posted 02 July 2013 - 12:25 PM
Thankyou for creating your tutorial, and for your help with my problem. It turns out I was using commas instead of periods for the .. at the end of line 7. They look very similar to my eyes on the CC screen and I couldn't find it after going over it many times.

Do you know if there is a way to copy text directly from the ComputerCraft screen so that I can paste it into something else for troubleshooting purposes in the future? I had to transcribe my code by hand last time, which is of course why the commas didn't show up in the text I showed you since my brain transformed them into periods.

Thanks again for your help!

No problem!

Your CC scripts are stored in your world, in the path .minecraft/saves/(your world folder)/computer/(your computer id), where your computer id is the number you get by typing "id" into your computer console. You can open the script in that folder with an editor such as Notepad, then copy and paste it here.

For future reference, when you do paste code here, it's good practice to use [code][/code] tags,


function soYour()
  if code then
    looks = likeThis()
  end
end
That_Guy #72
Posted 19 July 2013 - 01:24 PM
Hello, I was wondering if


local _, side, freq, rfreq, message = os.pullEvent('modem_message')

was possible to use with a timeout number like rednet.receive()
acesoyster #73
Posted 20 July 2013 - 06:55 AM
Embarrassingly simple, glad someone wrote it down or I'd never have used these.

Thanks a lot (:
Dejected #74
Posted 22 July 2013 - 01:38 AM
Thank You
Kingdaro #75
Posted 22 July 2013 - 01:52 AM
Hello, I was wondering if


local _, side, freq, rfreq, message = os.pullEvent('modem_message')

was possible to use with a timeout number like rednet.receive()

It's possible, but involves a bit of tricky logic. The key is to wait for a timer event in conjunction with a modem message event, and keep pulling events until either are received. This function should do the trick (untested, keep that in mind):


function modemTimeout(time)
  local timeout = os.startTimer(time)
  while true do
    local ev, p1, p2, p3, p4 = os.pullEvent()
    if ev == 'timer' and p1 == timeout then
      return nil
    elseif ev == 'modem_message' then
      return p1, p2, p3, p4
    end
  end
end

Usage to, for example, wait a max 10 seconds for a modem message:

local side, freq, rfreq, message = modemTimeout(10)

And to check if we actually got a message:

if message then
  -- do stuff
end

Of course, you could check for any other variable, but this probably makes the most sense.
jmarko #76
Posted 24 July 2013 - 04:15 PM
Thanks, now I'm understand this too!
deefster1000 #77
Posted 08 August 2013 - 07:29 AM
How would i use modems to send a command to another computer?
i would like to make it so if someones doing something on their computer that would obviously damage the network, i could delete the program(s) from home, or turn off their computer before they save it, as just destroying it and replacing it is a bit too… simple.
AngryTubersLP #78
Posted 27 August 2013 - 08:00 AM
xD
YuvonDovah #79
Posted 27 August 2013 - 03:34 PM
Thanks Really Helpful.
MayContainVennom #80
Posted 30 August 2013 - 12:16 PM
Hey guys,

Is there a way I can edit a program on a floppy disk in a drive through a network? For instance I want to edit disk/test in drive_0 on a computer on the network. How would I go about doing this?
Kingdaro #81
Posted 30 August 2013 - 12:37 PM
Once you turn on the disk's modem, it should be available to you, mounted under the /disk directory.

Peripherals connected to computers act exactly as if they were right next to the computer itself, just that instead of accessing it by side, you access it by name.

In the case of disk drives, sides aren't involved, so names aren't involved. Connecting a disk drive to a computer via peripheral cable automatically mounts it, just like placing it next to the computer.
MayContainVennom #82
Posted 30 August 2013 - 12:40 PM
Once you turn on the disk's modem, it should be available to you, mounted under the /disk directory.

Peripherals connected to computers act exactly as if they were right next to the computer itself, just that instead of accessing it by side, you access it by name.

In the case of disk drives, sides aren't involved, so names aren't involved. Connecting a disk drive to a computer via peripheral cable automatically mounts it, just like placing it next to the computer.

I forgot to add it to my Network >.<
Letme go ahead and faceplam for a few hours.
theoriginalbit #83
Posted 30 August 2013 - 12:57 PM
Is there a way I can edit a program on a floppy disk in a drive through a network? For instance I want to edit disk/test in drive_0 on a computer on the network. How would I go about doing this?
Definitely possible. If you have the disk drive attached to the computer and type "ls" or "dir" it will come up on the computer under "disk#" where # is the order it has been attached…

However if you do not know which one it is you can do the following:

method 1. use the disk API

local path =disk.getMountPath("drive_0")

method 2. use the peripheral API

local path =peripheral.call("drive_0", "getMountPath")

method 3. use a slightly more verbose peripheral API call

local drive = peripheral.wrap("drive_0")
local path = drive.getMountPath()
kreezxil #84
Posted 30 August 2013 - 01:16 PM
Awesome tutorial and even more awesome comments. I'm getting new ideas for the computers in my base now …. *EvilGrin*
YuvonDovah #85
Posted 10 September 2013 - 02:21 PM
Thanks for the tutorial, I really wanted to know how to connect a monitor via wired cable.
kennywd7 #86
Posted 27 September 2013 - 10:26 PM
thx for the help
lixowurm #87
Posted 20 October 2013 - 08:57 AM
Hello there :)/> nice tutorial.
id like to ask you a question: ist there a limit how far the cable works?
thx - lixowurm
Kingdaro #88
Posted 21 October 2013 - 01:23 PM
I'm sure there's a limit, but I'm not exactly sure what it is.
sens #89
Posted 21 October 2013 - 07:06 PM
Thanks for making the tutorial!

I'm sure there's a limit, but I'm not exactly sure what it is.
I remember reading somewhere that the limit is 256 per network.
awsmazinggenius #90
Posted 21 October 2013 - 09:55 PM
Thanks for finally allowing me to have more than 6 peripherals. Is is possible to connect directly to turtles by placing a block, then a modem next to them? Or do I have to transmit a message to a computer over the wire and have the computer on a program to immediately rebroadcast the message wirelessly via Rednet.
theoriginalbit #91
Posted 22 October 2013 - 01:17 AM
A Turtle can interface directly with any peripheral on any side where there is not already a peripheral present (tools included). However a Turtle cannot connect to a wired network. If you're using OpenPeripheral however a Turtle can connect to a wired network by means of a Peripheral Proxy.
MudkipTheEpic #92
Posted 22 October 2013 - 07:07 PM
-snip-
However a Turtle cannot connect to a wired network. If you're using OpenPeripheral however a Turtle can connect to a wired network by means of a Peripheral Proxy.

we have been able to do this the whole time

the turtle can use rednet, just aslong as its attached to a solid block
c_c
theoriginalbit #93
Posted 23 October 2013 - 12:45 AM
Spoiler

we have been able to do this the whole time

the turtle can use rednet, just aslong as its attached to a solid block
c_c
Uhhh sorry to burst your bubble and rain on your parade but look.

Setup

Code
http://pastebin.com/2JrsUhFC

Result

I've never been able to replicate the circumstances in that image.
Edited on 08 November 2013 - 02:23 AM
MudkipTheEpic #94
Posted 23 October 2013 - 09:56 AM
Spoiler

we have been able to do this the whole time

the turtle can use rednet, just aslong as its attached to a solid block
c_c
Uhhh sorry to burst your bubble and rain on your parade but look.

Setup
Spoiler

Code
http://pastebin.com/2JrsUhFC

Result
Spoiler

I've never been able to replicate the circumstances in that image.




mrgreaper #95
Posted 24 November 2013 - 12:43 PM
very helpful, thank you
mrgreaper #96
Posted 24 November 2013 - 01:27 PM
Actually i have a bit of a problem, i want to add lan to some icbm launchers from the icbm mod and some monitors, now, i can hook the monitors up perfectly but i cant place the modem onto the icbm launcher control panal, tried everything i could think off…annoyingly it will connect to the dirt block next to it just fine lol. the controler can be used as a peripheral (placing a computer next to it will allow me to control its coordinates and fire etc all wrapped as a peripheral, so in theory i could have 10 computers all hooked up looking for wireless signals to then fire the missiles/set coords/report what missile is in the bay etc, but for efficency sake and convience i really just want to use 1 computer with these all connected with lan.

i will link calclavia to this as well incase its a bug with icbm

mekenism also seems to have this issue, i suspect it may be in the way they deal with right clicking?


**SOLVED** sort of, theres a mod called openPeripherals, that has a peripheral proxy block, using that i can indeed connect to "ICBMLaunchers" etc …awesome
Edited on 24 November 2013 - 02:42 PM
buzzy613 #97
Posted 10 December 2013 - 01:28 AM
finally! this makes my printer setup alot more convinient. i could never get those wires working before.
ZagKalidor #98
Posted 12 December 2013 - 05:20 AM
Hey Guys,

maybe I'm to stupid for this, but please explain.
Let's say, i have one central computer, and i have 10 others connected to the central one. Every computer of those 10 is wrapped at the central like so: local com1 = peripheral.wrap("computer_1") a.s.o
How do i call, maybe the command rs.setOutput("top", true) on the central, for one of those connected 10 remote computers.

greetz
Edited on 12 December 2013 - 04:21 AM
Kingdaro #99
Posted 12 December 2013 - 09:12 AM
You would need to set up a system where the remote computers would accept commands over a network, because you wouldn't be able to call commands on them like that directly.
awsmazinggenius #100
Posted 12 December 2013 - 06:53 PM
You would need to set up a system where the remote computers would accept commands over a network, because you wouldn't be able to call commands on them like that directly.

Yeah. You should use a message handler.

//Off Topic: I replied to your other tutorial with how to get a Lua syntax highlight.
Kingdaro #101
Posted 12 December 2013 - 09:26 PM
You would need to set up a system where the remote computers would accept commands over a network, because you wouldn't be able to call commands on them like that directly.

Yeah. You should use a message handler.

//Off Topic: I replied to your other tutorial with how to get a Lua syntax highlight.
I saw. I didn't use GitHub's markup to make that page, so that's not possible for my situation.
awsmazinggenius #102
Posted 12 December 2013 - 11:16 PM
Aww. But look what I found:

http://markup.su/highlighter/

It generates HTML code for a syntax highlight, as seen below. It supports Lua. I'm assuming you made it a HTML site, not a Jekyll one. (It also has that awesome "All Hallow's Eve" style from Sublime Text)

<pre style="background:#000;color:#fff"><span style="color:#c83730">print</span>(<span style="color:#6c3">"Hello, World"</span>)
</pre>

(I meant for that to be code, so that Kingdaro could see.)
Edited on 14 December 2013 - 09:03 AM
InThayne #103
Posted 03 November 2014 - 04:54 PM
I find myself moving monitors around a lot. They keep relabeling themselves to the next higher monitor number (monitor_87 eg.) How does one reset the monitor number to zero?
Hayden_Almeida #104
Posted 11 February 2015 - 09:17 PM
Where i can find Modem functions? like Open() etc… ?
Bomb Bloke #105
Posted 11 February 2015 - 09:22 PM
Here.
CCGrimHaxor #106
Posted 14 February 2015 - 10:06 AM
Can the tuorial be updated I keep getting errors
Bomb Bloke #107
Posted 14 February 2015 - 11:08 AM
The code is still correct for CC 1.65. Double check you're entering it correctly, and post details on your problems if you're still having them.