PDA

View Full Version : Another layered script replacement question



celestian
February 19th, 2017, 00:45
This is probably staring me in the face but if I was to say want to replace the


<script name="CombatManager" file="scripts/manager_combat.lua" />


Script with my own how would I do that?

I am currently building a layered ruleset on top of CoreRPG and 5e.

I've tried to do this by adding the above line to my base.xml and then placing a copy of the original CoreRPG version into my "RuleSetName/scripts/manager_combat.lua directory and restarting FG. I've placed a few debug prints (that's all) so I could see that it worked but I don't see any of the functions being used. I've placed a few debug prints before the calls to functions in manager_combat.lua in other lua scripts and they do show up in the console window (manager_combat2.lua, from 5e).

As you can see I already replaced a similar script for the 5e and it seems to work but the CoreRPG one isn't... so im wondering what I've missed.

Moon Wizard
February 19th, 2017, 05:47
Just redefine the same tag after the importruleset tag for 5E (which already imports CoreRPG). Make sure to include the new script in the new ruleset at scripts/manager_combat.lua. (Or whatever place you pick) Each named script can only exist once, so top layer scripts override same named scripts in lower layers.

Cheers,
JPG

celestian
February 19th, 2017, 07:09
Just redefine the same tag after the importruleset tag for 5E (which already imports CoreRPG). Make sure to include the new script in the new ruleset at scripts/manager_combat.lua. (Or whatever place you pick) Each named script can only exist once, so top layer scripts override same named scripts in lower layers.

Cheers,
JPG


When you say "tag" do you mean "<script name="CombatManager" file="scripts/manager_combat.lua" />" ? I'd done that (just double checked) and didn't seem to do it. I'll double check my paths/etc when I'm more awake and see that I didn't miss something. Right now script is in Ruleset/scripts/manager_combat.lua and does match the base.xml config.

Here is a snippet.




<!-- Layers -->
<importruleset source="CoreRPG" />
<importruleset source="5E" />

<!-- Strings -->
<includefile source="strings/strings_adnd.xml" />

<!-- Graphics -->
<includefile source="graphics/graphics_fonts.xml" />
<includefile source="graphics/graphics_frames.xml" />

<!-- Campaign Records -->
<includefile source="campaign/record_char_main.xml" />
<includefile source="campaign/record_char_main.xml" />
<includefile source="campaign/template_char_adnd.xml" />
<includefile source="campaign/record_char.xml" />
<includefile source="campaign/record_char_weapon.xml" />

<!-- <script name="SaveScores" file="campaign/scripts/number_savescore.lua" />
<script name="AbilityScores" file="campaign/scripts/number_abilityscore.lua" />
-->
<!-- Party sheet -->
<includefile source="ps/template_ps.xml" />
<includefile source="ps/ps_main.xml" />

<!-- High-level scripts -->
<script name="DataCommon" file="scripts/data_common.lua" />
<script name="ActorManager2" file="scripts/manager_actor2.lua" />
<script name="ActionsManager2" file="scripts/manager_actions2.lua" />
<script name="ActionSave" file="scripts/manager_action_save.lua" />
<script name="ActionCheck" file="scripts/manager_action_check.lua" />
<script name="ActionAttack" file="scripts/manager_action_attack.lua" />
<script name="CombatManager" file="scripts/manager_combat.lua" />
<script name="CombatManager2" file="scripts/manager_combat2.lua" />

<!-- Combat tracker -->
<includefile source="ct/template_ct.xml" />

<!-- Desktop -->
<includefile source="desktop/desktop_classes.xml" />

Trenloe
February 19th, 2017, 16:22
Here is a snippet.




<!-- Layers -->
<importruleset source="CoreRPG" />
<importruleset source="5E" />


I doubt this is the cause of your issue, but for correct layering you should only use one <importruleset> tag - use 5E in this case as 5E is layered on top of CoreRPG and so when you importruleset for 5E it will automatically load other rulesets it needs.

See the PFRPG ruleset as an example - this is layered on top of 3.5E which is layered on top of CoreRPG. There is only single line in the PFRPG ruleset: <importruleset source="3.5E" />

Moon Wizard
February 19th, 2017, 18:48
Except for as Trenloe pointed out, the rest of the base.xml file looks fine.

Do you also have a scripts/manage_combat.lua file in your new ruleset? If not, it will fallback to the 5E file in that location in the 5E ruleset.

Regards,
JPG

celestian
February 20th, 2017, 02:14
Except for as Trenloe pointed out, the rest of the base.xml file looks fine.

Do you also have a scripts/manage_combat.lua file in your new ruleset? If not, it will fallback to the 5E file in that location in the 5E ruleset.

Regards,
JPG

So, removed the CoreRPG layer line and tried things, still doesn't seem to work. The scripts/manager_combat.lua is in the ruleset/scripts directory.

Here is a clip from scripts/manager_combat2.lua



function onInit()
print ("manager_combat2.lua, onInit");
CombatManager.setCustomSort(CombatManager.sortfunc DnD);
CombatManager.setCustomDrop(onDrop);

CombatManager.setCustomAddNPC(addNPC);
CombatManager.setCustomNPCSpaceReach(getNPCSpaceRe ach);

CombatManager.setCustomTurnStart(onTurnStart);
CombatManager.setCustomCombatReset(resetInit);

OptionsManager.registerCallback("HRDD", onHRDistanceChanged);
onHRDistanceChanged();
end


Note the print line there. Now the only code I altered in the scripts/manager_combat.lua file.



--
-- SINGLE HANDLERS
-- NOTE: Setting these handlers will override previous handlers
--

local fCustomSort = nil;
function setCustomSort(fSort)
print ("manager_combat.lua, setCustomSort");
fCustomSort = fSort;
end
-- NOTE: Lua sort function expects the opposite boolean value compared to built-in FG sorting
function onSortCompare(node1, node2)
print ("manager_combat.lua, setCustomSort");
if fCustomSort then
return not fCustomSort(node1, node2);
end

return not sortfuncSimple(node1, node2);
end



The print lines there are the code I added to test this. When I watch the /console after I've typed /reload all I see is.



Runtime Notice: Reloading ruleset
Script Notice: manager_combat2.lua, onInit
Database Notice: Campaign saved.



So, you can see that the oninit part is being run from the manager_combat2.lua script but the "CombatManager.setCustomSort(CombatManager.sortfunc DnD);" function that I mention above does NOT generate any console output....

I've attached a file that shows the directory I've placed the manager_combat.lua in which far as I know is the correct path. I've double/triple checked the spelling of names and config entries.

Moon Wizard
February 20th, 2017, 02:24
You would have to post your ruleset to try and track down what is happening.

Additionally, I wouldn't recommend updating the CombatManager script, since this a common function in CoreRPG that may be updated over time. If you replace, you will miss changes and/or fixes to that file. That is why CombatManager2 is used by many rulesets.

Regards,
JPG

celestian
February 20th, 2017, 04:11
You would have to post your ruleset to try and track down what is happening.

Additionally, I wouldn't recommend updating the CombatManager script, since this a common function in CoreRPG that may be updated over time. If you replace, you will miss changes and/or fixes to that file. That is why CombatManager2 is used by many rulesets.

Regards,
JPG

I'm mostly just poking around to find where something is done in the code right now. Once I figure out where it is I might could avoid changing things there. Still feeling my way around the code.

If you really want to poke at the code I have it up on git or I can zip it here. Keep in mind this is really early stuff ... mostly of me figuring out how things work. So don't judge ;)

https://github.com/CelestianGC/AD-D-Core

Moon Wizard
February 20th, 2017, 04:30
Hmm, just downloaded ZIP from Git, unpacked and put in my rulesets directory. When I unpack and create a new campaign, I get this.



Runtime Notice: Reloading ruleset
Script Notice: manager_combat.lua, onInit
Script Notice: manager_combat2.lua, onInit
Script Notice: manager_combat.lua, setCustomSort


It seems like that's correct. What are you expecting to see?

No judgement on building rulesets. I started from scratch just like everyone else. ;)

