Page 1 of 2 12 Last
  1. #1

    [Programming] windowlist within windowlist object

    Hey again guys! this one i imagine is fairly simple to answer, it's just a simple syntax thing i'm having trouble with, i'm sure.

    so in my ruleset, vehicles have windowlists that hold inventory like a character.

    the PC sheets also have a windowlist that can hold vehicles like inventory.

    example of what i want to do:
    the weapons section of the PC sheets shows weapons from the inventory. instead of seeing weight, we see a field for damage and bonus.
    example.png
    so basically what i would like is to have the armaments windowlist on the main page to contain all the armaments within the vehicles windowlist on the inventory page.

    i'm sure it's something like what i have below with the setDatabaseNode() function, but i really am not sure how to delve further into the character sheet.

    so i want the armaments windowlist from the mainsheet. . . .
    Code:
    <windowclass name="charsheet_main2" source="charsheet_main2">
    		<margins control="0,0,0,3" />
    		<sheetdata>
                            <windowlist name="armamentslist">
    				<anchored to="armamentsframe">
    					<top offset="40" />
    					<left offset="15" />
    					<right offset="-10" />
    					<bottom offset="-15" />
    				</anchored>
    				<child></child>
    				<child><backcolor>1A40301E</backcolor></child>
    				<datasource>.armamentslist</datasource>
    				<class>vehicle_armaments</class>
    				<acceptdrop>
    					<class>referencetext</class>
    					<class>referencetextwide</class>
    					<field>*</field>
    				</acceptdrop>
    				<allowdelete />
    				<script>
    					function onListChanged()
    						
    						setDatabaseNode(DB.getPath(node, "*.vehicleinv"));
    					end
    				</script>
    			</windowlist>
    . . . to have the same list of items as the vehicles in the list on the record_char_inventory.xml. . .

    Code:
                         <windowlist name="vehiclelist">
    				<anchored to="vehicleframe">
    					<top offset="40" />
    					<left offset="15" />
    					<right offset="-10" />
    					<bottom offset="-15" />
    				</anchored>
    				<child></child>
    				<child><backcolor>1A40301E</backcolor></child>
    				<datasource>.vehiclelist</datasource>
    				<class>char_vehicle</class>
    				<acceptdrop>
    					<class>vehicle</class>
    					<class>referencetextwide</class>
    					<field>*</field>
    				</acceptdrop>
    				<allowdelete />
    			</windowlist>

    the armaments list in the vehicles windowclass is in the record_vehicle.xml. . .
    Code:
                       <windowlist name="armamentslist">
    				<anchored height="80">
    					<top parent="columnanchor" anchor="bottom" relation="relative" offset="10" />
    					<left offset="90" />
    					<right offset="-10" />
    				</anchored>
    				<frame>fielddark</frame>
    				<child></child>
    				<child><backcolor>1A40301E</backcolor></child>
    				<datasource>.vehicleinv</datasource>
    				<class>vehicle_armaments</class>
    				<acceptdrop>
    					<class>referencetext</class>
    					<class>referencetextwide</class>
    					<field>*</field>
    				</acceptdrop>
    				<allowdelete />
    			</windowlist>
    “The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents. We live on a placid island of ignorance in the midst of black seas of the infinity, and it was not meant that we should voyage far.”
    ― H. P. Lovecraft, The Call of Cthulhu and Other Weird Stories

    “The oldest and strongest emotion of mankind is fear, and the oldest and strongest kind of fear is fear of the unknown”
    ― H.P. Lovecraft, Supernatural Horror in Literature

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Denver, Colorado, USA (for a bit)
    Posts
    23,651
    The <datasource> tag determines the database location of the data displayed in the windowlist.

    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!

  3. #3
    So for the armaments section of the main page, would I set it like
    Code:
    <datasource>.vehiclelist.window.vehicleinv</datasource>
    “The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents. We live on a placid island of ignorance in the midst of black seas of the infinity, and it was not meant that we should voyage far.”
    ― H. P. Lovecraft, The Call of Cthulhu and Other Weird Stories

    “The oldest and strongest emotion of mankind is fear, and the oldest and strongest kind of fear is fear of the unknown”
    ― H.P. Lovecraft, Supernatural Horror in Literature

  4. #4
    so i tried setting the <datasource> tag for the vehicle inventory and the player armaments list to <datasource>DB.VehicleInv</datasource> and that almost worked, but then each vehicle in the list had the same armaments. i guess setting it to DB.whatever gave no room for variance? not what you said to do anyway, but i thought i'd see how it worked. i don't want all the vehicles in the inventory to have the same armaments, but i do want the armaments list on the PC sheet to have all the armaments from the vehicle's inventory. would a DB.addHandler() and a getWindows() function be better? something like how encumbrance is updated when item weight is changed?

    edit: i suppose this could work for now if i limited the vehicle list to one vehicle only.

    this is how the source looks in the db.xml file, so do i want my datasource to look something like <datasource>.vehicle.vehiclelist.VehicleInv</database>? i'm missing something there if so.

    Code:
              <vehicle>
    		<id-00006>
    			<vehiclelist>
    				<VehicleInv>
    					<id-00002>
    						<cost type="string">$300</cost>
    						<isidentified type="number">1</isidentified>
    						<itemtype type="number">2</itemtype>
    						<locked type="number">1</locked>
    						<name type="string">.357 Magnum Revolver</name>
    						<notes type="formattedtext">
    							<p>Bonus: +1</p>
    							<p>Damage: 2</p>
    							<p>Range: Medium</p>
    							<p>A classic high caliber revolver, equally popular amongst both Frontier marshals and lowlifes.</p>
    						</notes>
    						<weaponbonus type="number">1</weaponbonus>
    						<weapondamage type="number">2</weapondamage>
    						<weaponrange type="number">3</weaponrange>
    						<weight type="number">1</weight>
    					</id-00002>
    				</VehicleInv>
    			</vehiclelist>
    		</id-00006>
    	</vehicle>
    Last edited by pr6i6e6st; September 22nd, 2019 at 08:39.
    “The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents. We live on a placid island of ignorance in the midst of black seas of the infinity, and it was not meant that we should voyage far.”
    ― H. P. Lovecraft, The Call of Cthulhu and Other Weird Stories

    “The oldest and strongest emotion of mankind is fear, and the oldest and strongest kind of fear is fear of the unknown”
    ― H.P. Lovecraft, Supernatural Horror in Literature

  5. #5
    ok, so i have to be close here, because when i entered the following as the datasource, it removed what was in the vehiclelist on the players inventory page.
    <datasource>.*..VehicleInv</datasource>

    but it still doesn't show any of the inventory from the vehicle in the players main sheet.

    the datasource of the vehiclelist is:
    <datasource>.vehiclelist</datasource>

    while the datasource of the vehicles own inventory is:
    <datasource>.VehicleInv</datasource>
    “The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents. We live on a placid island of ignorance in the midst of black seas of the infinity, and it was not meant that we should voyage far.”
    ― H. P. Lovecraft, The Call of Cthulhu and Other Weird Stories

    “The oldest and strongest emotion of mankind is fear, and the oldest and strongest kind of fear is fear of the unknown”
    ― H.P. Lovecraft, Supernatural Horror in Literature

  6. #6
    * doesn’t work for control data source. It’s only for DB.addHandler/removeHandler.

    You have to have a specific path to a set and f child nodes to use data source directly.

    Otherwise, you’re better off rolling your own that queries existing records across all sources, builds each window in the list, then adds handlers for onAdd/onDelete to add/remove windows. This is how the campaign record master lists are built.

    In general that’s much more complex, and I recommend against using lists fed from multiple locations.

    Regards,
    JPG

  7. #7
    Quote Originally Posted by Moon Wizard View Post
    * doesn’t work for control data source. It’s only for DB.addHandler/removeHandler.

    You have to have a specific path to a set and f child nodes to use data source directly.

    Otherwise, you’re better off rolling your own that queries existing records across all sources, builds each window in the list, then adds handlers for onAdd/onDelete to add/remove windows. This is how the campaign record master lists are built.

    In general that’s much more complex, and I recommend against using lists fed from multiple locations.

    Regards,
    JPG
    Ok, so I'm limited to a single data source then unless I get crazy with the code.

    So perhaps there's something I can do to be able to ”equip” a vehicle, setting that particular vehicles inventory as the new data source to use. So rather than getting all the different .VehicleInv from the different vehicles in the inventory, we just get the one list from the equipped vehicle.

    Or I could just make the vehiclelist entries have subwindows with their .VehicleInv list below each entry.
    “The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents. We live on a placid island of ignorance in the midst of black seas of the infinity, and it was not meant that we should voyage far.”
    ― H. P. Lovecraft, The Call of Cthulhu and Other Weird Stories

    “The oldest and strongest emotion of mankind is fear, and the oldest and strongest kind of fear is fear of the unknown”
    ― H.P. Lovecraft, Supernatural Horror in Literature

  8. #8
    You can use windowlistcontrol.setDatabaseNode to update the source node for the windowlist. Technically, the windowlist does support a table of node paths, or a single node path. However, it does not support wildcards, so you still have to be specific.

    JPG

  9. #9
    Ok, so say the windowlist entry of the vehicle list has a button much like the ”carried” button, but it's only equipped or not equipped.

    What I want then, is to have a code in that equipped button, when set to equipped, to tell the armaments windowlist in the player sheet, to have the same data source as the equipped vehicle’s .VehicleInv?

    So something like

    onValueChanged()
    if getValue() ==1 then
    NewNode = window.getDatabaseNode().getChild(”.VehicleInv”)

    Windowlist.getDatabaseNode().getChild(”.armaments” ).setDatabaseNode(NewNode)
    Last edited by pr6i6e6st; September 23rd, 2019 at 20:37.
    “The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents. We live on a placid island of ignorance in the midst of black seas of the infinity, and it was not meant that we should voyage far.”
    ― H. P. Lovecraft, The Call of Cthulhu and Other Weird Stories

    “The oldest and strongest emotion of mankind is fear, and the oldest and strongest kind of fear is fear of the unknown”
    ― H.P. Lovecraft, Supernatural Horror in Literature

  10. #10
    You're getting into some pretty advanced stuff, because you're trying to link multiple records into a view within another record. That's going to be complicated, and require quite a bit of work.

    As for your specific mention above; windowlist.setDatabaseNode is only for the windowlist control itself. You can't switch back and forth between controls and database nodes. Once you go to database nodes, you don't know which controls are viewing that database node. You can only go from windowcontrol->databasenode, not the other way.

    Also, are you saving the equipped status of the vehicle somewhere? It seems like it would need to be saved with the character record as a specific character vehicle record, not as part of the original vehicle record. In this case, it gets even more complicated, because you basically need a local character vehicle record that stores specific character vehicle information (equipped, etc.) as well as storing the main vehicle record database information. Then, since each window can only have one data source, you would have to create a window with the character specific vehicle information as controls, and use a subwindow control and subwindow.setValue API to make any vehicle specific information appear (name, etc.). Like I said, it starts getting very complex going across records.

    In the equipped button, you would add something like:

    In button code:

    Code:
    function onButtonPress()
      if getValue() == 1 then
        window.setEquippedVehicle();
      else
        window.unequipAllVehicles();
      end
    end
    In vehicle window containing button:

    Code:
    function setEquippedVehicle()
      windowlist.setEquippedVehicle(self);
    end
    
    function unequipAllVehicles()
      windowlist.setEquippedVehicle(nil);
    end
    In the vehicle list control containing the vehicle windows with the buttons:

    Code:
    function setEquippedVehicle(winVehicle)
      foreach _,w in ipairs(getWindows())
        if w ~= winVehicle then
          w.equipped_button.setValue(0);
        end
      end
    end
    Regards,
    JPG

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