Posted 17 November 2013 - 10:51 AM
I made a program to get items from my chest. There is one chest per item. I have a base computer broadcasting the message "dirt", but it sends this error every time: testr:7:attempt to index ? (a number value) Here is the code:
I have made a simple program to receive a rednet signal and send a redstone signal. I split the string to find the amount of item needed, but it gives me an error: testr:5: attempt to index ? (a number value). Here is the code:
rednet.open("left")
function split(str, pat)
local t = {}
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
return t
end
while true do
m = { }
x,y,z=rednet.receive()
m = split(x, ",")
if m[1] == "dirt" then
a = tonumber(m[2])
b = a * 5
rs.setOutput("right", true)
sleep(B)/>/>/>
rs.setOutput("right", false)
end
end
I have made a simple program to receive a rednet signal and send a redstone signal. I split the string to find the amount of item needed, but it gives me an error: testr:5: attempt to index ? (a number value). Here is the code:
rednet.open("top")
local function split(str, pat)
local parts = {}
for part in str.gmatch( "[^" .. pat .. "]+" ) do
table.insert( parts, part )
end
return part
end
while true do
m = {}
x,y,z = rednet.receive()
m = split(x, ":")
if m[1] == "cobble" then
a = tonumber(m[2])
b = a * 5
rs.setOutput("left", true)
sleep(B)/>/>
rs.setOutput("left", true)
end
end
Edited on 17 November 2013 - 08:01 PM