View Full Version : New Extension - Individual PC XP Awards (3.5E/PFRPG)
nickabbey
August 29th, 2016, 01:45
Greetings,
I've taken a crack at my first extension. It's not ready for primetime yet, so rather than include a link to the .ext, here is a link to the bitbucket repo where I'm tracking my work.
Why would I do such a thing?!
Because it's useless at the moment, and I'm fumbling my way through making it work.
Tracking the history of my attempts using a version control system like git is helpful to my learning process.
Any feedback, pointers or tips will be greatly appreciated.
https://github.com/nickabbey/Individual-PC-XP-Awards
The extension directory holds the actual extension, and I used the package.sh and deploy.sh scripts to deploy locally.
If you want to look at the code, you can browse it directly under the extension folder.
If you want to install the current packaged version, grab the individualXPawards.ext file in the root of the repository.
Current State:
Checkbox added to the Experience tab of the main character screen
Some code written
TODO:
Update the readme on the repo
Checkbox tooltip to describe why this random checkbox is floating on your main character tab
Add debug statements to my code so I can test if they are actually being executed and doing what I expect
SpiritofFire
September 8th, 2016, 20:34
Ooo looking forward to this. I've been wishing for a quick way to award xp rewards for rp or clever problem solving. Any chance of this working for 5e?
Gwydion
September 8th, 2016, 20:38
Ooo looking forward to this. I've been wishing for a quick way to award xp rewards for rp or clever problem solving. Any chance of this working for 5e?
Trenloe already has your back.
https://www.fantasygrounds.com/forums/showthread.php?27298-Extensions-Modules-Pregens-and-other-5E-resources
nickabbey
September 8th, 2016, 20:39
Ooo looking forward to this. I've been wishing for a quick way to award xp rewards for rp or clever problem solving. Any chance of this working for 5e?
is this (https://www.fantasygrounds.com/forums/showthread.php?33599-Individual-PC-XP-assignment-extension-for-d20-based-rulesets)what you're looking for?
It was the first thing I looked at when trying to figure out how I'd do this in 3.5/PFRPG
nickabbey
September 8th, 2016, 20:40
For what it's worth, I'm recently unemployed so figuring this out has been back burnered for a bit. I'm sure I'll need a distraction from the job search and will circle back to this soon, as I really want it for own purposes and was hoping to contribute something to the FG community.
nickabbey
September 8th, 2016, 21:02
is this (https://www.fantasygrounds.com/forums/showthread.php?33599-Individual-PC-XP-assignment-extension-for-d20-based-rulesets)what you're looking for?
It was the first thing I looked at when trying to figure out how I'd do this in 3.5/PFRPG
Oh, and there's this (https://www.fantasygrounds.com/forums/showthread.php?33599-Individual-PC-XP-assignment-extension-for-d20-based-rulesets)one too, which is done by the man himself.
damned
September 9th, 2016, 03:13
Good luck with your job search nickabbey!
SpiritofFire
September 9th, 2016, 21:33
Awesome, gonna use it for my next session!
nickabbey
September 11th, 2016, 19:55
Hacking on this a bit this PM.
I skimmed https://www.lua.org/pil/contents.html last night, went through the whole thing in about 45 minutes.
Didn't really try any exercises cuz it was late, I just wanted to get some lua in my brain before bed.
Since my first language was C (that was like, 15 languages ago) I got a pretty good feel for lua with that.
Took a look at the manager_ps2.lua I was using, somehow it wasn't identical to the one in the 3.5e ruleset in my fg_data rulesets folder.
I fixed that up by copying the original in to my extensions dir as ps/scripts/manager_ps2.lua and having extension.xml import it.
First thing I did was try to output a console debug message so I could start inspecting results of things like assignments and logic operations.
Started here by reading https://www.fantasygrounds.com/refdoc/Debug.xcp, and simply trying to output to the console with a test.
console("Test")
threw:
Script Error: [string "ps/scripts/manager_ps2.lua"]:269: attempt to call global 'console' (a nil value)
so I tried:
local test = "Testing"
console(test)
same result.
So what gives? do I need to do something extra along the lines of an import or instantiate something to be able to use the console?
nickabbey
September 11th, 2016, 20:01
Hacking on this a bit this PM.
I skimmed https://www.lua.org/pil/contents.html last night, went through the whole thing in about 45 minutes.
Didn't really try any exercises cuz it was late, I just wanted to get some lua in my brain before bed.
Since my first language was C (that was like, 15 languages ago) I got a pretty good feel for lua with that.
Took a look at the manager_ps2.lua I was using, somehow it wasn't identical to the one in the 3.5e ruleset in my fg_data rulesets folder.
I fixed that up by copying the original in to my extensions dir as ps/scripts/manager_ps2.lua and having extension.xml import it.
First thing I did was try to output a console debug message so I could start inspecting results of things like assignments and logic operations.
Started here by reading https://www.fantasygrounds.com/refdoc/Debug.xcp, and simply trying to output to the console with a test.
console("Test")
threw:
Script Error: [string "ps/scripts/manager_ps2.lua"]:269: attempt to call global 'console' (a nil value)
so I tried:
local test = "Testing"
console(test)
same result.
So what gives? do I need to do something extra along the lines of an import or instantiate something to be able to use the console?
so I guess typing this out helped me reason a good guess.
tried
Debug.console(test)
works.
nickabbey
September 11th, 2016, 20:48
Ok, so next stumbling block encountered pretty quickly. Been at it for about an hour, gonna take a break but for note taking purposes slash cry for help, here it is.
TL;DR: why can't I get info out of debug.getinfo() for a database record?
looking at ps/scripts/manager_ps2.lua (my understanding is commented in):
function awardXP(nXP)
-- Determine members of party
local aParty = {};
-- _,v is a tuple returned form the db call. basically iterate over whatever the DB call returns, expecting first position _ as a key, 2nd positin v is the corresponding value.
for _,v in pairs(DB.getChildren("partysheet.partyinformation")) do
-- striaghtforward multiple assignment sClass = v and sRecord = v.link (or maybe v["link"]?)
local sClass, sRecord = DB.getValue(v, "link");
-- verify that we're working on a charsheet and that sRecord resolved to some not nil thing
if sClass == "charsheet" and sRecord then
-- question #1 below
local nodePC = DB.findNode(sRecord);
if nodePC then
-- my main question - why does debug.getinfo(nodePC) throw an error resolving "debug"?
-- is the low level lua debug stuff not available, or wrapped somewhere?
Debug.console(debug.getinfo(nodePC))
-- question #2 below
local sName = DB.getValue(v, "name", "");
table.insert(aParty, { name = sName, node = nodePC } );
end
end
end
The line:
Debug.console(debug.getinfo(nodePC))
throws:
Script Error: [string "ps/scripts/manager_ps2.lua"]:269: attempt to index global 'debug' (a nil value)
question #1: Is nodePC a pointer or an object here can I do things like Debug.console(nodePC.<whatever>) or Debug.console(nodePC["whatever"])
question #2: is this the "right" way to get any individual value from the db for a specific element on a character sheet? IE) if I added a charsheet.receivesxp, would I use this format to get the value it is currently assigned?
More or less, I want to get instrospection working so I can dump things to the console to get a better understanding of the object and datastructure hierarchies. I'm looking to do things like look at functions and tables so that I can answer questions like 1 and 2 for myself.
Trenloe
September 11th, 2016, 22:01
This is what is available to you in terms of Debug: https://www.fantasygrounds.com/refdoc/Debug.xcp
And be aware of what is and isn't available in FG: https://www.fantasygrounds.com/modguide/scripting.xcp
Trenloe
September 11th, 2016, 22:05
nodePC is a database node, more info on what you can do with those here: https://www.fantasygrounds.com/refdoc/databasenode.xcp and FG databases in general here: https://www.fantasygrounds.com/modguide/database.xcp
Some good background info, references and hints here: https://www.fantasygrounds.com/forums/showthread.php?20651-Modifying-the-CoreRPG-ruleset
Trenloe
September 11th, 2016, 22:07
Your best examples for doing "stuff" is he already existing FG code. Extract the CoreRPG and 5E rulesets to a temporary directory somewhere (*not* within the FG rulesets directory as FG will read them as a ruleset) and then use "find in files" in your chosen text editor to find examples of what you're looking to do.
nickabbey
September 11th, 2016, 22:20
Your best examples for doing "stuff" is he already existing FG code. Extract the CoreRPG and 5E rulesets to a temporary directory somewhere (*not* within the FG rulesets directory as FG will read them as a ruleset) and then use "find in files" in your chosen text editor to find examples of what you're looking to do.
I've been "grep"ing with wild abandon all day lol. This is how I recognized that I was using the wrong copy of the manager_ps2.lua file.
Thanks as always for the pointers on the other things. I've reached a stop for the day, but will probably hit the link you gave for debugging either before bed or during the day early next week.
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.