make states numbers instead of booleans
This commit is contained in:
@ -1,4 +1,8 @@
|
||||
|
||||
local function queueBit(gate, bit)
|
||||
table.insert(gate.queueBits, 1, bit)
|
||||
end
|
||||
|
||||
return function(gate, argv)
|
||||
if argv[1]=="\\:" then argv[1] = ";" end
|
||||
|
||||
@ -7,18 +11,14 @@ return function(gate, argv)
|
||||
|
||||
local code = keycode+(status and 128 or 0)
|
||||
|
||||
local function queueBit(bit)
|
||||
table.insert(gate.queueBits, 1, bit)
|
||||
end
|
||||
|
||||
queueBit(true)
|
||||
queueBit(gate, 1)
|
||||
for bitidx = 1, 8 do
|
||||
local val = bit.band(code, 0x80)~=0
|
||||
queueBit(val)
|
||||
local val = bit.band(code, 0x80)
|
||||
queueBit(gate, val)
|
||||
|
||||
code = bit.lshift(code, 1)
|
||||
end
|
||||
queueBit(false)
|
||||
queueBit(gate, 0)
|
||||
|
||||
Gate.queue(gate, 0)
|
||||
end
|
||||
|
@ -5,6 +5,6 @@ return function(gate)
|
||||
Gate.setportstate(gate, 1, bit)
|
||||
Gate.queue(gate, 1)
|
||||
else
|
||||
Gate.setportstate(gate, 1, false)
|
||||
Gate.setportstate(gate, 1, 0)
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ return function(gate, argv)
|
||||
else
|
||||
gatedata.switchstate = not gatedata.switchstate
|
||||
end
|
||||
Gate.setportstate(gate, 1, gatedata.switchstate)
|
||||
Gate.setportstate(gate, 2, gatedata.switchstate)
|
||||
Gate.setportstate(gate, 1, gatedata.switchstate and 1 or 0)
|
||||
Gate.setportstate(gate, 2, gatedata.switchstate and 1 or 0)
|
||||
Gate.cb(gate, bool_to_int[gatedata.switchstate])
|
||||
end
|
||||
|
Reference in New Issue
Block a user