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

    Adding fields to record_item window

    Looking over this for days and out of ideas. How would one insert additional fields in the item window? I can actually add the fields but not where I would like them to go. Example below.

    I would like to add the "Item Type" cycler either into the first Section or it's own Section following the first. Here is the code I've done.

    record_item.xml
    Code:
    <windowclass name="item_main" merge="join">
    		<margins control="0,0,0,2" />
    		<script file="campaign/scripts/item_main.lua" />
    		<sheetdata>
    			<anchor_column name="columnanchor" />
    
    			<label_column name="nonid_name_label">
    				<static textres="item_label_unidentified" />
    			</label_column>
    			<string_columnh name="nonid_name" />
    			
    			<label_column name="nonid_notes_label">
    				<static textres="item_label_unidentifiednotes" />
    			</label_column>
    			<string_columnh name="nonid_notes" />
    
    			<line_column name="divider" />
    
    			<label_column name="item_type_label">
    				<static textres="item_type_group" />
    			</label_column>
    			<item_cycler name="itemtype">
    	    		        <anchored to="item_type_label" position="insidetopleft" offset="100,5" width="100" height="20" />
    	    	        </item_cycler>
    
    			<line_column name="divider2" />
    
    			<label_column name="cost_label">
    				<static textres="item_label_cost" />
    			</label_column>
    			<string_columnh name="cost" />
    
    			<label_column name="weight_label">
    				<static textres="item_label_weight" />
    			</label_column>
    			<number_columnh name="weight" />
    
    			<line_column name="divider3" />
    
    			<ft_columnh name="notes" />
    
    		</sheetdata>
    	</windowclass>
    my modified block of code in item_main.lua
    Code:
    function update()
    	local nodeRecord = getDatabaseNode();
    	local bReadOnly = WindowManager.getReadOnlyState(nodeRecord);
    	local bID = LibraryData.getIDState("item", nodeRecord);
    	
    	local bSection1 = false;
    	if User.isHost() then
    		if updateControl("nonid_name", bReadOnly, true) then bSection1 = true; end;
    	else
    		updateControl("nonid_name", bReadOnly, false);
    	end
    	if (User.isHost() or not bID) then
    		if updateControl("nonid_notes", bReadOnly, true) then bSection1 = true; end;
    	else
    		updateControl("nonid_notes", bReadOnly, false);
    	end
    
    	local bSection2 = false;
    	if updateControl("itemtype", bReadOnly, bID) then bSection2 = true; end
    	
    	local bSection3 = false;
    	if updateControl("cost", bReadOnly, bID) then bSection3 = true; end
    	if updateControl("weight", bReadOnly, bID) then bSection3 = true; end
    
    	local bSection4 = bID;
    	notes.setVisible(bID);
    	notes.setReadOnly(bReadOnly);
    		
    	divider.setVisible(bSection1 and bSection2);
    	divider2.setVisible((bSection1 or bSection2) and bSection3);
    	divider3.setVisible((bSection1 or bSection2 or bSection3) and bSection4);
    end
    This is my result. As I said, I would like to get the cycler to show up in it's own section before "Cost"

  2. #2
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,678
    Blog Entries
    1
    At first blush that looks correct...
    Where are you adding this code? In the ruleset or an extension? Do you have any other extensions active?

  3. #3
    Thanks for the reply.

    Adding in an extension, using the MoreCore ruleset, but there doesn't seem to be MC record_item, so I am extending the CoreRPG record_item.xml. No other extensions active.

  4. #4

  5. #5
    Did this, used merge="replace", reloaded FG and the console shot back an error: windowclass: Defined with unrecognized merge attribute value(replace)

  6. #6
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,678
    Blog Entries
    1
    Quote Originally Posted by Ranzarok View Post
    Did this, used merge="replace", reloaded FG and the console shot back an error: windowclass: Defined with unrecognized merge attribute value(replace)
    Merge = delete
    Sorry on my phone
    The reason the above isn't working is because the anchoring is relative and you have not defined all of the fields which means that the ones you didn't drive are displaying before your new ones

  7. #7
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,678
    Blog Entries
    1
    It leave the merge attribute off altogether and it will replace.

  8. #8
    Quote Originally Posted by damned View Post
    It leave the merge attribute off altogether and it will replace.
    Thanks, that worked (leaving off the merge).

    Just for my reference, could you explain this:
    The reason the above isn't working is because the anchoring is relative and you have not defined all of the fields which means that the ones you didn't drive are displaying before your new ones
    If the anchoring is relative, and I replaced the entire file, which fields would I have needed to define?

    Thanks again for your help, I appreciate it.

  9. #9
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,678
    Blog Entries
    1
    Replacing the entire file you need to just put your entries in the right order with the other elements.
    Like you did in your example. It's just the merge doesn't really work that well with those relative anchors.

  10. #10

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