PDA

View Full Version : Player-side scripting questions



Vlek
May 15th, 2013, 21:30
Hello everyone, first time poster.

I was wondering if it was possible to create a script, only available to me, which would perform things with the information that I have full access to as only a player.

Some things that come to mind are basic calculators, and things that watch the message feed for certain events.

Now, I know one can make modules and package them, but is there a way to inject smaller scripts and run them regardless of the module?

Thanks

Trenloe
May 16th, 2013, 00:16
Now, I know one can make modules and package them, but is there a way to inject smaller scripts and run them regardless of the module?
Yes there is, these are called extensions: https://www.fantasygrounds.com/modguide/extensions.xcp Extensions are ruleset specific

FYI - "modules" are actually packages containing either scenario data, library data or other "campaign" type data. Only extensions modify the base Fantasy Grounds ruleset code that they are running on top of.

To do what you want to do, the GM who would have to enable any extension that has been written - all code comes down from the GM: the base ruleset and any extensions. You cannot, as a player, add on extra code from your side it has to be the GM.

But, if you write code in an extension for a specific ruleset and tie it to a certain username, and your GM activates the extension for a game you play in, then whoever joins the game with the username specified in the extension would have access to whatever was coded in the extension for that username.

gmkieran
May 16th, 2013, 15:06
Trenloe, I was unaware that extensions could be made that specific. Are there limitations on what types of extensions that can be done with? For instance, could I create a separate desktop for each of my players (don't know why I'd want to, but as an example)? How would I declare a specific username for the extension when writing it?

Cheers!
GMK

Trenloe
May 16th, 2013, 16:03
Trenloe, I was unaware that extensions could be made that specific. Are there limitations on what types of extensions that can be done with? For instance, could I create a separate desktop for each of my players (don't know why I'd want to, but as an example)? How would I declare a specific username for the extension when writing it?
By using the User.getUsername function: https://www.fantasygrounds.com/refdoc/User.xcp#getUsername you can return the username of the logged in user. So, something like the following could be used:


if User.getUsername() == "Trenloe" then
-- Run code specific to the user Trenloe
end
You are limited to changes you can make with LUA code - default layouts, window sizes, desktop layouts etc. are defined in XML. Some of these you can change with code some you can't. For example, you can change the graphics used for the buttons down the right side of the desktop with code, but I don't think you can change the underlying graphic file (desktop.png) used.

Vlek
May 17th, 2013, 22:41
Thank you for that link to what appears to be the standard library. I was wondering if there was a way to have an extension listen in to the chat window and, if the player desired, store the data somewhere else to be retrieved if they wish to add upon what they did last game.

I'm asking because A: It does not appear as though there are pre-setup ways of capturing, aside from onRecieveMessage, the information I'm looking for (This wouldn't be able to capture what the player does, only what his party does).

B: Lua isn't allowed to touch outside files, so I am unsure about how to go about giving my extension a save and options file. I am guessing I should pack it in with the scripts and call it in my extension .xml?

Trenloe
May 19th, 2013, 17:33
Thank you for that link to what appears to be the standard library. I was wondering if there was a way to have an extension listen in to the chat window and, if the player desired, store the data somewhere else to be retrieved if they wish to add upon what they did last game.

I'm asking because A: It does not appear as though there are pre-setup ways of capturing, aside from onRecieveMessage, the information I'm looking for (This wouldn't be able to capture what the player does, only what his party does).

B: Lua isn't allowed to touch outside files, so I am unsure about how to go about giving my extension a save and options file. I am guessing I should pack it in with the scripts and call it in my extension .xml?
I think you've hit on the main two issues above.

Quick solution: a transcript of all of the campaign chat window entries is saved on the GMs PC as an HTML file - chatlog.html in the campaign directory. This will give you all the info that is displayed in the chat window. As your GM to send you a copy. If the GM wants to hide some info, like the BBEG's attack rolls, then they can use the community chatlog scrubber to remove certain items: https://www.fantasygrounds.com/forums/showthread.php?t=8133

Other options: as you mentioned in a PM to me, you can get the msg.text from the onReceiveMessage and onDeliverMessage events. The problem you then have is how do you filter them and, more importantly, where do you store the info? Probably the best place to store the info on the player side is as one or more "notes" entries in the campaign DB. It really has to be in the DB where a player can access it and the best place for this is probably notes - as you've noted, the FG LUA is restricted from accessing files locally on the PC.