PDA

View Full Version : Instant updating of <script>-defined variables?



Zakarius
November 29th, 2009, 05:21
Below is the codeblock I'm working with... as in ShadowRun, wound penalties are based on every three points of stun and physical damage. I wish I could get it to update whenever the stun or physical fields are altered, but the onInit() I'm using only changes the wound value when the character sheet is first opened. (And having to close one's character sheet and reopen simply to reflect the change is pretty silly.)


<standardsm name="woundmodifier" source="stat.wound.modifier">
<anchored>
<to>pdam</to>
<position>right</position>
<offset>60,0</offset>
</anchored>
<readonly />
<script>
function onInit()
local temp = 0;
temp = 0 - math.ceil((window.sdamact.getValue()-2)/3) - math.ceil((window.pdamact.getValue()-2)/3);
window.woundmodifier.setValue(temp);
end
</script>
</standardsm>

Is there something else I can use instead of onInit()?

Zak

Oberoten
November 29th, 2009, 10:41
The function you need is : OnValueChanged()

Put it in the instance that should changethe others.

- Obe

Zakarius
December 2nd, 2009, 03:04
I kept the onInit() in the above code instance since the field is <readonly />.
However, I added the onValueChanged() script within the definitions of the two dependant variables and it worked like a charm. Thanks a lot!

Zak

Oberoten
December 2nd, 2009, 10:41
I know this was one of the big keys to get things working for me. :)

Glad to be of assistance.

- Obe