PDA

View Full Version : buttoncontrol/buttonfield getValue problem



psicodelix
November 18th, 2014, 11:17
Hi,

I don't know if there is some problem or I'm missing something about buttoncontrol/buttonfield controls, because I'm unable to retrieve the actual control value by the getValue function.

I have this code:


<buttonfield name="showoptions">
<state icon="expand" />
<state icon="collapse" />
<anchored to="rightanchor" width="10" height="10">
<top offset="5"/>
<right anchor="left" relation="relative" offset="-5" />
</anchored>
<script>
function onValueChanged()
if getValue() == 0 then
actions.setVisible(false);
else
actions.setVisible(true);
end
end
</script>
</buttonfield>


but the the getValue() call always throw an error, and I'm unable to get a reference to the showoptions control

damned
November 18th, 2014, 12:38
can you do a setValue or some other action to make sure your onValueChanged is being read/actioned first?

psicodelix
November 18th, 2014, 17:18
All the calls to the class own functions throw errors (getValue, setValue, setStateTooltipText), but the inherited functions (setVisible, setTooltipText) works.

damned
November 18th, 2014, 20:44
hmmm... dont you need to be specifying the button specifically?

function getValue( sourcenode, [subpath], [default] )

psicodelix
November 18th, 2014, 21:40
This is for retrieving the value from database. It should be possible to get the value directly from the control.

Moon Wizard
November 20th, 2014, 22:38
Did you figure this out already?

If not,
* How is onValueChanged being called? (directly by FG when node value changes, or via external call)
* Are there any error messages in the console other than the missing getValue function?
* What do you get when you add a Debug.console(self) to the first line of the onValueChanged function?

Regards,
JPG

psicodelix
November 21st, 2014, 06:08
Hi JPG,

- the onValueChange event is called directly by FG, when the button is pressed by the user.
- that is the only error in the console:

[21.11.2014 06:02:36] Script Error: [string "char_attribute:showoptions"]:1: attempt to call global 'getValue' (a nil value)

- the Debug.console(self) returns:

[21.11.2014 06:04:17] Script Notice: WINDOWCONTROL = { nil }


Regards

Moon Wizard
November 25th, 2014, 21:26
It sounds like perhaps the onValueChanged event is being called in the middle of creation or destruction of the window. Any chance this could be happening? If so, you may have to add a flag to prevent the processing of the onValueChanged event code until after onInit event has been called, or prevent processing after onClose event has been called.

Otherwise, I'll probably have to take a look at the code directly on my machine to see what is going on.

Regards,
JPG

psicodelix
November 28th, 2014, 11:19
It sounds like perhaps the onValueChanged event is being called in the middle of creation or destruction of the window. Any chance this could be happening?

I don't think so, because the window is created long before the value of the field change and trigger the event.

The same code is working for other classes so, it may be that FG is not correctly exposing the buttoncontrol class interfaces to lua engine?

Moon Wizard
November 30th, 2014, 00:41
I have no idea. I'd have to run the code to see what is happening.

Do you have a copy of the ruleset somewhere that I can download and look at? As well as instructions to recreate?

Regards,
JPG

psicodelix
December 2nd, 2014, 06:37
Ok:

- Start a new CoreRPG campaing with the attached extension loaded.
- Go to options window, to the Charsheet (GM) section and set "Skills: show rollable chat command" to ON
- Create a new character
- Open the character sheet and insert a new section and a new skill
- You will see a new down arrow button next to the bonus box. This button is intended to show a hidden section under the skill name.
- If you press this button FG console raises the refered error.
- You can check the record_char_main.xml file in the extension. In line 218 there is the problematic buttonfield definition.

I'm only want to be able to read the button's current state.

Thank you very much.

damned
December 2nd, 2014, 08:01
Hi Moon_Wizard - this is to enable psuedo dice macros in CoreRPG as in https://www.fantasygrounds.com/forums/showthread.php?22303-CoreRPG-Requests :)

https://www.fg-con.com/wp-content/uploads/2014/12/dice-macros.gif

At the moment it is only seeing the changed state on restart of FG?

psicodelix
December 2nd, 2014, 08:06
You can only see the changes on restarting FG because, although the buttonfield is correctly changing its value when you click on it, I'm unable to read its actual value when it changes.

Moon Wizard
December 3rd, 2014, 18:23
Here's the updated extension.

The root cause was that the compatibility mode of the extension was set to 2.8. The getValue function is not registered for buttoncontrol/buttonfield objects in compatibility mode to prevent overriding older extensions.

During the process, I also removed a bunch of templates and windowclasses that were being redefined exactly the same as the originals. You only need to override those windowclasses and templates that you actually change, regardless of file name.

Regards,
JPG

psicodelix
December 3rd, 2014, 18:53
Nice!

Thank you very much JPG!

Kilitar
December 4th, 2014, 23:46
Found a bug in extension or I do something wrong. Its not functional bug but spams console

Script Error: [string "common/scripts/list_textitem.lua"]:30: attempt to index field 'windowlist' (a nil value)


It happens at atribute/skill table.
Add new group
Add new skill
Use extend arrow to add die macro
On empty field press backspace on keyboard (red arrow on image bellow)
8215