Posted 07 February 2014 - 11:34 AM
All - I'm trying to use variables for rs.testBundledInput and rs.setBundledOutput but get an error with the color name variable. I believe the error is in how I'm passing the color name variable, I've tested by explicitly stating a side and not the color (e.g. rs.testBundledInput("right",colors.checkColor) and will get the error. Then by explicitly stating the color and not the side (e.g. rs.testBundledInput(checkSide, colors.white) ) What I'm looking for help with is how to pass the actual color name to this code and not get an error. Please note I've identified the two lines of code where the error occurs with a comment for ease in finding it for this discussion. Note: I've tried searching for posts on "color variable testBundledInput" ,but that word is blocked in search so I'm not exactly sure what to use for a search term if a post like this already exists Thanks in advance for any help you could provide!
Error Message: mobSpawnerV2:18: Expected string, number
Thanks,
Recanem
Error Message: mobSpawnerV2:18: Expected string, number
local monitor = peripheral.wrap("top")
local signalResult
local spawnTimer = 30
local killTimer = 100
local inputTable = {}
--PopulateTable
inputTable[1] = {"Mob Essence", "Slimes", "right", white, "back", white }
inputTable[2] = {"Raw Beef, Leather", "Cows", "right", magenta, "back", magenta }
inputTable[3] = {"Glass Bottles, Glowstone Dust. Gunpowder, Redstone ,Spider Eyes, Sticks, Sugar", "Witches", "right", orange, "back", orange }
--Check for requested items, signals are sent via rednet cable on specific colors and computer sides (16 color inputs per computer side)
-- Once
function signalTest (tableKey)
local checkSide = inputTable[tableKey][3]
local checkColor = inputTable[tableKey][4]
signalResult = rs.testBundledInput(checkSide,colors.checkColor) -- ERROR HERE trying to pass varialble containing color name
end
--Send Signal to Spawn requested Mob and kill it for item drops
function signalSend (side, color)
local sendSide = inputTable[tableKey][5]
local sendColor = inputTable[tableKey][6]
rs.setBundledOutput(sendSide, colors.sendColor) -- ERROR HERE trying to pass varialble containing color name
sleep(spawnTimer)
rs.setBundledInput(side, 0)
sleep(killTimer)
end
--write out to monitor what the system is working on (fancy stuff later)
function displayStatus (mobName, itemName)
local mobName = inputTable[tableKey][2]
local itemName = inputTable[tableKey][1]
monitor.clear()
monitor.setCursorPos(1,1)
monitor.write("Need Items: "..itemName)
monitor.setCursorPos(2,1)
monitor.write("Spawing Mobs: "..mobName)
monitor.setCursorPos(3,1)
monitor.write("Spawn Timer: "..spawnTimer)
monitor.setCursorPos(4,1)
monitor.write("Kill Timer: "..killTimer)
end
while true do
signalResult = false
for i=1 , #inputTable do
signalTest(i)
if signalResult == true then
displayStatus(i)
signalSend (i)
break -- breaks the for loop and starts over at 1
end
sleep(1)
end
end
Thanks,
Recanem