PDA

View Full Version : Auto-generated Action items when gear is added to inventory



rmilmine
April 29th, 2020, 20:25
Question, where would I find the code that does this?
I would like to have a peek at it and see how difficult it would be to modify it to add new capabilities like taking into account more items in properties of the item.
I'm currently wanting to do this for 3.5E/Pathfinder.

Thanks.

Trenloe
April 29th, 2020, 20:28
In the 3.5e.pak files in the <FG app data>\rulesetset directory.

Look at campaign\scripts\manager_char.lua - the onCharItemAdd function is the one to get called first - and this calls the addToWeaponDB function where all of the action (pun intended) is.

rmilmine
April 29th, 2020, 20:58
Thanks Trenloe, looking at it now. Barely know what I'm looking at but I'll figure it out.
Hopefully I can get this to work the way I want to.

Trenloe
April 30th, 2020, 13:29
Some guidelines and documentation here: https://www.fantasygrounds.com/forums/showthread.php?19033-Modifying-the-3-5e-PFRPG-ruleset

rmilmine
May 1st, 2020, 23:52
Thanks, I've actually been able to get stuff working. I can now add things like flaming to weapons or wands/potions to the actions tab.
Still work to do to get it working fully though.

Thanks.

rmilmine
May 2nd, 2020, 18:47
Well I've sort of got this working.
When the code creates the action item it doesn't do it every time.
If I go to the action tab and then to inventory it does.
If I go directly to the inventory tab it doesn't.
I used code similar to handleClassFeaturesSpells in manager_char.lua.



local nodeSpellSet = nodeChar.createChild("spellset");
if not nodeSpellSet then
return;
end
local nodeNewSpellClass = nodeSpellSet.createChild();
if nodeNewSpellClass then
DB.setValue(nodeNewSpellClass, "label", "string", sDisplayName);
DB.setValue(nodeNewSpellClass, "castertype", "string", "spontaneous");
DB.setValue(nodeNewSpellClass, "availablelevel" .. nSpellLevel, "number", nUsesAvailable);
DB.setValue(nodeNewSpellClass, "source_name", "string", sItemSource);
DB.setValue(nodeNewSpellClass, "cl", "number", nCL);
DB.setValue(nodeChar, "spellmode", "string", "standard");
local nodeNew = SpellManager.addSpell(nodeSpell, nodeNewSpellClass, nSpellLevel);
end

SpellManager.addSpell works but only after I've visited the action tab.
I've checked the values being passed and they are basically the same from one call to the next.

bmos
June 15th, 2020, 14:18
I'm having a similar issue and I think it's the same that is discussed here, in case you haven't seen this thread yet :)
https://svn.fantasygrounds.com/forums/showthread.php?50997-programming-Activate-Character-Sheet-Values&highlight=unless+opened+inventory+first

rmilmine
June 16th, 2020, 11:09
I think I know what the problem is now. SpellManager.addSpell is used on the Action tab, and because of that doesn't work if the action tab hasn't been open already. I'll have a look at what addSpell does and replicated it with changes so that it works even when the tab hasn't been open.