Yeah!
By Lily Kensa
Whether it's useful or not,
List
I've never used the map for a game before, but these look like useful functions to have as a template.
What is the reason you use that 'eval' table? If I needed that to happen I'd probably use ternary operations like:
value=value and 1 or 0 value=value!=0 and true or false |
...though I realize this first one accepts anything other than false or [nil] as true and the second one accepts any non-zero number as true, kind of like 'truthiness' in python. Whereas, in eval[value], they require specifically true/false for the first one, and in the second case any other number besides zero or 1 returns [nil], which an if statement will interpret as false, making it different from mine.
Is this kind of value-testing used so often in the code when using maps that calling the eval[value] saves tokens in the long run?
edit: I see from your other carts that you use this to interpret button presses as values, but it doesn't seem to save tokens. Looking at your shadow test cart, you use:
eval={[true]=1,[false]=0} yv+=(eval[btn(⬆️)]-eval[btn(⬇️)])*-1 xv+=(eval[btn(➡️)]-eval[btn(⬅️)])*1 |
which is 43 tokens, but why not use:
yv+=btn"2" and 1 or btn"3" and -1 or 0 xv+=btn"1" and 1 or btn"0" and -1 or 0 |
which has the same functionality but in 26 tokens.
Is there some other reason you prefer this method?
@UnitVector
Because I didn't know that the way you mentioned would work ;)
I'm not good with algorithm, so it's just the most simple way I could think of.
[Please log in to post a comment]