STAR TREK 2d20
  1. #1

    Example of a diecontrol that accepts dragged dice

    Could anyone point me to an example of a diecontrol that is basically an empty box until player drags appropriate dice there?

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    See <windowclass name="char_attribute"> in CoreRPG: campaign\record_char_main.xml The <basicdice name="dice"> control is what you're looking for.
    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!

  3. #3
    Quote Originally Posted by Trenloe View Post
    See <windowclass name="char_attribute"> in CoreRPG: campaign\record_char_main.xml The <basicdice name="dice"> control is what you're looking for.
    Thank you Trenloe

  4. #4
    Out of that I used something like this, but it gives '<eof>' expected near 'end' is it the setDice command you think?

    function recalc()
    local dmg = window.getDatabaseNode().
    getChild("damage").getValue();
    local wpndmg = window.getDatabaseNode().
    getChild("attributes.DM.current").getValue();
    local totdmg = wpndmg+dmg;
    setDice(dice);
    end
    end

  5. #5
    It looks like you have an extra 'end' in there that doesn't match up with anything that I can see.

  6. #6
    I think I fixed that, but I seem to have a recurring problem with diecontrol and strings that involve dice that produce this error:

    Script Error: [string "skilllevel"]:1: attempt to call field 'onDoubleClick' (a nil value)

    I'm not sure what is causing this as I have looked through the offending areas and I can't find the culprit. There is another thing called rollDamage that gives the same error. At times it will point to the chatmanager.lua file, but otherwise will usually blame the windowclass element.

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    If ever you get an "attempt to call field XXXXX (a nil value)" error, then that means that XXXXX doesn't exist or isn't accessible from where you are running the code.

    onDoubleClick is an event handler that is present in all window controls: https://www.fantasygrounds.com/refdo...#onDoubleClick It can be triggered by double-clicking on a control, or it can be called from another function. If the control where the onDoubleClick code is be called from doesn't support the onDoubleClick method then you might get this error.

    It might also mean that the function isn't accessible from where you're calling it to do the script scope - refer to the "Using Scripts" section of this page.

    You may also find it easier to write your LUA scripts in separate LUA files and attach these to the control rather than writing your scripts within the XML of the control. The advantage of using LUA files rather than inline scripting is that the error message will tell you the line number within that file where the error is occurring - this helps a lot in tracking down where the error is. With inline LUA within XML all you'll know is which control raised the error - in your example, the "skilllevel" control, but you won't get the line number of the LUA script where the error occurred.
    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!

  8. #8
    leozelig's Avatar
    Join Date
    Jun 2007
    Location
    Eastern USA
    Posts
    1,852
    Blog Entries
    1
    I am trying to create the same thing. I have been modifying the C&C ruleset as a learning exercise. I have inserted the code almost exactly as written for the CoreRPG character sheet:

    Code:
    			<basicdice name="actiondice">
    				<anchored to="combatframe" position="insidetop" offset="-15,85" width="50" height="30" />
    				<frame name="fielddark" offset="7,5,7,5" />
    				<script>
    					function onInit()
    						onValueChanged();
    					end
    					
    					function onValueChanged()
    						setVisible(not isEmpty());
    					end
    
    
    					function onDragStart(button, x, y, draginfo)
    						return window.onDragStart(button, x, y, draginfo);
    					end
    
    
    					function onDoubleClick(x, y)
    						return window.onDoubleClick(x, y);
    					end
    				</script>
    			</basicdice>
    This is producing the following error when I open the character sheet:
    Ruleset Error: windowcontrol: Database type mismatch for control (actiondice) in windowclass (charsheet_main)


    I have finished the main tab except for this little bit. Here is a screenshot to give you an idea of what I need. I want to replace the <basicnumber> fields for "Action Dice" and "Crit Die" with <basicdie> fields.

    Attachment 9578

  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    Quote Originally Posted by leozelig View Post
    This is producing the following error when I open the character sheet:
    Ruleset Error: windowcontrol: Database type mismatch for control (actiondice) in windowclass (charsheet_main)


    I have finished the main tab except for this little bit. Here is a screenshot to give you an idea of what I need. I want to replace the <basicnumber> fields for "Action Dice" and "Crit Die" with <basicdie> fields.
    Create a new character, you shouldn't get the error.

    The error is caused by a character sheet created when the "actiondice" field was of type <basicnumber>, and the underlying data field would have been stored in the database with a type of "number". When you change <basicnumber> to <basicdie> the GUI is expecting a different database type than number - hence the "Database type mismatch" error. If you create a new character it makes all of the fields with the correct database types for the current XML definitions you have in the ruleset, so you won't get the error. Until you change the types in future...
    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. #10
    leozelig's Avatar
    Join Date
    Jun 2007
    Location
    Eastern USA
    Posts
    1,852
    Blog Entries
    1
    Trenloe, you are truly a wizard!

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
  •  
Starfinder Playlist

Log in

Log in