-
May 30th, 2019, 21:36 #1
How to validate "databasenode = { }"
I've a bit of code that I need to check the value of a node.
Code:Runtime Notice: s'manager_effect.lua' | s'adnd_processEffect' | s'nodeEffect' | databasenode = { }
The best way I could figure out was to do this.
Code:-- check if effect still exists. removed in fCustomOnEffectActorStartTurn() probably -- we check the .getPath() through pcall and if it fails then just end this run. if not pcall(function () nodeEffect.getPath() end) then Debug.console("manager_effect_adnd.lua","adnd_processEffect","nodeEffect removed in-line",nodeEffect); return; end
Is there a better way to handle this or is this the best?
The reason this happens... is during the effects processing on a players turn, they might "die" from "DMGO" effects. If that happens, in the manager_action_damage code I remove the DMGO effect (this is part of death's door for AD&D) but when it comes back here from running the custom function the effect is gone... so I test for it and continue or end this effects loop as necessary.
I could just leave the effect on the dead player and let it keep ticking and make my life easier but this does what I want (allows me to remove the effect and then apply a dead effect on them). I'm considering going that way because I had to override a bit of CoreRPG code to do this...---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
May 30th, 2019, 21:49 #2
So, it's a LUA table. Maybe check for an empty table? A quick google gives this as a possible solution (the one with the green check mark): https://stackoverflow.com/questions/...ins-no-entries
Using if next(myTable) == nil thenPrivate Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
May 30th, 2019, 21:54 #3
I had actually tried that (tho I wasn't hopeful) and the error when trying that was....
Code:Runtime Notice: Reloading ruleset Script Error: [string "scripts/manager_effect_adnd.lua"]:564: bad argument #1 to 'next' (table expected, got userdata)
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
May 30th, 2019, 22:00 #4Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
May 30th, 2019, 22:05 #5---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
May 30th, 2019, 22:15 #6
Yeah, then you're left to variations on what you're doing. How about DB.getType(nodeEffect) - what does that return?
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
May 30th, 2019, 22:18 #7---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
May 30th, 2019, 22:20 #8
Looks like your code is good enough then!
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
May 30th, 2019, 22:23 #9
Heh, was hoping someone had a better idea than that.
It would be useful if we had a DB.exists(nodeEffect) or similar function perhaps.
After all this I think I might just pull it all out and just leave the effect on the dead character. In the long run I think it'll be better that I don't override CoreRPG code (in this case EffectManager.processEffect()).---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
June 1st, 2019, 05:42 #10
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
How are you getting a node with no path? Was it deleted during the script?
JPG
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks