Thread: New to FG, a couple of questions
-
October 9th, 2018, 07:45 #21
- Join Date
- Sep 2018
- Posts
- 17
Sorry I should have realized this.
Here is the Extension.xml code:
Code:<?xml version="1.0" encoding="iso-8859-1"?> <root version="3.3" release="1.0"> <announcement text="This extention provides additional autofill and automation for the 3.5/Pathfinder ruleset" font="emotefont" /> <properties> <name>Autofill Extras</name> <version>0.1</version> <author>TobyFox2002</author> <description>This extention provides additional autofill and automation for the 3.5/Pathfinder ruleset</description> </properties> <base> <!-- This file is our main Lua file. You can name it what you want, but you must use xml restrictions in order to do that.--> <script name="AutofillExtras" file="scripts/autofill.lua" /> </base> </root>
Code:-- -- © Copyright TobyFox2002 2018+ except where explicitly stated otherwise. -- Fantasy Grounds is Copyright © 2004-2014 SmiteWorks USA LLC. -- Copyright to other material within this file may be held by other Individuals and/or Entities. -- This file may be freely distributed and even modified as long as any changes and/or -- enhancements are shared to the community as a whole for the enrichment of all. RACIAL_TRAIT_SIZE = "^size$"; RACIAL_TRAIT_SIZE_MEDIUM = "^medium$"; RACIAL_TRAIT_SIZE_SMALL = "^small$"; -- RACIAL_TRAIT_LARGE added by TobyFox2002 to allow for large races RACIAL_TRAIT_SIZE_LARGE = "^large$"; function handleRacialSize(nodeChar, nodeTrait, sTraitType) local sSize = ""; if sTraitType:match(RACIAL_TRAIT_SIZE) then local sText = DB.getText(nodeTrait, "text"):lower(); local aWords = StringManager.parseWords(sText); local i = 1; -- added "large" as part of the isPhrase array while aWords[i] do if StringManager.isPhrase(aWords, i, { "are", { "small", "medium", "large" }, "creatures" }) then sSize = aWords[i+1]; break; end i = i + 1; end -- added large to elseif elseif sTraitType:match(RACIAL_TRAIT_SIZE_MEDIUM) then sSize = "medium"; elseif sTraitType:match(RACIAL_TRAIT_SIZE_SMALL) then sSize = "small"; elseif sTraitType:match(RACIAL_TRAIT_SIZE_LARGE) then sSize = "large"; end if sSize == "" then return false; end local sSkill; if DataCommon.isPFRPG() then sSkill = "Stealth"; else sSkill = "Hide"; end -- added large to else if DB.setValue(nodeChar, "size", "string", StringManager.capitalize(sTraitType)); if sSize == "small" then DB.setValue(nodeChar, "ac.sources.size", "number", 1); DB.setValue(nodeChar, "attackbonus.melee.size", "number", 1); DB.setValue(nodeChar, "attackbonus.ranged.size", "number", 1); if DataCommon.isPFRPG() then DB.setValue(nodeChar, "attackbonus.grapple.size", "number", -1); else DB.setValue(nodeChar, "attackbonus.grapple.size", "number", -4); end addSkillBonus(nodeChar, sSkill, 4); -- Perhaps include addSkillBonus(nodeChar, Fly, 8); Questionable, need to knowledge of lua. elseif sSize == "large" then DB.setValue(nodeChar, "ac.sources.size", "number", -1); DB.setValue(nodeChar, "attackbonus.melee.size", "number", -1); DB.setValue(nodeChar, "attackbonus.ranged.size", "number", -1); if DataCommon.isPFRPG() then DB.setValue(nodeChar, "attackbonus.grapple.size", "number", 1); else DB.setValue(nodeChar, "attackbonus.grapple.size", "number", 4); end addSkillBonus(nodeChar, sSkill, -4); -- Perhaps include addSkillBonus(nodeChar, Fly, -8); Questionable, need to knowledge of lua. elseif sSize == "medium" then DB.setValue(nodeChar, "ac.sources.size", "number", 0); DB.setValue(nodeChar, "attackbonus.melee.size", "number", 0); DB.setValue(nodeChar, "attackbonus.ranged.size", "number", 0); DB.setValue(nodeChar, "attackbonus.grapple.size", "number", 0); end return true; end
-
October 9th, 2018, 08:40 #22
manager_char.lua is going to use the function handleRacialSize within the file.
It doesnt know to use your version.
Replace the whole manager_char.lua in your extension.
-
October 9th, 2018, 08:49 #23
You're defining your custom code as a new global script package called "AutofillExtras" - but as damned says, nothing calls that package. FG will keep using the code in the 3.5E script package CharManager because there's nothing telling FG to use the new code.
Have a look at script scope and global packages here: https://www.fantasygrounds.com/wiki/...cript_Packages
So, to make this work, without modifying the base ruleset, we need to override the relevant code in the CharManager script package, but using CharManager. to reference code in that package.
The following should work OK - as long as you use the racial trait name "Size" as the code in the main CharManager package that calls handleRacialSize doesn't look for Large.
The onInit() function run when the script package is initialized when the extension.xml file is loaded (because of the <script name="AutofillExtras" file="scripts/autofill.lua" /> entry in that file). onInit adds the RACIAL_TRAIT_SIZE_LARGE variable to the CharManager package (it doesn't strictly need to do that, as it's not used elsewhere, it's an example of what can be done and keeps all variables in that package.
The CharManager.handleRacialSize function is overridden with the local custom_handleRacialSize function.
And then in that function, any calls to variables or other functions in CharManager package have CharManager. in front of them.
Note - there is an issue with the script as is - it will use the name of the racial trait for the size name in the Notes tab of the PC sheet - I've changed this to use sSize instead.
Code:function onInit() CharManager.RACIAL_TRAIT_SIZE_LARGE = "^large$"; CharManager.handleRacialSize = custom_handleRacialSize; end function custom_handleRacialSize(nodeChar, nodeTrait, sTraitType) local sSize = ""; if sTraitType:match(CharManager.RACIAL_TRAIT_SIZE) then local sText = DB.getText(nodeTrait, "text"):lower(); local aWords = StringManager.parseWords(sText); local i = 1; -- added "large" as part of the isPhrase array while aWords[i] do if StringManager.isPhrase(aWords, i, { "are", { "small", "medium", "large" }, "creatures" }) then sSize = aWords[i+1]; break; end i = i + 1; end -- added large to elseif elseif sTraitType:match(CharManager.RACIAL_TRAIT_SIZE_MEDIUM) then sSize = "medium"; elseif sTraitType:match(CharManager.RACIAL_TRAIT_SIZE_SMALL) then sSize = "small"; elseif sTraitType:match(CharManager.RACIAL_TRAIT_SIZE_LARGE) then sSize = "large"; end if sSize == "" then return false; end local sSkill; if DataCommon.isPFRPG() then sSkill = "Stealth"; else sSkill = "Hide"; end -- added large to else if DB.setValue(nodeChar, "size", "string", StringManager.capitalize(sSize)); if sSize == "small" then DB.setValue(nodeChar, "ac.sources.size", "number", 1); DB.setValue(nodeChar, "attackbonus.melee.size", "number", 1); DB.setValue(nodeChar, "attackbonus.ranged.size", "number", 1); if DataCommon.isPFRPG() then DB.setValue(nodeChar, "attackbonus.grapple.size", "number", -1); else DB.setValue(nodeChar, "attackbonus.grapple.size", "number", -4); end addSkillBonus(nodeChar, sSkill, 4); -- Perhaps include addSkillBonus(nodeChar, Fly, 8); Questionable, need to knowledge of lua. elseif sSize == "large" then DB.setValue(nodeChar, "ac.sources.size", "number", -1); DB.setValue(nodeChar, "attackbonus.melee.size", "number", -1); DB.setValue(nodeChar, "attackbonus.ranged.size", "number", -1); if DataCommon.isPFRPG() then DB.setValue(nodeChar, "attackbonus.grapple.size", "number", 1); else DB.setValue(nodeChar, "attackbonus.grapple.size", "number", 4); end CharManager.addSkillBonus(nodeChar, sSkill, -4); -- Perhaps include addSkillBonus(nodeChar, Fly, -8); Questionable, need to knowledge of lua. elseif sSize == "medium" then DB.setValue(nodeChar, "ac.sources.size", "number", 0); DB.setValue(nodeChar, "attackbonus.melee.size", "number", 0); DB.setValue(nodeChar, "attackbonus.ranged.size", "number", 0); DB.setValue(nodeChar, "attackbonus.grapple.size", "number", 0); end return true; end
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks