The Gang Garrison 2 Forum

Gang Garrison Development => Game Modifications => Add-Ons and Plugins => Topic started by: Phantom Brave on June 04, 2012, 01:09:45 am

Title: Namespaces and you! (AKA organize your plugin resources...)
Post by: Phantom Brave on June 04, 2012, 01:09:45 am
...So that people don't spend five hours figuring out what sprites to delete when they remove the "extra animations" plugin.

Basically, there's an idea in the programming world that people should seperate their own stuff into their own "namespaces".

If you go into Minecraft's .jar file, you'll see some .class files and a couple directories. One of these directories is "net". If you open this, you'll see "minecraft". Back up a little bit. If I'm trying to tell java something's in that "minecraft" folder in the jar, what do I ask it for? "net.minecraft.file.class". This is a namespace. "net" is a directory in the root of the archive, and "minecraft" is a subdirectory of the "net" dir.

You might notice, this is basically a backwards "minecraft.net". This is because it is - notch organized it like that to keep minecraft-specific, notch-made code in one place in the archive, as long as it wasn't so important it deserved to be in the "root" namespace, which would make it "file.class". Why it's net.minecraft instead of something like notch.game, is because it's a naming convention - people who do that level of organizing tend to use their domain names as their namespaces.

You see this in greasemonkey script and ruby scripts too. Where am I going with this? I personally spent five hours gutting sprites out of the "Resources" folder, so I'm asking people who make plugins to start doing something like "Resources/Wareya/LaserFade/bloat.png" instead.

TL;DR: PUT PLUGIN RESOURCES IN SPECIAL FOLDERS OR PEOPLE GET FRUSTRATED REMOVING STUFF
Title: Re: (meta) Namespace directories and you! (AKA organize your plugin resources...)
Post by: notajf on June 04, 2012, 01:14:23 am
I support this convention. Also, maybe put plugin config there too.
Title: Re: (meta) Namespace directories and you! (AKA organize your plugin resources...)
Post by: Phantom Brave on June 04, 2012, 01:20:29 am
Also, maybe put plugin config there too.
possible, I'll try it out
Title: Re: (meta) Namespace directories and you! (AKA organize your plugin resources...)
Post by: notajf on June 04, 2012, 01:40:18 am
Oh wait ini_open only takes files in program directory :z3:

Eh I guess you could use namespace sections like [Plugins/Wareya/LaserFade] or w/e
Title: Re: (meta) Namespace directories and you! (AKA organize your plugin resources...)
Post by: Phantom Brave on June 04, 2012, 02:05:57 am
COMPILATION ERROR in code action
Error in code at line 4:
           conf = file_bin_open("C:\Users\wareya\Desktop\gg2\Plugins\Resources\Wareya\EndroundScreenshot\enable", 2); //god damn it GM
                                  ^
at position 33: Unexpected symbol.


conf = file_bin_open("' + namespace + "enable" + '", 2); //god damn it GM

Well, shit.
Title: Re: (meta) Namespace directories and you! (AKA organize your plugin resources...)
Post by: notajf on June 04, 2012, 02:07:33 am
COMPILATION ERROR in code action
Error in code at line 5:
           conf = file_bin_open("C:\Users\wareya\Desktop\gg2\Plugins\Resources\Wareya\EndroundScreenshot\" + workaround, 2); //god damn it GM
                                  ^
at position 33: Unexpected symbol.

Well, shit.
Try \\ maybe?
Title: Re: (meta) Namespace directories and you! (AKA organize your plugin resources...)
Post by: Phantom Brave on June 04, 2012, 02:09:16 am
It works fine if I use a var. It only breaks when I inline the string.
Title: Re: (meta) Namespace directories and you! (AKA organize your plugin resources...)
Post by: notajf on June 04, 2012, 02:16:57 am
I guess you're using this within an object

In which case do:

Code: [Select]
global.wareyaLoadConfig 〓 '
    gg2_file_bin_open(...);
';

Then just do string_execute(global.wareyaLoadConfig, argument)
Title: Re: (meta) Namespace directories and you! (AKA organize your plugin resources...)
Post by: Phantom Brave on June 04, 2012, 02:20:57 am
It's already doing that. The ONLY PROBLEM I'm having is that if the dir is a constant, GM freaks out.
Title: Re: (meta) Namespace directories and you! (AKA organize your plugin resources...)
Post by: Orpheon on June 04, 2012, 06:20:12 am
Yay GM
Title: Re: (meta) Namespace directories and you! (AKA organize your plugin resources...)
Post by: Phantom Brave on March 12, 2013, 10:44:40 am
I should've stickied this a while ago.