Closed Ardnived closed 10 years ago
Well, we're definitely not adding if/else logic (or, likewise, tertiary operators, which in JS are just shortcuts for the same thing) to the dice roller, as has been said before. And Javascript doesn't have a Math.fix() function. So I'm not really sure what else we can do here.
To be clear, is this the type of value that changes on a per-roll/per-turn basis? Or is this just a convenience calculation that you would only need to change each time that your character levels up/gains a skill point (i.e. only once every session or two)? I'm not familiar with GURPS so I don't know.
Typically you'd be changing a couple of these values once every session. Usually a player will gain something like 3 - 5 character points a session that could be spent on skills, attributes, or advantages. But there are a lot of calculations so it can be prone to mistakes, and some tedium. Especially for new players.
Is Roll20 not written in such a way that you (the developer) can supply your own functions? Implementation for a fix function should be really simple.
function fix(x) {
if (x >= 0) {
return Math.floor(x);
} else {
return Math.ceil(x)
}
}
I'm not sure what your reasons for not wanting to implement if/else logic (Maybe you think thats too much power or complexity to give to users), but if it's due to complexity of implementation (I can certainly see why, with parsing a tertiary operator and all those condition operators). I'd suggest a simple addition that could solve my problems by offering a limited subset of if/else functionality.
Add a function to auto-calc that takes 3 arguments
cond(pivot, then, else)
If pivot >= 0
return the result of then
, otherwise return the result of else
My problems would be solved thusly:
p = @{points}
Attributes: 10 + cond(p, floor(p / 20), ceil(p / 20))
Skills: cond(p-1, 1, 0) + cond(p-2, 1, 0) + floor(p / 4)
Another option, though perhaps an undesirable one would be to special case your division operator so that "0 / 0" = 0
. Perhaps if the numerator is 0, it doesn't even look at the denominator, it just returns 0. (All my division by 0 problems are actually 0/0).
One other option I can think of is to allow html tags in character sheets to specify a default if the auto-calc results in NaN.
<input type="number" disabled value="10 + floor(abs(x)) * x/abs(x)" data-default="10" />
Similar to the 0/0 special case, this only solves attributes, not skills, but that's something at least.
In my opinion Character Sheets should be allowed to contain the ability to have extensive programming capabilities. I could care less about not having logic added to the dice roller, all we would need is the ability to calculate that an attribute equals a certain number and use that number for rolling purposes without having the roller do any math to figure out what number to use. In the mean time you could allow the use of Javascript Bitwise Operators and use a Double Not (~~) and it would round towards 0.
I'm closing this out because this is not a bug, it is a feature request. There's a discussion on this here on the forums: https://app.roll20.net/forum/post/882737/gurps-known-issues#post-883752
After testing with the new abs() function, it's become apparent that it won't work for the GURPS sheet (as described in issue #83), since it results in a division by 0 if the user wants to keep their attribute at default (and naturally that will cascade and invalidate the vast majority of other calculations on the character sheet).
It would seem this is only solved by either implementing a
fix
function, or adding tertiary operators, in which case I can dox != 0 ? abs(x) * x/abs(x) : 0
orx >= 0 ? floor(x) : ceil(x)
I also have another problem, which would require tertiary operators to solve. Unless someone can suggest an alternate way to compute it, which would be amazing.
GURPS has a slightly complicated system for calculating skill levels, the first few levels cost fewer points than the later levels.
The only way I can think to accomplish this right now is with a tertiary operator.
(x >= 1 ? 1 : 0) + (x >= 2 ? 1 : 0) + floor(x / 4)
of course this would also work in a much more simple fashion if those booleans could be evaluated as a 1 or 0.(x >= 1) + (x >= 2) + floor(x / 4)
I was trying to think of a way to do it with modulo, but to no avail.
If that's too much too ask, then the GURPS character sheet will have to be very minimal in it's use of auto-calc. Or supported by an API script.