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

    need coding help with BOTTOMs and how to reference another window

    As the title says, Im missing something basic and my infamiliarity with the environment has me flustered. I do a little bit too much HTML coding and i may be confusing the DOM there with the way FG works. Im working on a CORErpg extension to make a Roll&Keep window.

    First, how do I reference data from another window? My new window will need to pull data off of the charactersheet. Stuff like 'name' and ability scores. So far, alls I've gotten is nil references trying to use stuff like parent and windowlist. What's the correct way to go about it?

    Second, here is my code to put two number boxes at the bottom of a window.
    Code:
    	<template name="rnk_close">
    		<buttoncontrol>
    			<anchored height="24" width="24" />
    			<icon normal="rnk_button_close" pressed="rnk_button_close_down" hover="rnk_button_close_hover" />
    			<script>
    				function onButtonPress()
    					window.close();
    				end
    			</script>
    		</buttoncontrol>
    	</template>
    	<template name="close_rnk">
    		<rnk_close>
    			<anchored>
    				<top offset="0" />
    				<right offset="0" />
    			</anchored>
    		</rnk_close>
    	</template>
    	<template name="rnk_number">
    		<numberfield>
    			<anchored height="20" width="30" />
    			<noreset />
    			<script file="common/scripts/number.lua" />
    		</numberfield>
    	</template>
    	<template name="simple_rnk_number">
    		<rnk_number>
    			<droptypes>
    				<type>number</type>
    			</droptypes>
    			<font>sheetnumber</font>
    		</rnk_number>
    	</template>
    	<template name="sheet_rnk_number">
    		<simple_rnk_number>
    			<frame mergerule="replace" name="fielddark" offset="7,5,7,5" />
    			<stateframe>
    				<keyedit name="fieldfocus" offset="7,5,7,5" />
    				<hover name="fieldfocus" offset="7,5,7,5" hidereadonly="true" />
    				<drophilight name="fieldfocus" offset="7,5,7,5" hidereadonly="true" />
    			</stateframe>
    		</simple_rnk_number>
    	</template>
    	<windowclass name="rnkwindow">
    		<frame>fielddark</frame>
    		<sheetdata>
    			<close_rnk />
    			<sheet_rnk_number name="roll_entry">
    				<anchored>
    					<left offset="50" />
    					<bottom offest="-10"/>
    				</anchored>
    			</sheet_rnk_number>
    			<sheet_rnk_number name="keep_entry">
    				<anchored>
    					<bottom offest="-10"/>
    					<left offset="130" />
    				</anchored>
    			</sheet_rnk_number>
    		</sheetdata>
    	</windowclass>
    That code puts the close button correctly centered on the top right corner. I can even move it by putting in numbers other than 0. But the number boxes refuse to get off the bottom row. I can move them side to side, but any number i put for the bottom offset has no effect. What am I doing wrong there?

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,425
    1) If the window you want to reference is a completely separate window, then you're best off going directly to the data the window displays in the database. Even if the data is on another tab of a window (e.g. a character sheet) it usually is best to go the database as well. Some info on the FG database here: https://www.fantasygrounds.com/modguide/database.xcp

    2) Have you tried a bottom offset of -50 just to see if that gets the control off the bottom of the window? I don't know what the dimensions of the fielddark frame are, but using <anchored> without a <parent> results in the windows edge being used as the reference. See the "Anchoring" section here: https://www.fantasygrounds.com/modguide/windowing.xcp How large is the frame used for the window?
    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
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,425
    To expand on point 1 - the CoreRPG ruleset uses a lot of code that refers to the "actor" - this is a reference to a PC or NPC record. scripts\manager_actor.lua has a few functions to get the actor record (rActor) and then use rActor to access further data - and it also is used to get a databasenode reference so you can extract specific data from the character record in the database. This is really the best way to go. If you haven't looked at the FG database and how to access data there it can be a bit daunting, but it's well worth spending the time to get to know your way around it.
    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. #4
    problem 2 was fixed with
    Code:
    				<anchored>
    					<top anchor="bottom" offset="-20"/>
    					<left offset="10" />
    				</anchored>

  5. #5
    hrm, how do i call?

    my code line is:
    desc = getActor("pc","databasenode").window["name"].getValue() + "test";

    im getting error:
    Runtime Notice: Reloading ruleset
    Script Error: [string ""]:1: attempt to call global 'getActor' (a nil value)

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,425
    manager_actor.lua is a global script package - which is defined in base.xml. See the "Script Packages" section here: https://www.fantasygrounds.com/modguide/scripting.xcp

    The CoreRPG base.xml file has the following code: <script name="ActorManager" file="scripts/manager_actor.lua" /> This defines the global package as ActorManager. Therefore, you can call getActor with ActorManager.getActor...
    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. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,425
    Your biggest "problem" could be deciding on which character record to access, as a player could own multiple characters and have multiple character sheets open. Which one do you access?

    FG has a useful function for this - CombatManager.getCurrentUserCT(). This is in scripts\manager_combat.lua and returns the combat tracker node for either the currently active PC or NPC (useful for the GM, but also for a player with multiple PCs) or the currently active character sheet for a player. The CTNode can be used to get the rActor record: ActorManager.getActorFromCT(CombatManager.getCurre ntUserCT());

    This is heavily linked to the combat tracker, which might not always be appropriate, so you might just want to go for the currently active PC for a player, and use something like this: rActor = ManagerActor.getActor("string", "charsheet." .. User.getCurrentIdentity()); However, this won't work for the GM.

    See here for info on activating a character: https://www.fantasygrounds.com/wiki/...Character_List
    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
    its for a 7th sea campaign. the combat tracker they use is really wonky and doesnt fit easily into the existing initiative based combat tracker FG uses.

    so if getActor() is DB wide, and the DB includes all players and npcs, then getting to the right player might be player driven via a combo box... or ill need to be more inventive. wait, getActor() only has 2 arguments... why does your example include that User bit?

    Once i can see how the DB is laid out once it's all running, it should be a snap... catch 22 is getting it all runnning, lol

  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,425
    Quote Originally Posted by grelgen View Post
    wait, getActor() only has 2 arguments... why does your example include that User bit?
    rActor = ManagerActor.getActor("string", "charsheet." .. User.getCurrentIdentity()) has two arguments. Two dots: ".." in LUA is a concatenation - so "charsheet." .. User.getCurrentIdentity() is a single argument.

    The advantage of this command is that, on the player side, it will use whichever PC is activated - the last one they selected from the PC portraits in the top left of the desktop. See here for info on this: https://www.fantasygrounds.com/wiki/...Character_List

    Using the active character would replace any combo box you might be thinking about (it's doing the same job).
    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
    this is just getting frustrating... how do i look at this in FG as a player, not a GM. cause this is just impossible to test otherwise

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 Product Walkthrough Playlist

Log in

Log in