-
July 18th, 2022, 15:46 #1
How to show only the desired version of a skill
So here's my solution. It works, but I don't know if what I have done is correct or if it can create problems somewhere.
First of all, I will describe to you what the problem was. I have a ruleset and two (or more modules). Each module has a description of some skills, one of which exists on multiple modules.
When loading both modules nad opening the skill list, you see both versions, which may cause problems as players may be using the outdated version instead of the revised one.
My solution involves the generation of a LUA script which at the time of initialization registers a function (onEvent) to be called for these 5 events: onModuleLoad, onModuleUnload, onModuleAdded, onModuleUpdated and onModuleRemoved.
The function essentially does 3 things:
1. if both modules are loaded it makes a backup of the module skill with the original version (obviously it is tested that this backup is not already present);
2. if both modules are loaded delete the original skill (if it still exists);
3. if the original skill appears in the backups and the original module is loaded, while the one with the revised version is not, restore the original version (obviously testing that it does not already exist).
I would say everything happens very quickly. This solution implies that the ruleset must know which skill to look for and on which module. I am open to any suggestions.
This is added ti base.xml
Code:<script name="SkillVersionManager" file="scripts/skill_version_manager.lua" />
Code:function onInit() Interface.onDesktopInit = onDesktopInit; end function onDesktopInit() Module.onModuleLoad = SkillVersionManager.onEvent; Module.onModuleUnload = SkillVersionManager.onEvent; Module.onModuleAdded = SkillVersionManager.onEvent; Module.onModuleUpdated = SkillVersionManager.onEvent; Module.onModuleRemoved = SkillVersionManager.onEvent; end function onEvent() local nodeDest; local nodeOrig; if existsBackupVersion() == false and ModuleManager.isModuleLoaded("Module A") == true and ModuleManager.isModuleLoaded("ModuleB") == true then nodeDest = DB.createChild('backup'); nodeOrig = findModuleA(); -- Finds the original verison on Module A DB.copyNode(nodeOrig, nodeDest); end if existsBackupVersion() == true and existsOriginalVersion() == true and ModuleManager.isModuleLoaded("ModuleA") == true and ModuleManager.isModuleLoaded("ModuleB") == true then nodeOrig = findModuleA(); DB.deleteNode(nodeOrig); end if existsBackupVersion == true and existsOriginalVersion == false and ModuleManager.isModuleLoaded("ModuleA") == true and ModuleManager.isModuleLoaded("ModuleB") == false then nodeDest = DB.createChild('[ path on module A ]'); DB.copyNode(findBackupVersion(), nodeDest); DB.setCategory(findOriginalVersion, "ModuleA"); end end
-
July 18th, 2022, 15:54 #2
Extensions have a property called LoadOrder. I don't think modules do. But, maybe your extension/ruleset can use some of the code from it (if it is accessible in corerpg or an API). I don't know, and am not a coder/developer but maybe that can be of use to you (if desired, what you are doing sounds reasonable to me.)
Problems? See; How to Report Issues, Bugs & Problems
On Licensing & Distributing Community Content
Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets, Balance Disturbed, Dungeon Room Descriptions
Note, I am not a SmiteWorks employee or representative, I'm just a user like you.
-
July 18th, 2022, 16:49 #3
Yep, but I don't want an extension. It could be hard to manage and a master could forget to load it.
I've found an easier way. So, here is the revised code.
Code:function onInit() Interface.onDesktopInit = onDesktopInit; end function onDesktopInit() Module.onModuleLoad = SkillVersionManager.onEvent; Module.onModuleUnload = SkillVersionManager.onEvent; Module.onModuleAdded = SkillVersionManager.onEvent; Module.onModuleUpdated = SkillVersionManager.onEvent; Module.onModuleRemoved = SkillVersionManager.onEvent; onEvent(); end function onEvent() DB.revert(' Path Module A'); if ModuleManager.isModuleLoaded("ModuleA") == true and ModuleManager.isModuleLoaded("ModuleB") == true then nodeOrig = findModuleA(); DB.deleteNode(nodeOrig); end end
-
July 21st, 2022, 21:53 #4
-
July 21st, 2022, 22:21 #5
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,611
Clients don't support revert command; as they never own module data and revert only works on module data.
Regards,
JPG
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks