Starfinder Playlist
  1. #1

    DB.handler trying to set DB value its watching

    I'm trying to set the state of something inside the handler that I'm actually watching and clicking on a button that triggers all this.

    Code:
    function onInit()
    	DB.addHandler("charsheet.*.inventorylist.*.carried", "onUpdate", onCarriedChanged);
    end
    
    function onCarriedChanged(nodeCarried)
    ... stuff to decide when to do this...
            DB.setValue(nodeCarried, "carried", "number", 2);
    ... stuff...
    end
    But even though it appears to work - it does not actually prevent the button from changing. In fact the logs show it comes back into this function with the button setting unaffected.

    Is there a way instead of trying to force a setting to "not happen" by overriding its DB entry directly like I am now - to simply set the button through code to what I want and somehow get it to work?

    There is some sort of sequence going on here that is preventing this from actually working - even though it appears to do it and immediately set it back to what it was heading for. In my case, preventing equipped from becoming unequipped.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  2. #2
    Never mind... solved it.

    Test chunk to prove I could do my elablorate logic here - not that I would ever get rid of 0!!!!

    Code:
    <root>
    	<windowclass name="char_invitem" merge="join">
    		<sheetdata>
    			<button_char_inv_carried name="carried" merge="join">
    				<script>
    					function onInit()
    						onValueChanged();
    					end
    					
    					function onValueChanged()
    						Debug.console(getValue());
    						if getValue() == 0 then
    							setValue(1);
    						end
    					end
    				</script>
    			</button_char_inv_carried>
    		</sheetdata>
    	</windowclass>
    </root>
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

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