Posted 17 November 2012 - 11:43 AM
Hi. I'm new to the forums, and relatively new to Lua. I mainly have experience in the very basic programming language present on the TI-83 graphing calculators.
So, jumping right in, my question is about the different ways that you can compare Tables and Variables, if any, and whether or not you can put tables into Function Parameters. I've tried different things without success and I want to know what I'm missing here, please excuse my noobishness.
My first and most important question is whether or not this is possible:
Would the function call take each table as an answer to each parameter or does it take all of the first tables values as the parameters? The other part is where, if that would even work above somehow, it would be compared in the actual api:
What this program is basically supposed to do is I want to have a computer send out orders, and other control computers turn on or off whatever they're hooked to based on the orders. But, I want them to be able to respond to multiple commands to turn on or off. It's non functioning right now as it is, and I'm frustrated, it works if I don't use tables, but I want to somehow make it where it responds to multiple commands. Can someone please help me? :/
So, jumping right in, my question is about the different ways that you can compare Tables and Variables, if any, and whether or not you can put tables into Function Parameters. I've tried different things without success and I want to know what I'm missing here, please excuse my noobishness.
My first and most important question is whether or not this is possible:
oncomd = {"open primary jail gate","open all gates","open all"}
offcomd = {"close primary jail gate","close all gates","close all"}
thor.control(oncomd,offcomd)
Would the function call take each table as an answer to each parameter or does it take all of the first tables values as the parameters? The other part is where, if that would even work above somehow, it would be compared in the actual api:
function control(oncomd,offcomd,dirc)
if dirc == nil then
dirc = "top"
end
thor.wireless()
while true do
_,order,_ = rednet.receive()
if order == oncomd then
redstone.setOutput(dirc,true)
elseif order == offcomd then
redstone.setOutput(dirc,false)
end
end
end
What this program is basically supposed to do is I want to have a computer send out orders, and other control computers turn on or off whatever they're hooked to based on the orders. But, I want them to be able to respond to multiple commands to turn on or off. It's non functioning right now as it is, and I'm frustrated, it works if I don't use tables, but I want to somehow make it where it responds to multiple commands. Can someone please help me? :/