Cheers,
JPG

Moon Wizard
February 20th, 2017, 04:32
You can also use Debug.chat(...) and Debug.console(...) to output any set of comma-delimited variables/literals from ruleset scripts.

Ex: Debug.console("CombatManager", "onInit", v);

Cheers,
JPG

celestian
February 20th, 2017, 04:51
Hmm, just downloaded ZIP from Git, unpacked and put in my rulesets directory. When I unpack and create a new campaign, I get this.



Runtime Notice: Reloading ruleset
Script Notice: manager_combat.lua, onInit
Script Notice: manager_combat2.lua, onInit
Script Notice: manager_combat.lua, setCustomSort


It seems like that's correct. What are you expecting to see?

No judgement on building rulesets. I started from scratch just like everyone else. ;)

Cheers,
JPG

WTF! I dunno why it doesn't show that to me cause that's not what I see. Just what I mentioned above. I'll try a completely clean directory and get the same git zip. Odd odd.

celestian
February 20th, 2017, 05:16
So yeap, just downloaded the zip, installed into another dir and it shows so is actually working. I'm going to try and figure out what's up because this bothers me ;)

Moon Wizard
February 20th, 2017, 05:22
Try unpacking the CoreRPG and 5E folders as well. (Mine are usually unpacked, since I work on them all the time.) But, remember that you did so for the next update, or else you won't see the features/fixes added.

