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

send nuclear reactor via rednet

Started by exporta22, 01 March 2016 - 04:02 PM
exporta22 #1
Posted 01 March 2016 - 05:02 PM
hi all. first of all, sorry for my bad english, im francophone. im trying to do like the industrial info panel in ftb bu without it cuz i dont have access to that mod.

for the moment i got a teste code to make it work but it don't

on the sender computer:

rednet.open("left")
nucleair = peripheral.wrap("back")

local a = nucleair.getHeat()
local b = nucleair.isActive()
local c = nucleair.getEUOutput()
c = c  * 5

local a2 = tostring(a)
local b2 = tostring(B)/>
local c2 = tostring(c)
local donnees = { b2, c2, a2}
local encode = textutils.serialise(donnees)

rednet.broadcast(encode)

print(a2)
print(b2)
print(c2)

and on the receiving computer:

rednet.open("left")
local num = 1

while true do
  event, id, text = os.pullEvent()

  term.setCursorPos(1,1)
  print(num)
  num = num + 1
  if event == "rednet_message" then
    recup = textutils.unserialise(text)
    print("1 = "..recup[1])
    print("2 = "..recup[2])
    print("3 = "..recup[3])
  end
end

i kow for the moment this can be look ugly on a terminal but when it will work ill arrange it on a monitor,

all i want to do is sendig via wireless modem the status of the nuclear reactor, the energy output and the actual temperature. for the moment it don't work!

thanx to all
Bomb Bloke #2
Posted 01 March 2016 - 11:09 PM
it don't work!

What DOES happen?
exporta22 #3
Posted 02 March 2016 - 02:21 PM
ok i do some correction in my program but it s still dont work. on the receiver computer it say :

(the code in the computer is named 1)

1:33: attempt to indez ? (a nil value)

here's the code:


rednet.open("left")
local monitor = peripheral.wrap("top")
term.clear()

monitor.setBackgroundColor(colors.black)
monitor.clear()
monitor.setTextColor(colors.lightBlue)
monitor.setCursorPos(1,1)
monitor.write("Centrale Nucleaire")
monitor.setTextColor(colors.white)
monitor.setCursorPos(1,3)
monitor.write("Reacteur : ")
monitor.setCursorPos(1,4)
monitor.write("Energy:")
monitor.setCursorPos(1,5)
monitor.write("------------------------------------")
monitor.setCursorPos(2,6)
monitor.setTextColor(colors.orange)
monitor.write("Coeur du reacteur")
monitor.setCursorPos(1,8)
monitor.setTextColor(colors.red)
monitor.write("TEMP:")
term.setCursorPos(1,1)

while true do

  event, id, text = os.pullEvent()
  if event == "rednet_message" then
	recup= textutils.unserialise(text)
  end
monitor.setCursorPos(10,3)
monitor.setBackgroundColor(colors.cyan)
monitor.write(tostring(recup[1]))
-- if recup[1] == true then
--   monitor.write("OUI")
-- end
-- if recup[1] == false then
--   monitor.write("NON")
-- end
monitor.setCursorPos(10,4)
monitor.write(recup[2])
monitor.setCursorPos(10,8)
monitor.write(recup[3])

end

and the code of the sender


rednet.open("left")
nucleair = peripheral.wrap("back")

while true do

local a = nucleair.getHeat()
local b = nucleair.isActive()
local c = nucleair.getEUOutput()
c = c  * 5

if b == true then
  b2 = "oui"
elseif b == false then
  b2 = "non"
end

local a2 = tostring(a)
local c2 = tostring(c)
local donnees = { b2, c2, a2}
local encode = textutils.serialise(donnees)

rednet.send(12, encode)
end
Edited on 02 March 2016 - 01:35 PM
Dragon53535 #4
Posted 02 March 2016 - 10:13 PM
If the event you receive is not a rednet message, you don't ever set recur, since recur isn't set that's why you're getting your error.

Change this line:

event, id, text = os.pullEvent()
--#To this
local event, id, text = os.pullEvent("rednet_message")

Also, good tutorial on variable scope and why locals are better.

Here
Edited on 02 March 2016 - 09:14 PM
exporta22 #5
Posted 03 March 2016 - 05:05 AM
i just test it 2 min ago and it totally work!!! thanx a lot for the help!