-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
select_counter not working as expected #36
Comments
According to https://github.com/MikeTaylor/scottkit/blob/master/docs/notes/Definition-scottfree-1.14.txt the definition of opcode 81 should be:
And the code in ScottFree v1.14 bears this out:
So what we should be doing is copying the "current counter" value into the nominated numbered counter, and copying the value of that nominated numbered counter into the "current counter". The "current counter" should not itself be one of the numbered counters, but a separate special value the only one that can be directly set, augmented and tested. |
... and that does seem to be exactly what we do:
|
OK, so I think the current behaviour is correct — though more documentation would help. On the initialisation (
The Then before each turn this code runs:
So on the first time through it swaps the current counter (value 5) with counter 1 (value 0), prints the value (0), decrements it, and prints the new value (-1). And on the second time through, it swaps the current counter (value -1) with counter 1 (value 5), prints that value, decrements it, and prints the new value (4). And on the third time through, it swaps the current counter (value 4) with counter 1 (value -1), prints that value, decrements it, and prints the new value (-2). etc. |
In conclusion, I think the simplest and safest way to use the counters is either:
|
Here's an example of the second approach: a one-room game containing a matchbook and a packet of mints. The former contains five matches, the latter contains three mints. You can examine either to see how many items it contains; and you can
Here's a sample transcript:
|
Craig Macfarlane reports:
--
Hi Mike,
Thanks for replying to my comment on ScottKit. Sorry that I’ve taken so long to reply but I was unaware that you had replied – I didn’t see any email alerting me to a response, so I must have some settings wrong or I need to check my spam filter (although your posts are getting through, e.g. etch-a-sketch, which is what prompted me to go back and check the comments section on ScottKit today).
I’ve attached a short script to test counter1. It performs as follows: At start of game displays “-1-1” despite setting counter1 to 5. Entering a direction (e.g. “w”) causes counter1 to count down but “-1 -1” is interspersed with actual counter1 values:
5 4
-1 -1
4 3
-1 -1
3 2
-1 -1
2 1
-1 -1
1 0
-1 -1
0 -1
-1 -1 ad infinitum.
If I comment out both ‘select_counter 1’ commands (i.e. use default counter) then it works normally. At start of game displays “54”. Entering a direction (e.g. “w”) causes counter to count down:
5 4
4 3
3 2
2 1
1 0
0 -1
-1 -1 ad infinitum.
--
And here is the source file:
The text was updated successfully, but these errors were encountered: