summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/rules.js b/rules.js
index 0aac4cc..d293e17 100644
--- a/rules.js
+++ b/rules.js
@@ -2068,7 +2068,22 @@ function vm_if() {
}
function vm_else() {
- vm_goto(vm_endif, vm_if, 1, 1)
+ vm_jump(vm_endif, vm_if, 1, 1)
+}
+
+function vm_jump(op, nop, dir, step) {
+ let balance = 1
+ while (balance > 0) {
+ game.vm.ip += dir
+ if (vm_inst(0) === op)
+ --balance
+ if (vm_inst(0) === nop)
+ ++balance
+ if (game.vm.ip < 0 || game.vm.ip > CODE[game.vm.fp].length)
+ throw "ERROR"
+ }
+ game.vm.ip += step
+ vm_exec()
}
function vm_endif() {