DICE PACKS BUNDLE
  1. #1

    dynamic list, multiple entries, stumped

    So, bird's eye view of what I am trying to do... I am using the 5e ruleset as base, specifically the actions tab with weapons. Weapons can have multiple damage dice types set but when you roll them they all roll at once. In AD&D there isn't much call for that but there is a need to have damage differences depending on the size of the creature.

    So, my current task is to tweak the existing 5e ruleset actions tab/weapons/damage blocks to list individually so the user can double click (or drag) to perform the action/Damage rolls for a specific set of dice rolls that 5e already allows you to set. So instead of rolling 1d6+3 and 1d4 like 5e uses it will roll one or the other depending on the one double clicked.

    Sounds simple but I've been reviewing other parts of the rulesets that do similar tasks but I can't seem to wrap my head around it and get it working. It's probably some anchor part I'm just not getting right... as I've said before layout stuff just really is my bane.

    All I see at this point is this tiny blip on the tab (this character has 3 dice groups setup, you can see 3 lines). I can't seem to figure out how to get the view space visible.



    I've looked over the docs as best I can but I'm a "see an example and then do it" sorta person.

    I've created a windowclass (cobbled this together reviewing other similar tasks)

    Code:
    	<windowclass name="split_damage_entries">
            <margins control="0,0,0,5" />
       		<sheetdata>
    			<genericcontrol name="rightanchor">
    				<anchored width="0" height="0">
    					<top offset="2" />
    					<right />
    				</anchored>
    				<invisible />
    			</genericcontrol>
                <stringcontrol name="damageasstring">
    				<anchored to="rightanchor">
    					<top anchor="bottom" offset="0" />
    					<left />
    					<right />
    					<bottom parent="" offset="" />
    				</anchored>
    				<multilinespacing>20</multilinespacing>
    				<frame name="fielddark" offset="7,8,7,8" />
    				<stateframe>
    					<hover name="rowshade" offset="7,8,7,8" />
    				</stateframe>
    				<cursor hover="hand" />
    				<readonly />
    				<script>
    					function onDoubleClick(x,y)
    						return onDamageActionSingle();
    					end			
    
    					function onDragStart(button, x, y, draginfo)
    						return onDamageActionSingle(draginfo);
    					end
                                            function onDamageActionSingle(draginfo)
                                                   Debug.console("record_char_weapon.xml","onDamageActionSingle","draginfo",draginfo);
                                           end
    				</script>
    	  </stringcontrol>
            </sheetdata>
        </windowclass>
    And then I replaced the current display xml code for damageview with

    Code:
                <windowlist name="damage_split_list">
    				<anchored to="rightanchor" width="91">
    					<top offset="8" />
     					<right anchor="left" relation="relative" offset="-5" /> 
    				</anchored>
    				<datasource>.damagelist</datasource>
    				<class>split_damage_entries</class>
                </windowlist>
    If you have any suggestions and recommendations please do point them out
    Last edited by celestian; March 7th, 2017 at 22:52.

  2. #2
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    -7 UTC
    Posts
    17,273
    Blog Entries
    9
    Hmm, what about approaching it from an effects standpoint? Rather than the player selecting the size of the opponent, do something like an IF statement to evaluate if the target is small, medium/large? Don't know if that would be any easier, but, thought I would mention it.

    Problems? See; How to Report Issues, Bugs & Problems
    On Licensing & Distributing Community Content
    Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets, Balance Disturbed, Dungeon Room Descriptions
    Note, I am not a SmiteWorks employee or representative, I'm just a user like you.

  3. #3
    Quote Originally Posted by LordEntrails View Post
    Hmm, what about approaching it from an effects standpoint? Rather than the player selecting the size of the opponent, do something like an IF statement to evaluate if the target is small, medium/large? Don't know if that would be any easier, but, thought I would mention it.
    That is a good idea and I think I will steal it if the player has a target. If the player is just rolling dice w/o target however they still need to be able to choose which set of dice to use still ;(

  4. #4
    I'm no expert on this, but I've had my battles with anchoring. It would help if you had a concept mock-up so we know what you want things to look like. I'm just guessing at this point.

    But here is something I did notice. In the stringcontrol damageasstring, try this anchor:
    Code:
    				<anchored>
    					<top />
    					<left parent="rightanchor" anchor="right" relation="relative" />
    					<right />
    				</anchored>
    I've never gotten the 'to' part of the anchor to work. Instead, I find it easier to deal with each side of the control separately. You only need three anchor points (with height and width counting as one each). So ignore the bottom anchor. The left anchor is noted as attached to the genericcontrol (instead of noting the entire control is attached). The use of the 'relation' property is very important as this is what causes your anchors to grow.

    Likewise for the windowlist, try this anchor:
    Code:
    				<anchored width="91">
    					<left parent="rightanchor" anchor="right" relation="relative" />
    					<top offset="8" />
     				</anchored>
    Since you have a width, the right anchor isn't as important. The left anchor is again attached to the rightanchor genericcontrol, but since the previous anchor was 'relative', the genericcontrol grew to include the width of the stringcontrol.

    Of course, I'm guessing that these control are horizontal. If they are different, then shift the anchor information around. Again, a concept image would help.
    I never claimed to be sane. Besides, it's more fun this way.

  5. #5
    The way that the anchored.to attribute works is that it assigns its value to every anchor tag.

    In the case celestian published, that means every anchor (top, left, right, bottom) is set to match the rightanchor except the bottom one. However, in this case, you don't want the bottom anchor to be set, since you want the field to expand to show all the values; and you already have multilinespacing set to 20 to allow multiple lines to be displayed.

    Also, since the stringcontrol is mapped explicitly to the rightanchor, which has a zero width and zero height; therefore, the stringcontrol has a zero width and zero height. All you will see are the frame edges overlapping.

    It should probably look more like this:
    Code:
                <stringcontrol name="damageasstring">
    				<anchored to="rightanchor">
    					<top  />
    					<left parent="" offset="2" />
    					<right anchor="left" offset="-2"/>
    					<bottom parent="" offset="" />
    				</anchored>
    				<multilinespacing>20</multilinespacing>
    				...
    Regards,
    JPG

  6. #6
    Quote Originally Posted by Moon Wizard View Post
    The way that the anchored.to attribute works is that it assigns its value to every anchor tag.

    In the case celestian published, that means every anchor (top, left, right, bottom) is set to match the rightanchor except the bottom one. However, in this case, you don't want the bottom anchor to be set, since you want the field to expand to show all the values; and you already have multilinespacing set to 20 to allow multiple lines to be displayed.

    Also, since the stringcontrol is mapped explicitly to the rightanchor, which has a zero width and zero height; therefore, the stringcontrol has a zero width and zero height. All you will see are the frame edges overlapping.

    It should probably look more like this:
    Code:
                <stringcontrol name="damageasstring">
    				<anchored to="rightanchor">
    					<top  />
    					<left parent="" offset="2" />
    					<right anchor="left" offset="-2"/>
    					<bottom parent="" offset="" />
    				</anchored>
    				<multilinespacing>20</multilinespacing>
    				...
    Regards,
    JPG
    So, I tried the above and it did make the display widened which was great but it was a thin little text bubble you couldn't see. So, I fiddled around and eventually when I added an offset of 15 to the <bottom parent="" /> it opened it up enough to see. Probably the wrong way to do it? I also removed the multilinespacing because it seemed to squish the text and it would clip parts of the numbers off the bottom/top. Could be I need to fiddle with the height but for now I just disabled to get to the meat of the tests.

    The confusing bit now is no text shows in those boxes. It does add/remove the empty boxes if I add a damage dice type or remove it but doesn't fill it in. The damageasstring variable appears in the associated damagelist xml for what it's worth. I did some tinkering and I was able to force it to set the value by using a script in onInit.

    Code:
                <stringcontrol name="damageasstring">
                    <script>
                        function onInit()
                            local nodeSelf = window.getDatabaseNode();
                            Debug.console("record_char_weapon.xml","split_damage_entries","nodeSelf",nodeSelf);
                            local sTest = DB.getValue(nodeSelf,"damageasstring","");
                            setValue(sTest);
                        end
                        function onDoubleClick(x,y)
                            Debug.console("record_char_weapon.xml","split_damage_entries","window",window);
                            Debug.console("record_char_weapon.xml","split_damage_entries","self",self);
                            return window.onDamageActionSingle();
                        end			
    
                        function onDragStart(button, x, y, draginfo)
                            return window.onDamageActionSingle(draginfo);
                        end
                    </script>
    ...
    Obviously that will not help when you update/change but I was wondering if it could even find the "damageasstring" variable... which it could based on the above test.

    I also tried setting the source="damageasstring" and it didn't help.

    I looked at "char_weapon_damage_entry" which is the windowclass that adds/removes damage/dice fields and honestly I don't see the difference in the way it is setup and the above.

    I'll repost what I have now so far.

    The windowlist, within the char_weapon windowclass.

    Code:
                <windowlist name="damage_split_list">
    				<anchored to="rightanchor" width="91">
    					<top offset="8" />
     					<right anchor="left" relation="relative" offset="-5" /> 
    				</anchored>
    				<datasource>.damagelist</datasource>
    				<class>split_damage_entries</class>
                </windowlist>
    The split_damage_entries window class:
    Code:
       <!-- window, display damage rolls, each in their own clickable to have s/m and large damage types -->
    	<windowclass name="split_damage_entries">
            <margins control="0,0,0,5" />
       		<sheetdata>
    			<genericcontrol name="rightanchor">
    				<anchored width="0" height="0">
    					<top offset="2" />
    					<right />
    				</anchored>
    				<invisible />
    			</genericcontrol>
                <stringcontrol name="damageasstring">
                    <script>
                        function onInit()
                            local nodeSelf = window.getDatabaseNode();
                            Debug.console("record_char_weapon.xml","split_damage_entries","nodeSelf",nodeSelf);
                            local sTest = DB.getValue(nodeSelf,"damageasstring","");
                            setValue(sTest);
                        end
                        function onDoubleClick(x,y)
                            return window.onDamageActionSingle();
                        end			
    
                        function onDragStart(button, x, y, draginfo)
                            return window.onDamageActionSingle(draginfo);
                        end
                    </script>
    				<anchored to="rightanchor">
                                            <top  />
    					<left parent="" offset="2" />
                                            <right anchor="left" offset="-2"/>
                                            <bottom parent="" offset="15" />				
                                    </anchored>
    				<frame name="fielddark" offset="7,8,7,8" />
    				<stateframe>
    					<hover name="rowshade" offset="7,8,7,8" />
    				</stateframe>
    				<cursor hover="hand" />
    				<readonly />
    	   </stringcontrol>
            </sheetdata>
        </windowclass>
    A secondary thing I noticed is that when the window.onDamageActionSingle() call is triggered I get"Script Error: [string "split_damage_entries:damageasstring"]:1: attempt to call field 'onDamageActionSingle' (a nil value)" which I am guessing is because I can't reference the window.script functions? The cause of that is is probably the same reason damageasstring isn't getting set but I'm still bumbling around trying to find out why.

    Gonna sleep on it and poke some more at it tomorrow.

  7. #7
    So, partial success today. I decided to go step by step through a known working windowclass and compare. I got down to the method I used to display the dice string and when I switched from "stringcontrol " to "stringfield" ... low and behold the "damageasstring" value was being used.

    Now I just need to sort out how to access the script from char_weapon within the windowclass split_damage_entries so I can do something like this in the script portion (window.function calls) actually work.

    Code:
    		<stringfield name="damageasstring">
                    <script>
                        function onDoubleClick(x,y)
                            Debug.console("record_char_weapon.xml","split_damage_entries","window",window);
                            Debug.console("record_char_weapon.xml","split_damage_entries","self",self);
                            return window.onDamageActionSingle();
                        end			
    
                        function onDragStart(button, x, y, draginfo)
                            return window.onDamageActionSingle(draginfo);
                        end
                    </script>
                    <anchored to="rightanchor">
                        <top  />
                        <left parent="" offset="2" />
                        <right anchor="left" offset="-2"/>
                        <bottom parent="" offset="15" />				
                    </anchored>
                    <frame name="fielddark" offset="7,8,7,8" />
                    <stateframe>
                        <hover name="rowshade" offset="7,8,7,8" />
                    </stateframe>
                    <cursor hover="hand" />
                    <readonly />
    		</stringfield>
    Last edited by celestian; March 8th, 2017 at 18:06.

  8. #8
    You should get rid of the bottom anchor completely. I was incorrect to include that, and it removes the ability for the control to expand vertically to fit the text. If you actually want a fixed size, use the anchored.height attribute instead.

    The reason why the "damageasstring" control is not displaying anything is because you are using "stringcontrol" which is a control which does NOT link to the database. You probably want to use "stringfield", which is exactly the same control but automatically links to the database and creates the correct database node. I see you just figured that out.

    For the script error, you are trying to reference the "window" variable within a windowinstance object (single instance of windowclass), which is not valid. Only window control objects (i.e. those contained in sheetdata) can access the "window" variable, and those call the script for the windowinstance. If you are trying to chain control/window references up, you'll need to use the "windowlist" variable for windows contained within windowlist controls, and the "parentcontrol" variable for windows contained within subwindow controls. If you are trying to chain control/window references down, you need to use the getWindows() function in windowlist controls to get all the child windowinstances, and use the "subwindow" variable in subwindow controls to get the single child windowinstance.

    For example, if you wanted to make a call to the parent weapon script from "damageasstring" field which is contained within a windowinstance (of the "split_damage_entries" windowclass) which is used by the "damage_split_list" windowlist control which is contained within the weapon windowinstance ("char_weapon" windowclass?), then you would use these variable chains to access the various objects from damageasstring:

    "window" -> "split_damage_entries" windowinstance
    "window.windowlist" -> "damage_split_list" control
    "window.windowlist.window" -> "char_weapon" windowinstance

    Regards,
    JPG

  9. #9
    Quote Originally Posted by Moon Wizard View Post
    You should get rid of the bottom anchor completely. I was incorrect to include that, and it removes the ability for the control to expand vertically to fit the text. If you actually want a fixed size, use the anchored.height attribute instead.
    Indeed, removing that (and re-adding the multilinespacing field) works great!

    Quote Originally Posted by Moon Wizard View Post
    The reason why the "damageasstring" control is not displaying anything is because you are using "stringcontrol" which is a control which does NOT link to the database. You probably want to use "stringfield", which is exactly the same control but automatically links to the database and creates the correct database node. I see you just figured that out.
    Yeah I dunno why I used it to begin with. Woops!

    Quote Originally Posted by Moon Wizard View Post
    For the script error, you are trying to reference the "window" variable within a windowinstance object (single instance of windowclass), which is not valid. Only window control objects (i.e. those contained in sheetdata) can access the "window" variable, and those call the script for the windowinstance. If you are trying to chain control/window references up, you'll need to use the "windowlist" variable for windows contained within windowlist controls, and the "parentcontrol" variable for windows contained within subwindow controls. If you are trying to chain control/window references down, you need to use the getWindows() function in windowlist controls to get all the child windowinstances, and use the "subwindow" variable in subwindow controls to get the single child windowinstance.

    For example, if you wanted to make a call to the parent weapon script from "damageasstring" field which is contained within a windowinstance (of the "split_damage_entries" windowclass) which is used by the "damage_split_list" windowlist control which is contained within the weapon windowinstance ("char_weapon" windowclass?), then you would use these variable chains to access the various objects from damageasstring:

    "window" -> "split_damage_entries" windowinstance
    "window.windowlist" -> "damage_split_list" control
    "window.windowlist.window" -> "char_weapon" windowinstance

    Regards,
    JPG
    Thanks so much for that explanation. I kept trying to use variations that used char_weapon in the place of where I expected it to be a "window" class. Such as char_weapon.window.* . Also didn't realize windowlist was a viable use.

    Everything is working as expected now and I'll post the xml snippet incase anyone else ever searches the topic.

    Code:
        <!-- window, display damage rolls, each in their own clickable to have s/m and large damage types -->
    	<windowclass name="split_damage_entries">
            <margins control="0,0,0,5" />
       		<sheetdata>
    			<genericcontrol name="rightanchor">
    				<anchored width="0" height="0">
    					<top offset="2" />
    					<right />
    				</anchored>
    				<invisible />
    			</genericcontrol>
    		<stringfield name="damageasstring">
                    <script>
                        function onDoubleClick(x,y)
                            return window.windowlist.window.onDamageActionSingle();
                        end			
    
                        function onDragStart(button, x, y, draginfo)
                            return window.windowlist.window.onDamageActionSingle(draginfo);
                        end
                    </script>
                    <multilinespacing>20</multilinespacing>
                    <anchored to="rightanchor">
                        <top  />
                        <left parent="" offset="2" />
                        <right anchor="left" offset="-2"/>
                    </anchored>
                    <frame name="fielddark" offset="7,8,7,8" />
                    <stateframe>
                        <hover name="rowshade" offset="7,8,7,8" />
                    </stateframe>
                    <cursor hover="hand" />
                    <readonly />
    	        </stringfield>
    
            </sheetdata>
        </windowclass>
    Thanks so much for your help!

  10. #10
    Glad I had some time to help.

    Cheers,
    JPG

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
  •  
STAR TREK 2d20

Log in

Log in