Tatzelbelm
March 29th, 2020, 14:11
I'm trying to do a small modification to the inventory list of character sheets in a moreCore extension.
I'm trying to replace the numeric input field for the item weigth by a "button_stringcycler", which shows the strings "normal", "light", "tiny" or "heavy". The corresponding numeric values are 1, 0.5, 0 and 2.
I've set the button_stringcycler up like this:
<template name="button_cycler_weight">
<button_stringcycler>
<anchored height="20" />
<parameters>
<defaultlabel mergerule="replace">Normal</defaultlabel>
<default>1</default>
<labels>Light|Tiny|Heavy</labels>
<values>0.5|0|2</values>
</parameters>
</button_stringcycler>
</template>
This works fine for "light", "tiny" or "heavy", but not for the default value, which still seem to be strings.
The manager_char.lua of the CoreRPG throws the error Script Error: [string "campaign/scripts/manager_char.lua"]:22: attempt to perform arithmetic on local 'nWeight' (a string value).
I tried editing manager_char.lua of the CoreRPG to convert nWeight to a number by changing
nEncTotal = nEncTotal + (nCount * nWeight); to
nEncTotal = nEncTotal + (nCount * tonumber(nWeight));
As beforem this works fine for "light", "tiny" or "heavy", but not for the default value, then I get the error Script Error: [string "campaign/scripts/manager_char.lua"]:22: attempt to perform arithmetic on a nil value
Two questions:
1) How can I get rid of the error for the default value of the button_stringcycler?
2) Can I get the extension to use a local modified version of manager_char.lua instead of the CoreRPG manager_char.lua, but keep using all other inventory/weight management files of the CoreRPG?
I'm trying to replace the numeric input field for the item weigth by a "button_stringcycler", which shows the strings "normal", "light", "tiny" or "heavy". The corresponding numeric values are 1, 0.5, 0 and 2.
I've set the button_stringcycler up like this:
<template name="button_cycler_weight">
<button_stringcycler>
<anchored height="20" />
<parameters>
<defaultlabel mergerule="replace">Normal</defaultlabel>
<default>1</default>
<labels>Light|Tiny|Heavy</labels>
<values>0.5|0|2</values>
</parameters>
</button_stringcycler>
</template>
This works fine for "light", "tiny" or "heavy", but not for the default value, which still seem to be strings.
The manager_char.lua of the CoreRPG throws the error Script Error: [string "campaign/scripts/manager_char.lua"]:22: attempt to perform arithmetic on local 'nWeight' (a string value).
I tried editing manager_char.lua of the CoreRPG to convert nWeight to a number by changing
nEncTotal = nEncTotal + (nCount * nWeight); to
nEncTotal = nEncTotal + (nCount * tonumber(nWeight));
As beforem this works fine for "light", "tiny" or "heavy", but not for the default value, then I get the error Script Error: [string "campaign/scripts/manager_char.lua"]:22: attempt to perform arithmetic on a nil value
Two questions:
1) How can I get rid of the error for the default value of the button_stringcycler?
2) Can I get the extension to use a local modified version of manager_char.lua instead of the CoreRPG manager_char.lua, but keep using all other inventory/weight management files of the CoreRPG?