PDA

View Full Version : Can An Extension Be Stopped From Loading?



UrsaTeddy
August 12th, 2020, 15:59
Greetings All,

I am trying to stop an Extension from loading if another Extension has not been previously loaded.

Trenloe
August 12th, 2020, 16:29
See the <dependency> tag: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/272465927/Developer+Guide+-+Extensions+-+Files

Unfortunately, it looks like this has been removed from FGU: https://www.fantasygrounds.com/forums/showthread.php?50554-FGU-Early-Access-Developer-Considerations&p=467197&viewfull=1#post467197

UrsaTeddy
August 12th, 2020, 22:42
See the <dependency> tag: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/272465927/Developer+Guide+-+Extensions+-+Files

Unfortunately, it looks like this has been removed from FGU: https://www.fantasygrounds.com/forums/showthread.php?50554-FGU-Early-Access-Developer-Considerations&p=467197&viewfull=1#post467197

Dammit.

As a developer in the real world, I use libraries for everything.

Either I centralise everything in a Common Extension or I copy files between all my Extensions.

So with your response I will have to just ensure the Common Extension is loaded and hope that anyone using my Extension does the same thing.

Stopping an Extension from loading with a simple return false from an onInit() would be sufficient and it would be up to the developer to check if the required Extension is loaded or not.

damned
August 13th, 2020, 00:16
I wonder if it has been removed until we can determine the best way to implement this going forward like token locking?

bmos
August 13th, 2020, 00:37
Dammit.

As a developer in the real world, I use libraries for everything.

Either I centralise everything in a Common Extension or I copy files between all my Extensions.

So with your response I will have to just ensure the Common Extension is loaded and hope that anyone using my Extension does the same thing.

Stopping an Extension from loading with a simple return false from an onInit() would be sufficient and it would be up to the developer to check if the required Extension is loaded or not.

You can 'kind of' do this with if statements.
Just check for the name of the script that you depend on before triggering the code that depends on it.
Not perfect, but avoids errors.

See the onInit function here (https://github.com/bmos/FG-PFRPG-Disease-Tracker/blob/master/scripts/disease_tracker.lua) which only sets the handler if the ClockAdjuster extension is loaded.

UrsaTeddy
August 13th, 2020, 01:17
You can 'kind of' do this with if statements.
Just check for the name of the script that you depend on before triggering the code that depends on it.
Not perfect, but avoids errors.

See the onInit function here (https://github.com/bmos/FG-PFRPG-Disease-Tracker/blob/master/scripts/disease_tracker.lua) which only sets the handler if the ClockAdjuster extension is loaded.

@bmos

Your code does not illustrate my situation.

You are adding a handler based on a condition, however what I want to do is to completely block an Extension from loading.

So for example an Extension that adds a new Attribute to the character sheet but requires FancyExtension to be loaded still loads even if I do the check for FancyExtension being loaded or not.

What I want is to completely halt/unload the extension if it cannot find the required FancyExtension.