November 21, 2024, 06:55:50 am

The Gang Garrison 2 Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

NOTICE: Wondering where all the forums have gone?

Join the community Discord server!

Pages: [1]

Author Topic: Namespaces and you! (AKA organize your plugin resources...)  (Read 7295 times)

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12532
  • Another one --

...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
« Last Edit: April 27, 2013, 06:25:12 pm by Phantom Brave »
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

notajf

  • Guest

I support this convention. Also, maybe put plugin config there too.
Logged

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12532
  • Another one --

Also, maybe put plugin config there too.
possible, I'll try it out
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

notajf

  • Guest

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
Logged

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12532
  • Another one --

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.
« Last Edit: June 04, 2012, 02:07:11 am by Wareya »
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

notajf

  • Guest

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?
Logged

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12532
  • Another one --

It works fine if I use a var. It only breaks when I inline the string.
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

notajf

  • Guest

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)
Logged

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12532
  • Another one --

It's already doing that. The ONLY PROBLEM I'm having is that if the dir is a constant, GM freaks out.
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

Orpheon

  • Moderator
  • *****
  • Karma: 15
  • Offline Offline
  • Posts: 6409
  • Developer

Yay GM
Logged

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12532
  • Another one --

I should've stickied this a while ago.
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters
Pages: [1]
 

Page created in 0.02 seconds with 37 queries.