5E Character Create Playlist
Page 1 of 2 12 Last
  1. #1

    buttoncontrol/buttonfield getValue problem

    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:

    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

  2. #2

  3. #3
    All the calls to the class own functions throw errors (getValue, setValue, setStateTooltipText), but the inherited functions (setVisible, setTooltipText) works.

  4. #4

  5. #5
    This is for retrieving the value from database. It should be possible to get the value directly from the control.

  6. #6
    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

  7. #7
    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

  8. #8
    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

  9. #9
    Quote Originally Posted by Moon Wizard View Post
    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?

  10. #10
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
FG Spreadshirt Swag

Log in

Log in