Regards,
JPG

celestian
February 20th, 2017, 05:32
Try unpacking the CoreRPG and 5E folders as well. (Mine are usually unpacked, since I work on them all the time.) But, remember that you did so for the next update, or else you won't see the features/fixes added.

Regards,
JPG


Yeah I already have the CoreRPG and 5e's unpacked as well. I was wondering if I had inadvertently replaced one of their files by mistake but if it's working with this git/zip version without touching them I can't see how that's the problem. Perhaps I have an extra file in my other system that's causing it that I'll have to weed out.

celestian
February 20th, 2017, 05:53
Figured it out. I had the layers extension added and it apparently overrides my custom script.

Trenloe
February 20th, 2017, 06:31
Recommendation - don't do development with extensions enabled. Only use the base rulesets you're working on.

celestian
February 20th, 2017, 17:21
You would have to post your ruleset to try and track down what is happening.

Additionally, I wouldn't recommend updating the CombatManager script, since this a common function in CoreRPG that may be updated over time. If you replace, you will miss changes and/or fixes to that file. That is why CombatManager2 is used by many rulesets.

Regards,
JPG

Just wanted to explain what I'm trying to do incase anyone was curious. Right now the Combat tracker lists players higher to lowest initiative. What I'd like to do is flip that in addition to making "Next Actor" go from lowest to highest in order (instead of highest to lowest). AD&D's initiative is 1-10, with lower going first.

That's why I'm poking around in the sort functions.

damned
February 21st, 2017, 09:22
Just wanted to explain what I'm trying to do incase anyone was curious. Right now the Combat tracker lists players higher to lowest initiative. What I'd like to do is flip that in addition to making "Next Actor" go from lowest to highest in order (instead of highest to lowest). AD&D's initiative is 1-10, with lower going first.

That's why I'm poking around in the sort functions.

Hi celestian have you seen vodokars ADnD ruleset? Or are you doing a 2nd Edition?

damned
February 21st, 2017, 09:22
Just wanted to explain what I'm trying to do incase anyone was curious. Right now the Combat tracker lists players higher to lowest initiative. What I'd like to do is flip that in addition to making "Next Actor" go from lowest to highest in order (instead of highest to lowest). AD&D's initiative is 1-10, with lower going first.

That's why I'm poking around in the sort functions.

Hi celestian have you seen vodokars ADnD ruleset? Or are you doing a 2nd Edition?