fix multi-target commands
This commit is contained in:
parent
c5beecba95
commit
fdf4e771ac
1 changed files with 9 additions and 2 deletions
11
pattern.py
11
pattern.py
|
@ -55,6 +55,10 @@ def rand(target, arg, index):
|
||||||
return (random.randrange(0, 255), index)
|
return (random.randrange(0, 255), index)
|
||||||
|
|
||||||
|
|
||||||
|
def jmp(target, arg, index):
|
||||||
|
return (target, target)
|
||||||
|
|
||||||
|
|
||||||
def jnz(target, arg, index):
|
def jnz(target, arg, index):
|
||||||
if target != 0:
|
if target != 0:
|
||||||
return (target, arg)
|
return (target, arg)
|
||||||
|
@ -80,6 +84,7 @@ def _apply(index, target, arg, func):
|
||||||
|
|
||||||
|
|
||||||
def apply(index, targets, args, func):
|
def apply(index, targets, args, func):
|
||||||
|
j = index
|
||||||
for target in range(len(targets)):
|
for target in range(len(targets)):
|
||||||
if this.values[targets[target]['channel']] != None:
|
if this.values[targets[target]['channel']] != None:
|
||||||
print("target: {}".format(targets[target]['channel']))
|
print("target: {}".format(targets[target]['channel']))
|
||||||
|
@ -88,13 +93,14 @@ def apply(index, targets, args, func):
|
||||||
index, this.values[targets[target]['channel']], args[target], func)
|
index, this.values[targets[target]['channel']], args[target], func)
|
||||||
if val != this.values[targets[target]['channel']]:
|
if val != this.values[targets[target]['channel']]:
|
||||||
this.values[targets[target]['channel']] = val
|
this.values[targets[target]['channel']] = val
|
||||||
return jump
|
j = jump
|
||||||
else:
|
else:
|
||||||
val, jump = _apply(
|
val, jump = _apply(
|
||||||
index, this.values[targets[target]['channel']], 0, func)
|
index, this.values[targets[target]['channel']], 0, func)
|
||||||
if val != this.values[targets[target]['channel']]:
|
if val != this.values[targets[target]['channel']]:
|
||||||
this.values[targets[target]['channel']] = val
|
this.values[targets[target]['channel']] = val
|
||||||
return jump
|
j = jump
|
||||||
|
return j
|
||||||
|
|
||||||
|
|
||||||
this.instructions = {
|
this.instructions = {
|
||||||
|
@ -105,6 +111,7 @@ this.instructions = {
|
||||||
"DIVIDE": div,
|
"DIVIDE": div,
|
||||||
"MODULO": mod,
|
"MODULO": mod,
|
||||||
"RANDOM": rand,
|
"RANDOM": rand,
|
||||||
|
"JMP": jmp,
|
||||||
"JNZ": jnz,
|
"JNZ": jnz,
|
||||||
"JEZ": jez
|
"JEZ": jez
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue