-
October 3rd, 2022, 05:58 #11
- Join Date
- Mar 2020
- Location
- Sydney, Australia
- Posts
- 247
@Moon Wizard
So what is my best solution here?
... I want to keep a single common code base for all of my extensions
... I do not want to have to require a user to load a "common" extension ... this is cumbersome IMHO
By your description of the loading system, I could not even put code in saying "if I have previously defined this item then ignore this code" because the code would have been overwritten during the loading phase.Thanks In Advance,
D
-
October 3rd, 2022, 06:05 #12
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,412
Make sure your common code is in a separate extension with a lower load order than your extensions that rely on them.
Also, make sure that the scripts are fully defined, and not attempting to rewrite functions in onInit, since that order is not guaranteed.
JPG
-
October 3rd, 2022, 06:13 #13
- Join Date
- Mar 2020
- Location
- Sydney, Australia
- Posts
- 247
@Moon Wizard
So handing out my extension (for example on the Forge) would require me to put up two extensions with a warning that the common extension is required for the other extensions.
So my hopes of these extensions being atomic is a dream - unless I replicate the codebase ensuring no overwriting happens (therefore function BLAH() would have to be rewritten as BLAH105 and BLAH110).
I am assuming that I have it correct that string resources are not affected by the overwriting since they are are just named strings.Thanks In Advance,
D
-
October 3rd, 2022, 14:03 #14Private 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!
-
October 3rd, 2022, 14:05 #15
-
October 3rd, 2022, 15:01 #16
- Join Date
- Mar 2020
- Location
- Sydney, Australia
- Posts
- 247
@trenloe ...
for example i have a file called string.lua
in that file i have the following sample code ... that extends the lua string type with functions whose contents do not matter
Code:_100_string_initialised = false function onInit( ) Debug.chat("Setting up 100 STRING",_100_string_initialised) if not _100_string_initialised then Debug.chat("STRING","Actual Initialising") -- Extend LUA string string[ 'mid' ] = self.mid string[ 'left' ] = self.left string[ 'right' ] = self.right string[ 'split' ] = self.split string[ 'trim' ] = self.trim string[ 'concat' ] = self.concat -- Convenience alias string[ 'fget' ] = Interface.getString _100_string_initialised = true end end
loading each extension individually causes no problem ... however 110 essentially overwrites script_100_string_lib which from previous posts indicates that the code will not be accessible by 105 once 110 is loaded.Thanks In Advance,
D
-
October 3rd, 2022, 15:16 #17
How are you calling Global Script Package and from where within the FG file hierarchy? Where doesn't it run correctly?
Please provide more information to help us troubleshoot this issue. So far we've been very theoretical and this is the first post where we've seen some actual code, but we're still not seeing the whole picture of the code hierarchy, where the Global Script Package is being called and where it fails - please provide details of the actual code, where it fails, any error encountered, etc..Last edited by Trenloe; October 3rd, 2022 at 15:23.
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!
-
October 3rd, 2022, 15:32 #18
- Join Date
- Mar 2020
- Location
- Sydney, Australia
- Posts
- 247
@Trenloe ...
i am not 100% sure what you want ... there is a common code file string.lua that is loaded in both extensions.
In onInit( ) of the first extension - 105 in this case ... it calls string.concat to create a string.
When it is loaded on its own - the only extension loaded that uses the common code file - it works as expected.
When I load 105 and 110, the onInit() of 105 has an error on the string.concat call - it cannot locate string.concat, however 110 can find it and its string.concat call works.
That is the simplest I can describe it.Thanks In Advance,
D
-
October 3rd, 2022, 15:44 #19
I'm not looking for descriptions - I'm looking for actual code and actual error messages. It's very easy to misunderstand high level discussions of low level code, without seeing that actual code, actual error messages etc..
If you could provide a couple of skeleton extensions that can be used to recreate/investigate the issue, that would be great. Otherwise we're pretty much shooting in the dark and going back and forwards without full details.
It may be that extending the base LUA string object doesn't work within the way script scope operates within FG - Moon Wizard would have to comment on that. The way FG normally does things like this is to leave the base LUA object alone and extend with a Global Script Package - see the CoreRPG StringManager Global Script Package as an example (scripts\manager_string.lua). I think this is a better way to go in FG, especially within a multi extension extension environment where it could be difficult to track down exactly where base LUA objects are being extended when multiple extensions are being ran. Is it as elegant a programming solution as extending the base LUA string object? No, but I think it's easier to maintain and troubleshoot in a multi extension, fairly uncontrolled (i.e. multi developer) environment.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!
-
October 3rd, 2022, 16:09 #20
- Join Date
- Mar 2020
- Location
- Sydney, Australia
- Posts
- 247
Extending LUA objects is expected in LUA development AFAIK.
However I understand your concern and if I ever get to the publishing stage, I would most likely change the extending of the LUA objects to something else if it was an issue.
I have created an extremely stripped down pair of extensions that show the issue very simply.
Load each one individually you will see output in the Console.
Load them together and the Console will open with an error.
DSC_SWADE_105.ext
DSC_SWADE_110.ext
For some reason the URL tags do not load the attachments, however if you copy the URL and paste it in a new window it does.Last edited by UrsaTeddy; October 3rd, 2022 at 16:13. Reason: URL Corrections
Thanks In Advance,
D
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks