Hello all.
Can any of you clever folk make this code shorter?
It's bugging the life out of me but I don't know how to make it shorter though it looks like it can be.
Cheers.
--p.c= n / 2 + 0.5 ? if (p.t/p.die<7/#p.c_table) p.c=4 if (p.t/p.die<5/#p.c_table) p.c=3 if (p.t/p.die<3/#p.c_table) p.c=2 if (p.t/p.die<1/#p.c_table) p.c=1 |
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/54967/2_wave_0.gif)
Not 100% sure but try this:
p.c = ceil(((p.t * #p.c_table) / p.die + 1) / 2) |
You should be able to get rid of the inner-most parens so this should work too using one less token (I think)
p.c = ceil((p.t * #p.c_table / p.die + 1) / 2) |
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi21.png)
Wow, jasondelaat.
That was quick.
It looks like it works too.
Thanks so much for that :-)
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/54967/2_wave_0.gif)
@Peej
No worries, happy to help.
I don't know exactly what this code is doing or why it's doing it but you should be aware though that my version is potentially brittle if any of the numbers in your code need to change. Like, in the first line of your original code if you want that to be p.c = 5 for some reason my version won't work anymore.
[Please log in to post a comment]