DICE PACKS BUNDLE
Page 1 of 2 12 Last
  1. #1
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075

    SOLVED: My extension based on OldSchoolEssentials/MoreCore/CoreRPG question

    I have to run to dinner and then more Taxes, so figured toss this out to see if anyone had a tip for me so when get back to it very late tonight, I might be able to blow past it.


    Whenever I hit the icons for modifiers or effects in sidecar (used all MCOSR_Theme (copied in) big sidecar buttons but for now CoreRPG for the small ones) I get:

    Code:
    Script Error: [string "list"]:1: attempt to call field 'onInit' (a nil value)
    Database Notice: Campaign saved.
    Ruleset Warning: window: Anchored static height ignored for control (pcclasslink) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static height ignored for control (pcclasslink) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static height ignored for control (pcclasslink) in windowclass (charsheet)
    Script Error: [string "list"]:1: attempt to call field 'onInit' (a nil value)

    The respective windows open, but the console pops up as such. (I haven't coded anything relating to modifiers or effects so if there needs to be base calls - haven't done them yet).
    Last edited by Varsuuk; July 13th, 2020 at 04:20.

  2. #2

  3. #3
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    Found it - has nothing to do with anything anyone but me would have done wrong but when I understand it Morel and the fix later on today - will update this post.

  4. #4
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    Ah Thanks Damned, (I posted mine before seeing your reply) - No, it was my override of list_text. I was about to try to find and trace what happens when those two buttons are called but decided to do more hit and miss testing and commented out my override and the problem went away.


    So, realized my assumption that it "works" was wrong and realize what did wrong too I think - I had thought it tested since I tried two different controls one with and one without the field I added and both worked right. But it's a mistake in merge= option. I needed "join" I think, checking now.

    EDIT: Nope, hairier than that. Grrr... will be bit longer

  5. #5
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    I'm guessing this is a big "nope" but gonna toss it out there.

    So, I tried to change sort by and it worked, but I didn't want to do it via sortby because even if I did:
    Code:
    			<script name="alt_sort_order">
    				function onSortCompare(w1, w2)
    					return DB.getValue(w1.getDatabaseNode(), "alt_sort_order", DB.getValue(w1.getDatabaseNode(), "name", ""))
    					  > DB.getValue(w2.getDatabaseNode(), "alt_sort_order", DB.getValue(w2.getDatabaseNode(), "name", ""))
    				end
    This allows for the case where for some reason w1 has the proper alt_sort_order set and w2 doesn't - so it would compare alt_sort_order field against name field.

    And since I did not know a way (yet) to change one specific instance of list_text into using a different sort, I tried updating list_text itself to using my onSortCompare which apparently, since it is a "<script" will hide the earlier assigned list_text.lua script (which has onInit() for example) so I am LUCKY this bug reared right here early on.

    My two choices as I see it (so far) are:
    1. Copy entire list_text.lua code from CoreRPG into my own with the new sortCompare (depending on how called elsewhere it MIGHT work)
    2. Find a way to take an "instance" of list_text defined in MoreCore (for example, cliroller) and modify it with just the sortby change which in the case that I know it SHOULD have alt_sort_by, it is OK to missort if it is missing.

    probably more, but it's a new thing I am looking at for me.

  6. #6
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    So, if I step back from my attempts at implementation and describe the problem more generally:

    I have a control in MoreCore, (e.g., <list_text name="cliroller1"> ) where I would like to have it sort on a field, alt_sort_order IF and only if the field is present (preferably in both, but "works" as long as one of them has it. And to sort (as is usual default) on "name" field if the sort field is not present.


    Like, I want Str, Dex, Con...Char order vs Char,Con,Dex,...Wis order. And in later case, the OSE example "damage" rolling list to put d10 at end instead of top (where d10 < d4 lexically...)

    I'd LOVE to ask more in chat if anyone is on discord and can chat and who understands what I mean and might have tips on what I should read?

  7. #7
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    Tested #1, copying:
    Code:
    				function onSortCompare(w1, w2)
    					local node1AltSortOrder = DB.getValue(w1.getDatabaseNode(), "alt_sort_order")
    					local node2AltSortOrder = DB.getValue(w2.getDatabaseNode(), "alt_sort_order")
    
    					if node1AltSortOrder ~= nil and node2AltSortOrder ~= nil then
    						return node1AltSortOrder > node2AltSortOrder
    					else
    						return DB.getValue(w1.getDatabaseNode(), "name") > DB.getValue(w2.getDatabaseNode(), "name")
    					end
    				end
    into text_list.lua copy in my extension directory. As expected this works... but is a HORRIBLE way to go since it means I need to keep updating it each time CoreRPG is updated.

    Basically, I am trying to either add a method or <script> entry without obliterating the existing script (which does not define onSortCompare() so no issues) or I want to just modify <sortby> on a specific instance of a MoreCore object. Perhaps on my extension's init.

  8. #8
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    Quote Originally Posted by damned View Post
    have you named anything list or onInit?

    Interestingly, the control is called list_text, which comes from windowlist - but "list" is what the error message prints.

  9. #9
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    Screen Shot 2020-07-12 at 11.22.08 PM.png
    Above shows attributes not sorting automatically in alpha, i.e. Char, Con, Dex, etc instead it is Str, Dex, Con, etc.
    Also, you will see that D10 in damage section is last instead of the default, first, on the list.


    [EDIT: Note, not seeing the errors on the sidebar and it is sorting properly, so for now assuming I got it right - if I find a reason why it isn't working or any side-effects, I will update this thread so I do not give misinformation.]


    OK - Figured out how to update the sortby for a specific named instance in my extension:

    (I'm sure it's trivially obvious, but I had never worked on modifying this sort of generic all purpose control before, putting here in case helps anyone)

    Code:
    <root>
    	<!-- New WindowClass "charsheet_more" -->
    	<windowclass name="charsheet_more" merge="join">
    		<sheetdata>
    
    			<!-- Customize sorting for the Attributes list -->
    			<list_text name="cliroller1" mege="join">
    				<script>
    					function onSortCompare(w1, w2)
    						local node1AltSortOrder = DB.getValue(w1.getDatabaseNode(), "alt_sort_order")
    						local node2AltSortOrder = DB.getValue(w2.getDatabaseNode(), "alt_sort_order")
    
    						if node1AltSortOrder ~= nil and node2AltSortOrder ~= nil then
    							return node1AltSortOrder > node2AltSortOrder
    						else
    							return DB.getValue(w1.getDatabaseNode(), "name") > DB.getValue(w2.getDatabaseNode(), "name")
    						end
    					end
    				</script>
    			</list_text>
    			
    			<!-- Customize sorting for the Melee Damage list -->
    			<list_text name="cliroller2a" mege="join">
    				<script>
    					function onSortCompare(w1, w2)
    						local node1AltSortOrder = DB.getValue(w1.getDatabaseNode(), "alt_sort_order")
    						local node2AltSortOrder = DB.getValue(w2.getDatabaseNode(), "alt_sort_order")
    
    						if node1AltSortOrder ~= nil and node2AltSortOrder ~= nil then
    							return node1AltSortOrder > node2AltSortOrder
    						else
    							return DB.getValue(w1.getDatabaseNode(), "name") > DB.getValue(w2.getDatabaseNode(), "name")
    						end
    					end
    				</script>
    			</list_text>
    			
    			<!-- Customize sorting for the Ranged Damage list -->
    			<list_text name="cliroller3a" mege="join">
    				<script>
    					function onSortCompare(w1, w2)
    						local node1AltSortOrder = DB.getValue(w1.getDatabaseNode(), "alt_sort_order")
    						local node2AltSortOrder = DB.getValue(w2.getDatabaseNode(), "alt_sort_order")
    
    						if node1AltSortOrder ~= nil and node2AltSortOrder ~= nil then
    							return node1AltSortOrder > node2AltSortOrder
    						else
    							return DB.getValue(w1.getDatabaseNode(), "name") > DB.getValue(w2.getDatabaseNode(), "name")
    						end
    					end
    				</script>
    			</list_text>
    			
    			<!-- Change Health to HP -->
    			<string_useredit name="pc_label_health" merge="join">
    				<default>Hit Points</default>
    			</string_useredit>
    Last edited by Varsuuk; July 13th, 2020 at 04:25. Reason: Added image

  10. #10
    Just FYI in your code, several of the items have the word "merge" spelled wrong:
    Code:
    mege="join"
    instead of
    Code:
    merge="join"

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 Character Create Playlist

Log in

Log in