Enhanced handling of integers by light_switch()
This commit is contained in:
parent
d54ae9354e
commit
c645988ef3
1 changed files with 2 additions and 1 deletions
|
@ -210,7 +210,8 @@ class C4Room:
|
||||||
userinput = self._interactive_light_switch()
|
userinput = self._interactive_light_switch()
|
||||||
|
|
||||||
if len(userinput) != len(self.switches):
|
if len(userinput) != len(self.switches):
|
||||||
if int(userinput) <= 15:
|
if int(userinput) <= 15 and len(bin(int(userinput))) <= len(self.switches)+2:
|
||||||
|
# +2 because bin() returns something like 'b0...'
|
||||||
# Try to interpret as integer
|
# Try to interpret as integer
|
||||||
binary = bin(int(userinput))[2:]
|
binary = bin(int(userinput))[2:]
|
||||||
userinput = str(len(self.switches)*'0')[:-len(binary)] + binary
|
userinput = str(len(self.switches)*'0')[:-len(binary)] + binary
|
||||||
|
|
Loading…
Reference in a new issue