Page 1 of 2 12 Last
  1. #1
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    GMT -7
    Posts
    7,917
    Blog Entries
    9

    Creating a New List Type/Class/etc

    So I've got the need to create a couple of new sets of lists in my ruleset. I'm basing this off the Inventory lists system in CoreRPG, but am stuck due to my lack of coding knowledge.

    I starting by duplicating the "<list_charinv", "<button_iedit" & "<button_iadd" sections from "record_char_inventory.xml" to "record_char_main.xml" and editing as follows (and putting them inside a frame);
    Code:
     			<list_defenses name="defenselist">				<anchored to="defensesframe">
    					<top offset="40" />
    					<left offset="15" />
    					<right offset="-20" />
    					<bottom offset="-15" />
    				</anchored>
    			</list_defenses>
    			<scrollbar>
    				<anchored to="defenselist" />
    				<target>defenselist</target>
    			</scrollbar>
    
    
    			<button_iedit name="defenselist_iedit">
    				<anchored to="defenselist" position="aboveright" offset="5,10" />
    				<target>defenselist</target>
    			</button_iedit>
    			<button_iadd name="defenselist_iadd">
    				<anchored to="defenselist_iedit" position="lefthigh" offset="5,0" />
    				<target>defenselist</target>
    			</button_iadd>
    xxx

    I then duplicated the "record_char_inventory.xml" file to "record_char_defenses.xml" file and changed the windowclass name as follows;
    Code:
    	<windowclass name="ship_defenseitem">
    ...
    I copied "char_invlist.lua" to "ship_defenses.lua" and changed the update function to;
    Code:
    function update()
    	local bEditMode = (window.defenseslist_iedit.getValue() == 1);
    	window.idelete_header.setVisible(bEditMode);
    	for _,w in ipairs(getWindows()) do
    		w.idelete.setVisibility(bEditMode);
    	end
    end

    I added the includefile to base.xml;
    Code:
    	<includefile source="campaign/record_char_defenses.xml" />
    I wondered about an include for "ship_defenses.lua", but "char_invlist.lua" doesn't have one.

    I added the "list_defense" windowclass template to the "template_char.xml" as follows;
    Code:
    		<template name="list_defenses">
    		<windowlist>
    			<child></child>
    			<child><backcolor>1A40301E</backcolor></child>
    			<datasource>.defenses</datasource>
    			<class>ship_defenseitem</class>
    			<allowdelete />
    			<script file="campaign/scripts/ship_defenses.lua" />
    		</windowlist>
    But now I'm getting the following error when I click the edit button to add a new defense. Maybe I need to initialize a variable or create the database field or...? Anyway, my Find in Files has failed to indicate what I'm missing
    Script Error: [string "campaign/scripts/ship_defenses.lua"]:72: attempt to index field 'defenseslist_iedit' (a nil value)
    Help would be appreciated, as I've spent an hour plus on just this error

    Current Projects: Ultimate Undermountain (NYDUM)
    Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets
    DMsGuild Content: Balance Disturbed (Adventure), Dungeon Room Descriptions
    FG Product Reviews: Virtual Scribe Reviews

  2. #2
    LordEntrails,

    (window.defenseslist_iedit.getValue() == 1);

    should be:

    (window.defenselist_iedit.getValue() == 1);

    extraneous "s"

  3. #3
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    GMT -7
    Posts
    7,917
    Blog Entries
    9
    *lol* Thanks Paul. See I would never make it professionally!

    I corrected that, but I'm still getting the error. Entries are created, so that is good (not sure it was doing that before). But the console still throws that error every time I click or add. I'll go back through and check it all and see if I can find whatever mistakes I made.

    Current Projects: Ultimate Undermountain (NYDUM)
    Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets
    DMsGuild Content: Balance Disturbed (Adventure), Dungeon Room Descriptions
    FG Product Reviews: Virtual Scribe Reviews

  4. #4
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    18,878
    Blog Entries
    1
    Use Find in Files and search for:

    defenseslist
    defenseslist_iedit
    _iedit

    and see if you can track it down.

    MoreCore - Generic Ruleset
    --- Projects ---
    Extensions | Tutorials | MoreCore | MoreCore Themes | Call of Cthulhu | Maelstrom | FG Con

  5. #5
    Is the script error still :Script Error: [string "campaign/scripts/ship_defenses.lua"]:72: attempt to index field 'defenseslist_iedit' (a nil value)

    or

    did it at least change to: Script Error: [string "campaign/scripts/ship_defenses.lua"]:72: attempt to index field 'defenselist_iedit' (a nil value)

    ?

    Just curious. If it changed then we need to figure out why the defenselist_iedit is returning nil and not a value as expected. If it is the same error, then as damned said, there is another misspelling somewhere.

  6. #6
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    GMT -7
    Posts
    7,917
    Blog Entries
    9
    Should have clarified. It's the same message except it's now line 73. i.e.
    Code:
    window.idelete_header.setVisible(bEditMode);
    I've got to go to work, so I will track this down tonight when I get home. Thanks to both of you. I'll let you know tonight if I'm still stuck or what the solution is.
    Appreciate it

    Current Projects: Ultimate Undermountain (NYDUM)
    Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets
    DMsGuild Content: Balance Disturbed (Adventure), Dungeon Room Descriptions
    FG Product Reviews: Virtual Scribe Reviews

  7. #7
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    GMT -7
    Posts
    7,917
    Blog Entries
    9
    I can't figure it out, but I do have a thought that maybe someone can help me figure out.

    The error is;
    Script Error: [string "campaign/scripts/ship_defenses.lua"]:73: attempt to index field 'idelete_header' (a nil value)
    Script Error: [string "campaign/scripts/ship_defenses.lua"]:73: attempt to index field 'idelete_header' (a nil value)
    Line 73 is the "window.idelete" part of;
    Code:
    function update()
    	local bEditMode = (window.defenselist_iedit.getValue() == 1);
    	window.idelete_header.setVisible(bEditMode);
    	for _,w in ipairs(getWindows()) do
    		w.idelete.setVisibility(bEditMode);
    	end
    end
    But I think the actual problem comes from the 'record_char_defenses.xml' where I define the windowclass 'defenselist'. I thought I could just duplicate the default windowclass and give it the new name and leave everything internal to it the same (until I figure out how to remove/add fields to my desire), but maybe that's not right? Here's the complete code for the windowclass, if I'm right as to what needs to be updated. But I'm clueless of what inside of here would need to be changed.
    Code:
    	<windowclass name="ship_defenseitem">
    		<margins control="0,0,0,2" />
    		<script>
    			function onInit()
    				getDatabaseNode().onDelete = onDelete;
    			end
    			function onDelete(node)
    				ItemManager.onCharRemoveEvent(node);
    			end
    		</script>
    		<sheetdata>
    			<hidden_record_isidentified name="isidentified"><class>item</class><ignorehost /></hidden_record_isidentified>
    
    
    			<number_charinv name="count">
    				<bounds>5,2,20,20</bounds>
    				<tabtarget next="name" />
    				<default>1</default>
    			</number_charinv>
    
    
    			<genericcontrol name="rightanchor">
    				<anchored width="0" height="0">
    					<top />
    					<right />
    				</anchored>
    				<invisible />
    			</genericcontrol>
    			<button_idelete name="idelete">
    				<anchored width="20" height="20">
    					<top offset="2" />
    					<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
    				</anchored>
    			</button_idelete>
    			<linkcontrol_id name="shortcut">
    				<anchored width="20" height="20">
    					<top offset="2" />
    					<right parent="rightanchor" anchor="left" relation="relative" offset="-2" />
    				</anchored>
    				<class>item</class>
    				<readonly />
    			</linkcontrol_id>
    			<button_char_inv_carried name="carried">
    				<anchored width="20" height="20">
    					<top offset="2" />
    					<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
    				</anchored>
    			</button_char_inv_carried>
    			<number_charinv name="weight">
    				<anchored width="30" height="20">
    					<top offset="2" />
    					<right parent="rightanchor" anchor="left" relation="relative" offset="-10" />
    				</anchored>
    				<delaykeyupdate />
    				<tabtarget prev="location" />
    			</number_charinv>
    			<string_charinvloc name="location">
    				<anchored width="80" height="20">
    					<top offset="2" />
    					<right parent="rightanchor" anchor="left" relation="relative" offset="-10" />
    				</anchored>
    				<tabtarget next="weight" prev="nonid_name" />
    			</string_charinvloc>
    
    
    			<string_charinvname name="name">
    				<anchored position="insidetopleft" offset="35,2" height="20">
    					<right parent="rightanchor" anchor="left" relation="current" offset="-5" />
    				</anchored>
    				<tabtarget next="nonid_name" prev="count" />
    			</string_charinvname>
    			<string_charinvname name="nonid_name">
    				<anchored position="insidetopleft" offset="35,2" height="20">
    					<right parent="rightanchor" anchor="left" relation="current" offset="-5" />
    				</anchored>
    				<empty textres="library_recordtype_empty_nonid_item" />
    				<invisible />
    				<tabtarget next="location" prev="name" />
    			</string_charinvname>
    		</sheetdata>
    	</windowclass>

    Current Projects: Ultimate Undermountain (NYDUM)
    Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets
    DMsGuild Content: Balance Disturbed (Adventure), Dungeon Room Descriptions
    FG Product Reviews: Virtual Scribe Reviews

  8. #8
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    18,878
    Blog Entries
    1
    When you cant see it in the files you think it is - use find in files

    Things like button_idelete have a definition somewhere else - so find in files on that and see what comes up.

    And somewhere else might be in your code or in anything it is layered on.

    MoreCore - Generic Ruleset
    --- Projects ---
    Extensions | Tutorials | MoreCore | MoreCore Themes | Call of Cthulhu | Maelstrom | FG Con

  9. #9
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    GMT -7
    Posts
    7,917
    Blog Entries
    9
    I did Find in Files, I swear
    But I will look again tomorrow to see if I can find where it's defined
    Thanks for keeping me pointed in the right direction!

    Current Projects: Ultimate Undermountain (NYDUM)
    Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets
    DMsGuild Content: Balance Disturbed (Adventure), Dungeon Room Descriptions
    FG Product Reviews: Virtual Scribe Reviews

  10. #10
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    18,878
    Blog Entries
    1
    lets try another possible tack...

    is this your code?

    Code:
    function update()
    	local bEditMode = (window.inventorylist_iedit.getValue() == 1);
    	window.idelete_header.setVisible(bEditMode);
    	for _,w in ipairs(getWindows()) do
    		w.idelete.setVisibility(bEditMode);
    	end
    end
    try inserting:
    Debug.chat("bEditMode: ", bEditMode );
    at line 73.
    is it bEditMode that is nil?

    MoreCore - Generic Ruleset
    --- Projects ---
    Extensions | Tutorials | MoreCore | MoreCore Themes | Call of Cthulhu | Maelstrom | FG Con

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