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

String expected?

Started by SkyRamon, 07 February 2014 - 01:47 PM
SkyRamon #1
Posted 07 February 2014 - 02:47 PM
this is my code the error said String Expected (2) ==
something like that but i dont know what it is annyone could help me ??


-- SR.OS Public Server Settings
Local Stefan = 722
Local Ramon = 627
Local restart = "Startup"
-- Waiting For Message --
While true do
id, msg, distance = rednet.receive()
-- When message Receive check if message is From stefan --
if id == "Stefan" then
rednet.send(Ramon, "Stefan: "..msg..".")
shell.run(restart)
elseif id == "Ramon" then
rednet.send(Stefan, "Ramon: "..msg..".")
shell.run(restart)
else
rednet.send(id, "Access denied Ask Owner For Access")
shell.run(restart)
end
end
Dog #2
Posted 07 February 2014 - 03:20 PM
Try this and see if it works (I haven't tested it).

You had several errors in your code. You had variables wrapped in quotes which makes them a string instead of a variable, and you were trying to send too many variables over rednet. You were also capitalizing some commands which I don't think will work. On that note: is your startup file actually named "Startup" with a capital 'S' ? If that is the case, then the below code *should* work, but as I said, I haven't tested it. Also, it looks like you could just remove the os.reboot() commands and this script should 'just run' without requiring reboots.

I hope this helps :)/>


-- SR.OS Public Server Settings
local Stefan = 722
local Ramon = 627
local restart = "Startup"
-- Waiting For Message --
while true do
  id,msg = rednet.receive()
  msg = msg .. "."
-- When message Receive check if message is From stefan --
  if id == Stefan then
	rednet.send(Ramon, msg)
	shell.run(restart)
  elseif id == Ramon then
	rednet.send(Stefan, msg)
	shell.run(restart)
  else
	rednet.send(id, "Access denied Ask Owner For Access")
	shell.run(restart)
  end
end
Edited on 07 February 2014 - 02:21 PM
Bomb Bloke #3
Posted 07 February 2014 - 06:42 PM
You were also capitalizing some commands which I don't think will work.
Indeed, that's what the specific error was getting at - it saw the term "Local", didn't recognise it as a command, and hence assumed it was a variable. If a statement starts with a variable then the next symbol to come should be an "=" sign (followed by what you want to set that variable to).