5E Product Walkthrough Playlist
Page 4 of 4 First ... 234
  1. #31
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    In desktop/scripts/dice_counter.lua write some code (maybe call the function getPips ??) that calculates and returns the number of pips selected and then call that code.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  2. #32
    So, I tried, out of curiosity, changing it from a generic control to a button control.

    The errors went away, but I get 0 whenever I call it. I did try what you said, but I guess I don't know how to make it so a variable will be collectible from the outside.
    Wesley Toma-Lee
    Lead Developer
    Nerd Eye Industries
    https://www.nerdeyeindustries.com

  3. #33
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    Quote Originally Posted by statik37 View Post
    I did try what you said, but I guess I don't know how to make it so a variable will be collectible from the outside.
    Make a function in desktop/scripts/dice_counter.lua, something like:

    Code:
    function getPips()
      local nPips = 0;
    
      -- Write code that gets the number of pips and store that in nPips.
      -- Then return nPips as follows:
    
      return nPips;
    end
    Then, assuming that control.diegroup is valid where you run your code, call the function with: control.diegroup.getPips()
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  4. #34
    I thought I tried that and just kept getting either 0 or nil. But, as I'm typing, I am trying other things. For example. I realised that the getValue will return 0 because nowhere in my script am I calling a setValue.

    So I have the beginning of a function here that I was trying:

    Code:
    function updateSlots()
    	if not bInit then
    		return;
    	end
    	
    		Debug.chat("control", control);
                    checkBounds();
    
    	local m = getMaxValue();
    	local c = getCurrentValue();
    	if control then
    		Debug.chat(control);
    		Debug.chat(control.diegroup);
    		control.diegroup.setValue(c);
    	end
    The problem is the if loop doesn't run because the control isn't carrying into the function. the first debug generates a nil.
    Wesley Toma-Lee
    Lead Developer
    Nerd Eye Industries
    https://www.nerdeyeindustries.com

  5. #35
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    Quote Originally Posted by statik37 View Post
    the first debug generates a nil.
    So control is nil then. You'll need to investigate why.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  6. #36
    The reason that is happening semms to have been fixed by changing control to window, now it calls it up no problem.

    Here's another issue. It seems like it was issue after issue piling up.

    in https://www.fantasygrounds.com/refdo...l.xcp#setValue It states that:

    Sets the value of the button control. If the value specified is greater than the number of button states defined, then the value is set to zero instead.
    I think I have to define that there are 5 stages of button press, but I don't know how to do that part.

    Intead, I set a global variable nValue = 0 at the top of the file. Then, at the bottom of the update slots, I set nValue = c, which is the current value for the button. and returned nValue. But, when I call for the roll and getDCValue function, which right now only says Debug.chat(nValue)

    I get a returned value of 0. I feel like I am missing a super simple step.
    Wesley Toma-Lee
    Lead Developer
    Nerd Eye Industries
    https://www.nerdeyeindustries.com

  7. #37
    Don't use a buttoncontrol. That requires you to define all five states. Use a genericcontrol and define your own getValue. Make sure to liberally use Debug statements to make sure your variables are what they should be.

    JPG

  8. #38
    You are a godsend. You are all godsends. After messing with this code for, literally, 2 weeks, it's finally working. I can not thank you and Moon Wizard, and Damned enough for all the patience and tutelage you have given me. When I saw it working correctly, I almost cried.
    Wesley Toma-Lee
    Lead Developer
    Nerd Eye Industries
    https://www.nerdeyeindustries.com

  9. #39
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    Quote Originally Posted by statik37 View Post
    When I saw it working correctly, I almost cried.
    I don't help with crying. You're on your own there!

    Glad you got it working!
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

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
  •  
5E Character Create Playlist

Log in

Log in