-
May 17th, 2020, 16:32 #21
- Join Date
- Jul 2007
- Location
- Germany
- Posts
- 40
-
May 18th, 2020, 21:11 #22
- Join Date
- Jul 2007
- Location
- Germany
- Posts
- 40
Sorry, I am not a Lua programmer, and I do not have a lot of experience writing extensions for FG.
It seems that locking the NPC sheet is done by the function "update()" in npc_main.lua. Is there a way to extend this function, or do I need to include the complete npc_main.lua file from the 2e ruleset + my changes in the extension?
-
May 19th, 2020, 02:03 #23
Yeah, it's a little harder for a file like npc_main.lua that's referenced in the campaign xml rather than in base.xml, because you can't replace it as easily. What you basically need to do is create your own record_npc.xml, create a windowclass for npc_combat (the window in record_npc.xml in CoreRPG that references that lua file), use merge="join", and then add a script tag to point at your script. The rest of your xml file should be pretty much empty... you just need to build enough structure to get you down to where your script is defined so you can override that. By using the merge tag, you don't have to replace everything. I don't have the link but I known "damned" on these forums has a link to a short tutorial vid on how to do this in his signature
Then your script that you point it at can define an "update" function and within it you can do something like
Code:function update() super.update(); myThingToDo(); end
Code:local fOldUpdate; function onInit() fOldUpdate = NpcMain.update; NpcMain.update = myNewUpdate; end function myNewUpdate() fOldUpdate(); doMyNewStuff(); end
Last edited by Sterno; May 19th, 2020 at 13:06. Reason: Had some parenthesis in the wrong place which would have 100% made this not work
-
May 19th, 2020, 03:26 #24
Thats a complicated question to answer. There are various ways to do it and really depends on exactly what you want. You could insert code into you xml on the specific controls you're changing, you could add a new function, you could replace the entire item_main.lua with your own.
It really depends on what you need and what you know how to do.
You might try and pose the question in the Work Shop forum with sample bits of code you're trying to use.---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset FGU Reference Module, or Web.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
May 20th, 2020, 20:53 #25
- Join Date
- Jul 2007
- Location
- Germany
- Posts
- 40
Thank you very much, this was exactly what I was searching for. I reduced my custom npc sheet to the following:
Code:<root> <windowclass name="npc_combat" merge="join"> <script> function update() super.update(); local nodeRecord = getDatabaseNode(); local bReadOnly = WindowManager.getReadOnlyState(nodeRecord); updateControl("savesAs", bReadOnly); savesAs.setReadOnly(bReadOnly); end </script> <sheetdata> <label_column name="savesas_label"> <!-- anchored to="hitDice_label" position="bottom" offset="-10" / --> <static textres="npc_label_savesas" /> </label_column> <string_columnh name="savesAs"> <!-- anchored to="hitDice" position="bottom" offset="-10" / --> <script> function onValueChanged() local node = getDatabaseNode(); local nodeNPC = node.getChild(".."); CombatManagerADND.updateNPCSaves(nodeNPC, nodeNPC, true); window.onSummaryChanged(); end </script> </string_columnh> </sheetdata> </windowclass> </root>
Last edited by FlynnTheAvatar; May 20th, 2020 at 20:53. Reason: Fixed quoting.
-
May 21st, 2020, 04:11 #26
Look at "insertbefore" and that should get ya where you want.
<label_encounter_weaponlist name="label_weapons" insertbefore="maplinks_label" />---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset FGU Reference Module, or Web.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
May 21st, 2020, 09:03 #27
- Join Date
- Jul 2007
- Location
- Germany
- Posts
- 40
Thank you very much. So, the saves are done, too:
Rat, Giant (Basic).jpg
I created a pull request with my changes.
-
May 21st, 2020, 15:03 #28---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset FGU Reference Module, or Web.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
May 28th, 2020, 09:42 #29
- Join Date
- Jul 2007
- Location
- Germany
- Posts
- 40
-
May 28th, 2020, 16:24 #30
I checked gitlab and did not see any. See it now and processed merge.
One thing you might want to check, I corrected the hook in the 2E ruleset that did not properly calculate the entire span of the matrix (was to small). You should not need the matrix fix bit of code any longer.
I'm going to try and have gitlab send me notices for these things so I can resolve them quicker for you.---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset FGU Reference Module, or Web.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks