Page 3 of 4 First 1234 Last
  1. #21
    I feel like such a pain now, but let me try to explain this a little better.

    In order to create the pips on the desktop I am using the buttongroup_counter template and lua file from CoreRPG. The only difference is I stripped out all reference to the database. Once I did that, I was able to get the buttons to click on and off as expected. When I add debug commands into the lua file I can generate the correct value. The thing I'm struggling with is now how to I pull that info from the file? I tried registering controls. I tried the getmodifierkey like in 5e. Nothing I have tried will pull a value of 1 to 5 as I would like.

    As of right now, the only change I have made that makes things work is stripping out the database stuff so the buttons will react. At this point I don't know what else to do to get the info out.

    I am attaching the lua file here for reference. As I said, all I did was strip the db info. Any insight on how to now pull the value out of this file and store it in a variable in another lua file? I looked at the 5E code, and from what I can see, it's just looking for a single button to be on or off I tried to manipulate it to work for a variable button, but I couldn't figure it out.

    for reference, here is the template:

    Code:
    	<template name="dice_counter">
    		<genericcontrol>
    			<stateicons>
    				<on>button_checkon</on>
    				<off>button_checkoff</off>
    			</stateicons>
    			<script file="desktop/scripts/dice_counter.lua" />
     		</genericcontrol>
    	</template>
    and here is the windowclass I am using it in:

    Code:
        <windowclass name="rollpanel">
    		<sizelimits>
    			<minimum width="64" height="52" />
    		</sizelimits>
    		<noclose />
           <sheetdata> 
    	 		<dice_counter name="diegroup">
                    <anchored position="insidetopleft" offset="4,50" width="60"/>				
    				<allowsinglespacing />
    			    <stateicons>
    				    <on>button_checkon2</on>
    				    <off>button_checkoff2</off>
    			    </stateicons>                
    				<values>
    					<maximum>5</maximum>
    					<current>2</current>
    				</values>
    				<sourcefields>
    					<current>curr</current>
    				</sourcefields>
    				<maxslotperrow>5</maxslotperrow>
    			</dice_counter>
            </sheetdata>       
        </windowclass>
    I have also added the file to base.xml.

    right now, that's everything I have and did. I don't know what to do next so when I run this function in a different file:

    Code:
    function taskcheck(draginfo, winFrame, foc, tar)
        local nodeWin = winFrame.getDatabaseNode();
        local node = DB.findNode(".");
    	local rActor = ActorManager.getActor("pc", nodeWin);
    	local rolling20 = 0;
    	rolling20 =????????;
        local sides = 20;
        local TN = DB.getValue(nodeWin, tar);
    	local FC = DB.getValue(nodeWin, foc);
    	local nDiff = ActionsManager2.encodeDesktopDiff(nDiff);
        local nComp = 1 -- nodeWin.getChild("rollable.comprange").getValue();
    	local comp = 21 - nComp
    	local sParams = rolling20.."d"..sides.."t"..TN.."f"..FC.."c"..comp.."d"..nDiff;
    	local msg = {font = "sheetlabel"};
    	
    	msg.text = rActor.sName .. " rolls a task"
    	Comm.deliverChatMessage(msg);
    	local msg = {font = "sheetlabel"};
    	msg.text= "Target Number.." .. TN.."\nFocus Range.."..FC.."\nComplication Range.."..nComp.."\nDifficulty.."..nDiff.."\nRolling "..rolling20.. "d20\n";
    	Comm.deliverChatMessage(msg);
    	resetdice(winFrame);
    	DiceRoller.performAction(draginfo, rActor, sParams)
    	return true;
    end
    how do I get rolling20 to be the value 1 to 5, depending on how many pips are turned on?

    I hope that all makes sense. I have been staring at this code for 2 weeks now, and I have to somehow get it to work.
    Add me on Twitch: twitch.tv/statik367

    If you like what I am doing, you can support me via PayPal: paypal.me/wesleytoma
    Or Venmo: venmo.com/Wesley-Toma-Lee

  2. #22
    OK, after searching the forums further, I found this:

    https://www.fantasygrounds.com/forum...on-the-Desktop

    The number 2 version looks pretty much exactly what I want, but instead of entering a number, I want it to add up the value of the pips.

    I put the functions in the dice_counter.lua file and added the script to the windowclass.

    I then had rolling20 = DiceCounter.getDCValue. I changed the control names as appropriately. However, when I reload and try a roll, I get

    attempt to call field 'getValue' (a nil value)
    This ultimately seems to be my issue. How do I make that not nil?
    Add me on Twitch: twitch.tv/statik367

    If you like what I am doing, you can support me via PayPal: paypal.me/wesleytoma
    Or Venmo: venmo.com/Wesley-Toma-Lee

  3. #23
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Denver, Colorado, USA (for a bit)
    Posts
    24,130
    What code is running when you get that error? "nil value" means that getValue is being called against an invalid FG object. What object do you have before the getValue() code? Something like myControlName.getValue()

    As I mention in this post: https://www.fantasygrounds.com/forum...l=1#post387852 "... uses control.examplenumber.getValue() to get the value stored in the examplenumber number control ..."
    FG Con 15 Fantasy Grounds Online RPG Convention - Nov. 8-10, 2019
    Register at www.fg-con.com for all the latest info.

    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. #24
    function getDCValue()
    local numberValue = 0;

    if control then
    Debug.chat(control.diegroup);
    numberValue = control.diegroup.getValue();
    end

    return numberValue;
    end

    And the debug gives me: "windowcontrol = {x,y,w,h = 4,50,50,10}
    Add me on Twitch: twitch.tv/statik367

    If you like what I am doing, you can support me via PayPal: paypal.me/wesleytoma
    Or Venmo: venmo.com/Wesley-Toma-Lee

  5. #25
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Denver, Colorado, USA (for a bit)
    Posts
    24,130
    Quote Originally Posted by statik37 View Post
    And the debug gives me: "windowcontrol = {x,y,w,h = 4,50,50,10}
    What does debug for control give you?
    What does debug for control.diegroup give you?

    You're calling this: numberValue = control.diegroup.getValue(); so FG is looking for a GUI control called control.diegroup - does that exist? Is it accessible from where the code is running? Is getValue() a valid API call for that type of control?
    FG Con 15 Fantasy Grounds Online RPG Convention - Nov. 8-10, 2019
    Register at www.fg-con.com for all the latest info.

    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. #26
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Denver, Colorado, USA (for a bit)
    Posts
    24,130
    Also please read, in detail, the information I provide in the forum posts you've linked. For example:

    "note that control is actually a local variable declared at the stop of the script file - it is here that the reference to the desktop panel control will be stored when it is registered. This allows future function calls into this package to get access to the desktop panel control."

    Do you have this local variable in your script? Do you register it to the actual desktop control?
    FG Con 15 Fantasy Grounds Online RPG Convention - Nov. 8-10, 2019
    Register at www.fg-con.com for all the latest info.

    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!

  7. #27
    Debug of control gives me:

    windowinstance = { class = rollpanel, node = nil, x,y,w,h = 6,944,74,62 }


    Debug for control.diegroup gives me:

    windowcontrol = {x,y,w,h = 4,50,50,10}

    For reference, rollpanel is the name of the windowclass and diegroup is the name of the genericcontrol
    Add me on Twitch: twitch.tv/statik367

    If you like what I am doing, you can support me via PayPal: paypal.me/wesleytoma
    Or Venmo: venmo.com/Wesley-Toma-Lee

  8. #28
    And for your second question, yes I added:

    Code:
    local control = nil;
    
    function registerControl(ctrl)
    	control = ctrl;
    end
    to the start of the file.

    And the windowclass has
    Code:
    			<script>
    				function onInit()
    					DiceCounter.registerControl(self);
    				end
    				
    				function onClose()
    					DiceCounter.registerControl(nil);
    				end			
    			</script>
    Add me on Twitch: twitch.tv/statik367

    If you like what I am doing, you can support me via PayPal: paypal.me/wesleytoma
    Or Venmo: venmo.com/Wesley-Toma-Lee

  9. #29
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Denver, Colorado, USA (for a bit)
    Posts
    24,130
    Quote Originally Posted by Trenloe View Post
    Is getValue() a valid API call for that type of control?
    Quote Originally Posted by statik37 View Post
    ... diegroup is the name of the genericcontrol
    getValue() is not a valid API call for genericcontrol : https://www.fantasygrounds.com/refdo...riccontrol.xcp
    FG Con 15 Fantasy Grounds Online RPG Convention - Nov. 8-10, 2019
    Register at www.fg-con.com for all the latest info.

    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!

  10. #30
    Well shoot.

    Now I feel dumb.

    Is there something I can do for it to look the same and be able to do what I want it to?

    I want it to look like the file attached and click on and off sequentially.

    Here is the code I am using now, for reference.

    Code:
    	<template name="dice_counter">
    		<genericcontrol>
    			<stateicons>
    				<on>button_checkon</on>
    				<off>button_checkoff</off>
    			</stateicons>
    			<script file="desktop/scripts/dice_counter.lua" />
     		</genericcontrol>
    	</template>
    Code:
    	 		<dice_counter name="diegroup">
                    <anchored position="insidetopleft" offset="4,50" width="60"/>				
    				<allowsinglespacing />
    			    <stateicons>
    				    <on>button_checkon2</on>
    				    <off>button_checkoff2</off>
    			    </stateicons>                
    				<values>
    					<maximum>5</maximum>
    					<current>2</current>
    				</values>
    				<sourcefields>
    					<current>curr</current>
    				</sourcefields>
    				<maxslotperrow>5</maxslotperrow>
    			</dice_counter>
    Attached Images Attached Images
    Add me on Twitch: twitch.tv/statik367

    If you like what I am doing, you can support me via PayPal: paypal.me/wesleytoma
    Or Venmo: venmo.com/Wesley-Toma-Lee

Thread Information

Users Browsing this Thread

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

Posting Permissions

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

Log in

Log in