PDA

View Full Version : Problem with "button_stringcycler" when trying for a small (More)Core-Modification



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?

damned
March 29th, 2020, 15:08
i think in the Fragged Empire I have some cyclers on the More tab of the Char sheet that have scripts attached to them. Armour I think. Have a look at the setup behind those.

Tatzelbelm
March 29th, 2020, 19:04
I've got the string_cycler running now. I check if the value read from the string cycler is equal to "", then I set it to my preferred value for the defaul case.
My problem was that the default case of the string cycler always returns the string "" instead of the default value. I then converted "" to a number and got nil.

I've also solved problem #2, just added it to the extension.xml

Thanks for the tip regarding the Fragged Empire cycler.

damned
March 30th, 2020, 09:30
I've got the string_cycler running now. I check if the value read from the string cycler is equal to "", then I set it to my preferred value for the defaul case.
My problem was that the default case of the string cycler always returns the string "" instead of the default value. I then converted "" to a number and got nil.

I've also solved problem #2, just added it to the extension.xml

Thanks for the tip regarding the Fragged Empire cycler.

Very good. What are you making?
Sneek peek?

Tatzelbelm
March 30th, 2020, 16:34
It's just a small modification of Valyar's Forbidden Lands Extension.