Jump to content




Rednet:350: string expected (Need help)


  • You cannot reply to this topic
3 replies to this topic

#1 gheotic

  • Members
  • 64 posts
  • LocationDenmark

Posted 03 February 2013 - 02:51 AM

Im trying to make a program thats emits redstone if it get a signal from rednet but im also trying to make a function so if it get the signal (getState) then it send back the state but when i try that i just get this error rednet:350: string expected on the computer why?


local state = nil
local modem = "top"

local side = "left"

function Clear()
term.clear()
term.setCursorPos(1,1)
end

function RCslave()

while true do
local scrap, message = rednet.receive(5)

if message == "closeGate" then
redstone.setOutput(side,true)

Clear()


print("Close Gate")
state = closed

elseif message == "openGate" then
Clear()

redstone.setOutput(side,false)
print("Open Gate")
state = opened

elseif message == "getState" then
rednet.broadcast(state)
print("Broadcast state")


end
end
end

Clear()
rednet.open(modem)
textutils.slowPrint("Waiting for signal")
RCslave()


#2 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 03 February 2013 - 03:02 AM

use tostring on the message

rednet.broadcast(tostring(state))


#3 gheotic

  • Members
  • 64 posts
  • LocationDenmark

Posted 03 February 2013 - 03:31 AM

View PostKaoS, on 03 February 2013 - 03:02 AM, said:

use tostring on the message

rednet.broadcast(tostring(state))


thank you so much :D

#4 tesla1889

  • Members
  • 351 posts
  • LocationSt. Petersburg

Posted 03 February 2013 - 06:01 AM

View Postgheotic, on 03 February 2013 - 02:51 AM, said:

--snip--
state = closed
--snip--
state = opened
--snip--

you have not defined the variables closed or opened, so when you set state to this, you're setting it to nil

either define closed as "closed" and opened as "opened" or change closed to "closed" and opened to "opened"





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users