DICE PACKS BUNDLE
Page 1 of 2 12 Last
  1. #1

    Retreiving Extension Info

    Hi Guys,

    Just a quick one - is there a way (ie a function) to get a list of Extensions that are loaded, and/or the details about the Extension(s) (eg Version Number, Author, etc)?

    Cheers
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  2. #2
    Ikael's Avatar
    Join Date
    Jan 2008
    Location
    Finland/Joensuu
    Posts
    2,383
    Quote Originally Posted by dulux-oz View Post
    Hi Guys,

    Just a quick one - is there a way (ie a function) to get a list of Extensions that are loaded, and/or the details about the Extension(s) (eg Version Number, Author, etc)?

    Cheers
    I have also been requesting this, but the answer is no, not at the moment. The only way to gather this information is to make ruleset support some sort of "register yourself" functionality and each extension would invoke it when they are loaded in.
    "Alright, you primitive screwheads, listen up: THIS... is my BOOMSTICK!" -- Ash Williams, Army of Darkness

    Post your SavageWorlds ruleset feature requests and issue reports here!

  3. #3
    OK, well, if it doesn't exist then I'll write something - and I have.

    Feel free to use the following code in your Extensions - I suggest putting the code into an LUA file (say, "lsExtensionManager.lua") and then put this line:
    Code:
    <script name="ExtensionManager" file="lsExtensionmanager.lua"/>
    into your extension.xml file.

    Code:
    aExtensions = {}
    
    function registerExtension(sExtensionName,sAuthor,sVersion)
    	aExtensions[sExtensionName] = {};
    	if sAuthor then
    		aExtensions[sExtensionName]["author"] = sAuthor;
    	end
    	if nVersion then
    		aExtensions[sExtensionName]["version"] = sVersion;
    	end
    end
    
    function unregisterExtension()
    	if aExtensions then
    		aExtensions[sExtensionName] = nil;
    	end
    end
    
    function isExtensionLoaded(sExtensionName)
    	for kKey,vValue in pairs(aExtensions) do
    		if kKey == sExtensionName then
    			return true;
    		end
    	end
    	return false;
    end
    
    function getExtensionAuthor(sExtensionName)
    	if aExtensions[sExtensionName] then
    		return aExtensions[sExtensionName]["author"]
    	end
    	return nil;
    end
    
    function getExtensionVersion(sExtensionName)
    	if aExtensions[sExtensionName] then
    		return aExtensions[sExtensionName]["version"]
    	end
    	return nil;
    end
    If anyone wants or writes any other functions, post them to this thread so we can all "enjoy" them

    Might I also STRONGLY recommend that SW add this code (or something similar) into the CoreRPG Ruleset - please.

    Note: I haven't tested this yet - I wrote it "on the fly" - so if you spot a typo/bug/etc please let us know - thanks.

    Cheers
    Last edited by dulux-oz; August 29th, 2014 at 15:10.
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  4. #4
    Ikael's Avatar
    Join Date
    Jan 2008
    Location
    Finland/Joensuu
    Posts
    2,383
    Quote Originally Posted by dulux-oz View Post
    OK, well, if it doesn't exist then I'll write something - and I have.

    Feel free to use the following code in your Extensions - I suggest putting the code into an LUA file (say, "lsExtensionManager.lua") and then put this line:
    Code:
    <script name="ExtensionManager" file="lsExtensionmanager.lua"/>
    into your extension.xml file.

    Code:
    aExtensions = {}
    
    function registerExtension(sExtensionName,sAuthor,nVersion)
        aExtensions[sExtensionName] = {};
        if sAuthor then
            aExtensions[sExtensionName]["author"] = sAuthor;
        end
        if nVersion then
            aExtensions[sExtensionName]["version"] = nVersion;
        end
    end
    
    function unregisterExtension()
        if aExtensions then
            aExtensions[sExtensionName] = nil;
        end
    end
    
    function isExtensionLoaded(sExtensionName)
        for kKey,vValue in pairs(aExtensions) do
            if kKey == sExtensionName then
                return true;
            end
        end
        return false;
    end
    
    function getExtensionAuthor(sExtensionName)
        if aExtensions[sExtensionName] then
            return aExtensions[sExtensionName]["author"]
        end
        return nil;
    end
    
    function getExtensionVersion(sExtensionName)
        if aExtensions[sExtensionName] then
            return aExtensions[sExtensionName]["version"]
        end
        return nil;
    end
    If anyone wants or writes any other functions, post them to this thread so we can all "enjoy" them

    Might I also STRONGLY recommend that SW add this code (or something similar) into the CoreRPG Ruleset - please.

    Note: I haven't tested this yet - I wrote it "on the fly" - so if you spot a typo/bug/etc please let us know - thanks.

    Cheers
    Few notes: can you really "unregister" extension? I mean if you have loaded it in, that means that it's there to stay
    version number would better be string, because you could have something like 1.2-build2 -- depending version naming style, which may differ in projects.
    "Alright, you primitive screwheads, listen up: THIS... is my BOOMSTICK!" -- Ash Williams, Army of Darkness

    Post your SavageWorlds ruleset feature requests and issue reports here!

  5. #5
    Quote Originally Posted by Ikael View Post
    Few notes: can you really "unregister" extension? I mean if you have loaded it in, that means that it's there to stay
    I was waiting for someone to point that out - yes, you are right, but I put it in because every other register[something] function has a corresponding unregister[something] function - I was being (anally) complete.

    Quote Originally Posted by Ikael View Post
    version number would better be string, because you could have something like 1.2-build2 -- depending version naming style, which may differ in projects.
    Good call - changes made in the relevant post.

    Cheers
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    Quote Originally Posted by dulux-oz View Post
    Note: I haven't tested this yet - I wrote it "on the fly" - so if you spot a typo/bug/etc please let us know - thanks.
    Posting untested code! How could you??? ;-)

    Nice idea. The main issue, which I'm sure you're aware of, is relying on developers putting this in their extension. Or, we're you thinking it would be more of use to an individual who developed more than one extension themselves - checking for specific extensions and versions to see if they are compatible?
    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!

  7. #7
    Quote Originally Posted by Trenloe View Post
    Nice idea. The main issue, which I'm sure you're aware of, is relying on developers putting this in their extension. Or, we're you thinking it would be more of use to an individual who developed more than one extension themselves - checking for specific extensions and versions to see if they are compatible?
    Actually a little of both - my own Extensions may have extra/different features when each is loaded with others of my Extensions (which prompted me in the first place) but it would also be good if we, as the developer community, took the trouble to help each other out by using this in our Extensions.

    That's one reason I'm asking SW to add it in to FG and/or CoreRPG - or even make the registration automatic as part of the Extension loading code (which exists inside FG) - but even if they decide not too (and I really really hope they do) if we could all use it it would help us all out.

    Just my $0.03 worth (inflation, you know).

    Cheers
    Last edited by dulux-oz; August 29th, 2014 at 17:26.
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  8. #8
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    Quote Originally Posted by dulux-oz View Post
    Just my $0.03 worth (inflation, you know).
    What?!? You'll be up to the value of a real-life-real-money coin soon!
    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!

  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    Perhaps add a slash handler to output all registered extension names and versions to the chat window? /extensionlist maybe?
    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!

  10. #10
    Considering it already outputs the list of extensions at startup, I would expect the slash command to be a pretty trivial addition.

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
  •  
5E Product Walkthrough Playlist

Log in

Log in