Starfinder Playlist
  1. #1

    Join Date
    Nov 2008
    Location
    Surrey, England
    Posts
    273

    Problems Deleting Windowinstance

    Happy New Year one and all!

    I am having problems trying to program a windowlist to automatically delete entries once their values hit zero. My code for the windowclass is below. At the moment, FG crashes once I adjust the value of a wound entry to zero, presumably because I am creating an infinite loop with the if getValue() == 0 statement. Any pointers anyone?

    Code:
     <windowclass name="charsheet_woundlistitem">
      <sizelimits>
       <minimum>
        <height>30</height>
        <width>0</width>
       </minimum>
      </sizelimits>
      <sheetdata>
       <number_dropadd name="wound">
        <droptypes>
         <type merge="add">damage</type>   
        </droptypes> 
        <bounds>5,6,22,16</bounds>
        <min>0</min>
        <script>
         local bProcessing = false;
         
         function onValueChanged()
          if bProcessing then
           return;
          end
          bProcessing = true;
          if getValue() == 0 then
           window.getDatabaseNode().delete();      
          end
          bProcessing = false;
         end
        </script> 
       </number_dropadd>  
      </sheetdata>
     </windowclass>

  2. #2
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    is it possible its the delete that it doesnt like - try changing that action to something else?
    window.getDatabaseNode().delete();

  3. #3

    Join Date
    Nov 2008
    Location
    Surrey, England
    Posts
    273
    Thx damned, but no joy I'm afraid. I tried window.getDatabaseNode().destroy(); as well, but that gives an attempt to call field 'destroy' (a nil value) script error

  4. #4
    There's similar logic in the code that removes effects after they are decremented in both the 3.5E and 5E rulesets.

    My guess is that deleting the source database node in the onValueChanged event causes the crash. You'll most likely have to capture at a different level using a DB.addHandler call. There are also several examples of these calls in the 3.5E and 5E rulesets.

    Regards,
    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
  •  
5E Character Create Playlist

Log in

Log in