EABA Powers (Scripting question)
I've started yet another project that I'm not sure if I'll make it through, but for now, I'm wondering if I could get some scripting help.
If I'm reading the rules correctly, each power costs 1 point to add to the character. After that, every point spent raises the power level by 2. So in the portal, I set the incrementer to have an interval of 2, and that's working fine. But I'm having trouble calculating the point cost. The script I'm using is below, and this is what's happening. Say I start with 10 power points. I add a power. Now I'm left with 9 power points. (This is correct so far.) Now I increment the power level. It goes from 1 to 3. (This is also correct.) The problem is, I still have 9 power points. Going from 1 to 3 doesn't subtract a point from my resources. After that, it works fine. Going from 3 to 5 subtracts 1 point, then 5 to 7 and so on. I've tried different ways of coding the script, but I can't get it to work how I want. And yes, I sometimes miss obvious things. Thank you in advance. Code:
<!-- Each power that is added by the user costs 1 point |
So "(uval -1) / 2"
Does that give the correct subtraction, or should it be "(uval + 1) / 2"? |
I would not trust an interval to protect what you're trying to do. Users can still edit the number and type in whatever they want. Instead, I would add a second field that is the power level, and is calculated at 2x field[trtUser].value. Then, you're having the user control the number of points they spent, and displaying the final power level separately. (Or adjust the finalize script on trtUser to display the power level, but that might look odd if the user edits it when it says 4, because they'd see a 2).
I'd read up on the Savage Worlds Wiki - they do a similar thing where the user needs to control dice sizes, and they also need to only show even numbers to the user, but still have a single click change the die size from d4 to d6. |
Also, double check your math
cost = (uval - 1) / 2 So, at a uval of 0, the cost = -1/2 (but then you apply a minimum) At a uval of 2, the cost = 1/2 (and the minimum applies) at 4, the cost = 3/2 At 6, the cost = 5/2 That doesn't match the costs you were describing. |
Quote:
Code:
cost = (uval - 1) / 2 |
All times are GMT -8. The time now is 04:06 AM. |
Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.