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

Rednet:11: string expected

Started by keyboardhack, 04 October 2013 - 04:04 PM
keyboardhack #1
Posted 04 October 2013 - 06:04 PM
hey i got a problem with an update program i am making. it's supposed to run startup after 5 sec if no rednet signal has been received, but instead i just get an error after 5 sec and it doesn't start the startupprogram. the error is
Rednet:11: string expected
hope i can get some help with it :)/>

rednet.open("top")
if fs.exists("startup") == false then
shell.run("pastebin get 9rHSjf3j startup")
shell.run("pastebin get URxGE5tL information")
end

os.startTimer(5)
while true do
local program = "builder"
e,s,msg,dis = os.pullEvent()
if e == "timer" then
  shell.run("startup")
elseif e == "rednet_message" and string.sub(msg,1,string.find(msg," ")-1) == "update" then
  if string.sub(msg,string.find(msg," ")+1,string.len(msg)) == program then
   local pystebin = string.sub(msg,string.len("update  "..program)+1,string.len(msg))
   fs.delete("startup")
   shell.run("pastebin","get",pystebin,"startup")
  end
end
end

the error is Rednet:11: string expected

thanks in advance :)/>

startup program as requested by Lyqyd –not sure why it screws up the first lines in the spoiler
Spoiler

information1 = {}
function information()
ful = fs.open("information","r")
information1 = textutils.unserialize(ful.readAll())
ful.close()
item = information1[item]
rs_side = information1[rs_side]
num_items = information1[num_items]
rednet.open(information1[rednet_side])
m = peripheral.wrap(information[peripheral_wrap])
direction = information1[direction]
time1 = information1[time1]
produkt = information1[produkt]
end
information()
while true do
local lol = true
local cool = 1
local myth = math.ceil((number-cool)/produkt)
	e,s,msg,dis = os.pullEvent("rednet_message")
local ytem = string.sub(msg,1,string.find(msg," ")-1)
	if ytem == item then
  for k,v in pairs(m.list(direction)) do
   if v ~= nil then
	cool = cool + v
   end
  end
  local number = tonumber(string.sub(msg,string.find(msg," "),string.len(msg)))
  for w = 1,myth do
   for i = 1,num_items do
	rs.setOutput(rs_side,true)
	os.startTimer(time1/2)
	os.pullEvent("timer")
	rs.setOutput(rs_side,false)
	os.startTimer(time1/2)
	os.pullEvent("timer")
   end
  end
  while lol == true do
   for k,v in pairs(m.list(direction)) do
	if number <= v then
	 rednet.send(s,item.." ".."done")
	 lol = false
	end
  os.startTimer(2)
  os.pullEvent("timer")
   end
  end
end
end
Lyqyd #2
Posted 05 October 2013 - 03:40 PM
Split into new topic.

Please post the code for the program it runs as startup.
keyboardhack #3
Posted 06 October 2013 - 07:14 PM
people don't understand the problem, people don't know how to solve the problem, or should i be more patient? :)/>
Lyqyd #4
Posted 06 October 2013 - 07:21 PM
I didn't notice the edit.

You're indexing your table incorrectly. Instead of this:


information1[rednet_side]

use this:


information1.rednet_side

or this:


information1["rednet_side"]
keyboardhack #5
Posted 07 October 2013 - 03:15 AM
thanks :D/> didn't realize the problem was in the startup program. thought it was in the first program i linked :)/>