Foen
August 28th, 2007, 18:07
Discussions on another thread (https://www.fantasygrounds.com/forums/showthread.php?t=7067) got me thinking about the possibility of storing script in a module, rather than just in a ruleset.
The advantage (other than just adding intelligent functionality to a module) would be the ability to extend existing rulesets without having to maintain forked code (the case in point was the potential introduction of card decks to an existing ruleset).
I first started by seeing if a script block could be added to db.xml and then executed (reasoning that if scripts could be added to the ruleset xml, there might be an undocumented chance that they would be accessible from database nodes). No dice it seems. :o
I then tried to add a function handler to the database node using its metatable, hoping to save the extended node back to the db. Again, no dice - the metatable functionality is pruned in FG Lua (beyond just the documented missing features). :(
I am left with the possibility of storing the script as a text field in db.xml, and trying to execute it following a loadstring command. This is also failing, as loadstring also appears absent (not just loadfile, per the documentation). :mad:
Has anyone had any success with this or something similar?
Cheers
Stuart
(Foen)
The advantage (other than just adding intelligent functionality to a module) would be the ability to extend existing rulesets without having to maintain forked code (the case in point was the potential introduction of card decks to an existing ruleset).
I first started by seeing if a script block could be added to db.xml and then executed (reasoning that if scripts could be added to the ruleset xml, there might be an undocumented chance that they would be accessible from database nodes). No dice it seems. :o
I then tried to add a function handler to the database node using its metatable, hoping to save the extended node back to the db. Again, no dice - the metatable functionality is pruned in FG Lua (beyond just the documented missing features). :(
I am left with the possibility of storing the script as a text field in db.xml, and trying to execute it following a loadstring command. This is also failing, as loadstring also appears absent (not just loadfile, per the documentation). :mad:
Has anyone had any success with this or something similar?
Cheers
Stuart
(Foen)