Log in

View Full Version : Hidden field



Larhalt
December 28th, 2015, 14:35
Hello,
I'm trying to make an hidden field that will show when an icon is clicked.
I took an existing code from spell list that work good; when you click on the icon in the circle, the hidden fields appears
12357

And this is the code I found that (maybe) do that.

<button_toggle name="activatecombat">
<anchored>
<to>shortcut</to>
<position>left</position>
<offset>2,0</offset>
<size>
<width>20</width>
</size>
</anchored>
<icon>indicator_expanddown</icon>
<script>
function onValueChanged()
window.onCombatSectionToggle(getValue());
end
</script>
</button_toggle>


function onCombatSectionToggle(show)
speedlabel.setVisible(show);
speed.setVisible(show);
damagelabel.setVisible(show);
damageframe.setVisible(show);
damagedice.setVisible(show);
damagebonus.setVisible(show);
end

But when I try to use in the file that I need (record_char_combat) with the code

12358


<button_toggle name="weapondetails">
<anchored>
<to>damagebonus_l</to>
<position>right</position>
<offset>2,0</offset>
<size>
<width>20</width>
</size>
</anchored>
<icon>indicator_expanddown</icon>
<script>
function onValueChanged()
window.onWeaponProp(getValue());
end
</script>
</button_toggle>


function onWeaponProp(show)
prop.setVisible(show);
end

I have this error
Script Error: [string "weapondetails"]:1: attempt to call field 'onWeaponProp' (a nil value)


There's something that I miss? I already trying to check in 4E ruleset, but can't find it.

Thank you

dulux-oz
December 28th, 2015, 14:51
Hi Larhalt,

As your code stands at the moment, the FG engine is looking for an object in the current window called "onWeaonProp()" - obviously a function. Do you have the onWeaponProp() function included in the window's <script> tag? If not, that's your problem. :)

To put it another way: where do you declare the onWeaponProp() function?

Incidentally, if onWeaponProp() is only called from that one place, then you're better off simply having (as part of your "weapondetails" object):


function onValueChanged()
window.prop.setVisible(getValue());
end


Cheers

Larhalt
December 28th, 2015, 15:34
Thank you dulux, it works wonderfully :)