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

Monitors, wireless modems, and a Big Reactor.

Started by Dmac9244, 30 June 2014 - 10:47 PM
Dmac9244 #1
Posted 01 July 2014 - 12:47 AM
A while ago I made a reactor from the mod Big Reactors, and I decided that it would be cool to have a monitor that shows me what is happening with my reactor. I decided to use a turtle (don't ask me why, I really do not know) for the reactor computer port, and a regular computer for the monitor in my base. I used two wireless modems, and using various online threads and websites, I figured out how to connect the two computers together, connect the monitor to the computer, the reactor to my turtle, and how to do some basic monitor coding. Now, please don't get annoyed at my methods of coding, I amalgamated these programs from multiple online sources, and made them in to a program that somewhat works. My one problem is that when I try to transmit the fuel count from the reactor turtle to the monitor computer, the number is not printed on the screen. The output should be "The current amount of fuel is: (a number)" but the output is currently "The current amount of fuel is: ." I looked through both programs, and the only problem I could see is that I'm trying to transmit a number in stead of a string, but when I tried the tostring() function it still didn't work. There are currently no errors when trying to run the program.
The computer program is here:
www.pastebin.com/yFUdfhrQ

and my turtle program is here:
www.pastebin.com/vrBAc2xy

I have some computer coding knowledge, but unfortunately I don't know too much about lua. So, if my code is horrible, you know why.
AssossaGPB #2
Posted 01 July 2014 - 01:12 AM
Your problem is:
mon.write("Fuel is:", message)
In lua you use ".." to combine text, so your write statement should be:
mon.write("Fuel is:" .. message)
KingofGamesYami #3
Posted 01 July 2014 - 01:12 AM
mon.write does not accept multiple parameters. Try using two "." to connect them ( ".." ). I'm not exactly sure what this method is called, it think concating? Correct me if I'm wrong. Basicly it merges two strings, or a number and a string together.( lua calls tostring on numbers automagically when it needs to )

mon.write( "Fuel is:", message ) --#writes "Fuel is:" 
mon.write( "Fuel is: "..message ) --#writes "Fuel is: <message>"

Ninja'd
Dmac9244 #4
Posted 01 July 2014 - 01:23 AM
Thank you very much. Actually, I was wondering whether or not that was the right way of concating. (At least I also think that that's the right word) I have learned a little bit of three different languages, and each have different methods of doing this, so I was quite confused at that point. Was the rest of the code o.k.? I would suppose so, but if there are any better things I can do to clean up the code, please tell me.
Dmac9244 #5
Posted 01 July 2014 - 01:30 AM
Okay, another problem. In the turtle program, previously I had the line of code,
(how do you do those line of code things?)
 connect.transmit(25565, 25565, tostring(fAmount)) [code]

and now I replaced it with   connect.transmit(25565, 25565, fAmount), and the computer is returning an error, attempt to concatenate string and nil. Should I change the variable message to a string and try that?
Dmac9244 #6
Posted 01 July 2014 - 01:31 AM
Oh, sorry King, I did not quite fully read your post. But, then why is it giving me this error?
Dmac9244 #7
Posted 01 July 2014 - 01:50 AM
AHA! You use the code button on top of the typing area.


connect = peripheral.wrap("right")
connect.open(25565)
reactor = peripheral.wrap("front")
if reactor.getConnected() == true then
  connect.transmit(25565,25565,"connected")

like that!
KingofGamesYami #8
Posted 01 July 2014 - 02:32 PM
One of your "strings" is nil.

sOne = "hello"
sTwo = nil
sCon = sOne..sTwo --#error, because something was nil

Btw, use [code] and [/code] tags
AssossaGPB #9
Posted 01 July 2014 - 07:37 PM
mon.write does not accept multiple parameters. Try using two "." to connect them ( ".." ). I'm not exactly sure what this method is called, it think concating? Correct me if I'm wrong. Basicly it merges two strings, or a number and a string together.( lua calls tostring on numbers automagically when it needs to )

mon.write( "Fuel is:", message ) --#writes "Fuel is:"
mon.write( "Fuel is: "..message ) --#writes "Fuel is: <message>"

Ninja'd
Didn't you read my post? I said the same thing *facepalm*
Edited on 01 July 2014 - 05:37 PM
theoriginalbit #10
Posted 02 July 2014 - 02:58 AM
Didn't you read my post? I said the same thing *facepalm*
if you look at the timestamps, you both posted at the same time, and he did acknowledge you posted the same thing, hence the statement of "Ninja'd"