DICE PACKS BUNDLE
  1. #1
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    244

    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" />
    This is part of skill_version_manager.lua - I don't show the search or existence check functions because they are trivial checks of the DB. I think in the end I will leave only the search ones (find), cleaning up the code a bit.
    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
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

  2. #2
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    -7 UTC
    Posts
    17,148
    Blog Entries
    9
    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.

  3. #3
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    244
    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
    Last edited by Xarxus; July 18th, 2022 at 17:18.
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

  4. #4
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    244
    I have noticed that the command DB.revert(' Path Module A'); does not work on the client. I have to unload and load by hand.
    Anyone have an idea why it doesn't work and hat to do?
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

  5. #5
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in