i have an error : "Java exception trown: java.lang.ClassCastException"
pannel = peripheral.wrap("bottom")
rednet.close("back")
rednet.open("back")
function receiver()
channel,msg,protocol = rednet.receive()
if channel==35 then
time = msg
elseif channel==54 and msg=="BGon" then
state = msg
elseif channel==54 and msg=="BGoff" then
state = msg
elseif channel==54 and protocol=="RF" then
energy = msg
end
end
function check()
if state=="BGon" then
pannel.setText("clock",time,0x00FF00)
pannel.setText("BGstate","BigReactor is powered on",0x00FF00)
pannel.setText("BGenergy",energy,0x00FF00)
elseif state=="BGoff" then
pannel.setText("clock",time,0x00FF00)
pannel.setText("BGstate","BigReactor is powered off",0xFF0000)
pannel.setText("BGenergy",energy,0x00FF00)
end
end
while true do
receiver()
check()
term.setCursorPos(1,1)
term.clearLine()
term.write("clock:"..time.." energy:"..energy.." state:"..state)
end
this error come from this part of code:
function check()
if state=="BGon" then
pannel.setText("clock",time,0x00FF00)
pannel.setText("BGstate","BigReactor is powered on",0x00FF00)
pannel.setText("BGenergy",energy,0x00FF00)
elseif state=="BGoff" then
pannel.setText("clock",time,0x00FF00)
pannel.setText("BGstate","BigReactor is powered off",0xFF0000)
pannel.setText("BGenergy",energy,0x00FF00)
end
but if i change the "elseif" part of this fonction and use text instead of variables, i do not have errors anymore
ex:
function check()
if state=="BGon" then
pannel.setText("clock",time,0x00FF00)
pannel.setText("BGstate","BigReactor is powered on",0x00FF00)
pannel.setText("BGenergy",energy,0x00FF00)
elseif state=="BGoff" then
pannel.setText("clock",[color=#ff0000]"text here"[/color],0x00FF00)
pannel.setText("BGstate","BigReactor is powered off",0xFF0000)
pannel.setText("BGenergy",[color=#ff0000]"text here"[/color],0x00FF00)
end
i know my script could be better writed but i am a newbie.
i just want to know why this error appear and what cause it to appear.
thank's a lot
(sorry for my poor english)