Thread: Problems Deleting Windowinstance
-
January 1st, 2016, 11:13 #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>
-
January 2nd, 2016, 11:33 #2
is it possible its the delete that it doesnt like - try changing that action to something else?
window.getDatabaseNode().delete();
-
January 2nd, 2016, 12:45 #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
-
January 3rd, 2016, 01:21 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,561
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