PDA

View Full Version : Stored Script



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)

joshuha
August 28th, 2007, 18:18
No but the devs have acknowledged they are working on ways to include this type of functionality. The issue is while something nice and discrete like a card dealer works fine in a module, what about just simple changes to the charactersheet, or chatmanager chat functions? These will inheritently overwrite base files in the ruleset and thus need some sort of plugin manager. While the base d20 ruleset wouldn't be hard to implement as its fixed files its get to be a bit of an issue if you want to include multiple enhancements to the same source.

Say I find a cool enhancement to roll skillchecks from the sheet. I include that. Now I found one that lets me specify different base skills or another column on the skill sheets, if I include that does it overwrite the other one (if its something as simple as file replacement). Designing a plugin system that accomdates that would be difficult without some sort of managemenet system for both the users AND the developers. Something like function overriding where devs can write their functions and allow them to be overrided and player can pick which functions/enhancements they want. It would need to detect conflicts in multiple plugins overriding the same function/feature and let the user choose which one he wanted in that case.