• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Marin's Compiler

971
Posts
7
Years
  • Age 21
  • Seen Nov 28, 2022
The main inspiration to make this was the lack of plug-and-play support of the standard Compiler that comes with Essentials. You can't add a PBS file in a new script section without editing the Compiler script, and you therefore lose plug-and-play support, which I think is super important.

This is more or less useless as-is, but it will be used for some of my future resources. That said, anyone else is free (and I actually advise) to use this for their own plugins. This means that you must have decent Ruby skills to understand any of what I'm gonna say. That said, if you ARE a programmer but are confused about anything, feel free to ask.



Installation
First off, install Marin's Scripting Utilities.

Nexf, you need to download this script section.
If there are any plugins that use this compiler, you have to put it above that plugin. Currently, there are no plugins that use this, so you don't need to worry about this.
MarinCompiler

However, this is not all. This only provides the functionality so far, it does NOT actually compile or load the files. To allow other plugins to use this, we have to compile/load the files after those plugins have had the time to register their PBS files. Therefore, you have to add two lines at the VERY top of the Main script:
Code:
MarinCompiler.compile_where_necessary
MarinCompiler.load





Documentation

To force the compiler to compile, hold SHIFT. Not CTRL, SHIFT. This so the default compiler and this custom compiler don't BOTH recompile.
That said, it will automatically compile anyway if it detects changes in any of the PBS files. It will ONLY recompile THOSE files with changes; not all of them!

MarinCompiler.compile_where_necessary goes through each file and determines whether or not it has to be recompiled, and if so, it will compile the PBS file. If the PBS does NOT exist but the data files DOES, it will try to decompile the PBS file into the PBS file. For this to work, your custom PBS file must implement a decompile option. This has to be done manually by loading the data file and writing those options to a text file, and then save it to your desired destination.

MarinCompiler.load Loads every single registered data file, whether they've previously been compiled or not.

First off, MarinCompiler.register(pbs_file,data_file,compile_proc,load_proc,decompile_proc = nil) is the method you need to use:

  • pbs_file : This is the path of the file in the PBS folder.
  • data_file : This is the path of the file in the Data that contains the compiled PBS file data.
  • compile_proc : This is the code that will be run when this PBS file is compiled.
  • load_proc : This is the code that will be run when this Data file needs to be loaded.
  • decompile_proc (OPTIONAL) : If there is a Data file but not a PBS file, this is the code that will be run to create a PBS file with the Ruby data. This is completely optional, but similar to methods like pbSaveAbilities. It may come in handy when one has lost their PBS files but still has their data files; well-worth including.

The compile proc is different depending on the type of PBS file you have. There are two main types you can make with this resource; comma based and section based:

The comma/line-based compiler:
Spoiler:




The section-based compiler:
Spoiler:


Honestly, you can really mix and match all this stuff. I suggest messing around with it, and to leave a message here if you can't figure something out.

It's pretty hard properly documenting this type of stuff; please don't hesitate to leave a message if you don't understand anything at all.
 
Back
Top