Computercraft 捆绑电缆程序无响应
Computercraft bundled cable program not responding
经过多次修改,我的Lua程序仍然拒绝执行任何操作。
--Let's Go!
--Program Infos
--Mappings
--Pink: Gate 1
--Red: East Tower 2
--Orange: West Tower 3
--Lime: Armoury 4
--Blue: Master Bedroom 5
--Grey: Guest Bedroom 6
--Cyan: Power Generation 7
--arbitrary variables
-- c is the variable for adding and subtracting. keeps track of what is CURRENTLY ACTIVE.
--Beginning values
--Start out with listening for arguments
local args = {...}
arg1=args[1]
arg2=args[2]
--Where are our outputs?
local towere = colors.red
local towerw = colors.orange
local gate = colors.pink
local armoury = colors.lime
local mstr = colors.blue
local guest = colors.grey
local power = colors.cyan
--bundled outputs
local output = "right"
-- ADD AND SUBTRACT MAKE LIFE EASIER CODE
--Courtesy of @Kingdaro on Computercraft Fourm (adapted for practical use in project)
--Original Link: http://www.computercraft.info/forums2/index.php?/topic/7641-redpower-bundled-cable/
--How to close a door
function close(door)
local input = rs.getBundledOutput("right")
rs.setBundledOutput("right", colors.combine(input, door))
end
function open(door)
local input = rs.getBundledOutput("right")
rs.setBundledOutput("right", colors.subtract(input, door))
end
--Make a good base for closing/opening things
--Basically, Functions Galore.
--GATE CONTROLS
function gateclose()
rs.setOutput(top, true)
wait(1)
rs.setOutput(top, false)
close(colors.pink)
end
function gateopen()
open(colors.pink)
end
--Beef of the program
--Start out with all doors open
if args[1] == gate and args[2] == open then --if the command is gate open
gateopen()
elseif args[1] == gate and args[2] == close then --if the command is gate close
gateclose()
end
我试了又试,还是没有反应。我有正确的设置(物理上,如果你可以这样称呼它)(捆绑电缆在右边)并且没有错误消息,但是当 运行 带有 'gate close' 参数时,电线没有响应.
有什么建议吗?谢谢!
您很可能想比较字符串:
if args[1] == "gate" and args[2] == "open" then --if the command is gate open
gateopen()
elseif args[1] == "gate" and args[2] == "close" then --if the command is gate close
gateclose()
end
经过多次修改,我的Lua程序仍然拒绝执行任何操作。
--Let's Go!
--Program Infos
--Mappings
--Pink: Gate 1
--Red: East Tower 2
--Orange: West Tower 3
--Lime: Armoury 4
--Blue: Master Bedroom 5
--Grey: Guest Bedroom 6
--Cyan: Power Generation 7
--arbitrary variables
-- c is the variable for adding and subtracting. keeps track of what is CURRENTLY ACTIVE.
--Beginning values
--Start out with listening for arguments
local args = {...}
arg1=args[1]
arg2=args[2]
--Where are our outputs?
local towere = colors.red
local towerw = colors.orange
local gate = colors.pink
local armoury = colors.lime
local mstr = colors.blue
local guest = colors.grey
local power = colors.cyan
--bundled outputs
local output = "right"
-- ADD AND SUBTRACT MAKE LIFE EASIER CODE
--Courtesy of @Kingdaro on Computercraft Fourm (adapted for practical use in project)
--Original Link: http://www.computercraft.info/forums2/index.php?/topic/7641-redpower-bundled-cable/
--How to close a door
function close(door)
local input = rs.getBundledOutput("right")
rs.setBundledOutput("right", colors.combine(input, door))
end
function open(door)
local input = rs.getBundledOutput("right")
rs.setBundledOutput("right", colors.subtract(input, door))
end
--Make a good base for closing/opening things
--Basically, Functions Galore.
--GATE CONTROLS
function gateclose()
rs.setOutput(top, true)
wait(1)
rs.setOutput(top, false)
close(colors.pink)
end
function gateopen()
open(colors.pink)
end
--Beef of the program
--Start out with all doors open
if args[1] == gate and args[2] == open then --if the command is gate open
gateopen()
elseif args[1] == gate and args[2] == close then --if the command is gate close
gateclose()
end
我试了又试,还是没有反应。我有正确的设置(物理上,如果你可以这样称呼它)(捆绑电缆在右边)并且没有错误消息,但是当 运行 带有 'gate close' 参数时,电线没有响应.
有什么建议吗?谢谢!
您很可能想比较字符串:
if args[1] == "gate" and args[2] == "open" then --if the command is gate open
gateopen()
elseif args[1] == "gate" and args[2] == "close" then --if the command is gate close
gateclose()
end