| Blockland Forums > Modification Help |
| Best Practices for Handling Add-on Dependencies? |
| (1/2) > >> |
| Platypi:
Say I have two add-ons, Script_Test1 and Script_Test2. The server.cs in Script_Test1 has the code --- Code: ---if(forceRequiredAddOn("Script_NotAnAddOn") == $Error::AddOn_NotFound) { error("Script_Test1 will not load"); $test1 = false; return; } $test1 = true; --- End code --- and the server.cs in Script_Test1 has the code --- Code: ---if(forceRequiredAddOn("Script_Test1") == $Error::AddOn_NotFound) { error("Script_Test2 will not load"); $test2 = false; return; } $test2 = true; --- End code --- To be explicitly clear, Script_NotAnAddOn When I enabled them both and start a server, $test1 is given the value 0, as expected. However, $test2 is given the value 1, which is not satisfactory. How do I ensure Script_Test2 cannot be loaded when Script_Test1 cannot be loaded? Is there a standard way to handle this, or would it require some sort of support add-on? Perhaps there's some way to force forceRequiredAddOn() to return $Error::AddOn_NotFound? EDIT: made title more pertinent |
| Kyuande:
The addons load in backward alphabet order, unfortunately this is a lot worse on Linux. Script_Test2 will load before Script_Test1. Linux is entirely random. Create a main.cs with the main code of the mod, execute it when you have the right if statement checks, otherwise print out stuff. You could manually load the other addon, but why do you need to do all of this? Seems like a headache. |
| Platypi:
--- Quote from: Kyuande on January 04, 2018, 09:17:36 AM ---The addons load in backward alphabet order, unfortunately this is a lot worse on Linux. Script_Test2 will load before Script_Test1. Linux is entirely random. --- End quote --- I'm just trying to show the method I'm currently using to handle dependencies. Ideally, I would like to develop a method for handling dependencies that works regardless of the order files are loaded in. --- Quote from: Kyuande on January 04, 2018, 09:17:36 AM ---Create a main.cs with the main code of the mod, execute it when you have the right if statement checks, otherwise print out stuff. You could manually load the other addon, but why do you need to do all of this? Seems like a headache. --- End quote --- Just trying to establish the best practice for checking add-on dependencies. My main concern is how to make sure an add-on that is not mine has loaded in correctly. I can add all the checks I want for dependencies I create. But not for dependencies from other creators. |
| Kyuande:
There is a function to tell if an addon is loaded but I currently cannot get it, I will provide the function later |
| Greek2me:
In Script_Test2, simply require Script_Test1, along with the same things that Script_Test1 requires. |
| Navigation |
| Message Index |
| Next page |