From dc12ec50a91d17ceb861fa9fbfb49c06f6610b97 Mon Sep 17 00:00:00 2001
From: MisterE123 <gbrrudmin@gmail.com>
Date: Thu, 11 Feb 2021 16:39:51 -0500
Subject: [PATCH] Change file structures so that the interior modpol folder IS
 the portable modpol. Added documentation of how to pre-define the modpath and
 the storage file.

---
 init.lua                                      |   6 +--
 {DOCS => modpol/DOCS}/GOVERNANCE.md           |   0
 modpol/DOCS/Predefinitions.txt                |  35 ++++++++++++++++++
 modpol/api.lua                                |   2 +-
 modpol.lua => modpol/modpol.lua               |   2 +-
 {storage => modpol/storage}/storage-local.lua |   0
 {util => modpol/util}/ocutil/ocutil.lua       |   0
 {util => modpol/util}/serpent/LICENSE.txt     |   0
 {util => modpol/util}/serpent/README.md       |   0
 .../util}/serpent/serpent-git.tar.bz2         | Bin
 {util => modpol/util}/serpent/serpent.lua     |   0
 modpol_minetest/api.lua                       |   2 +-
 .../storage}/storage-mod_storage.lua          |   0
 13 files changed, 41 insertions(+), 6 deletions(-)
 rename {DOCS => modpol/DOCS}/GOVERNANCE.md (100%)
 create mode 100644 modpol/DOCS/Predefinitions.txt
 rename modpol.lua => modpol/modpol.lua (98%)
 rename {storage => modpol/storage}/storage-local.lua (100%)
 rename {util => modpol/util}/ocutil/ocutil.lua (100%)
 rename {util => modpol/util}/serpent/LICENSE.txt (100%)
 rename {util => modpol/util}/serpent/README.md (100%)
 rename {util => modpol/util}/serpent/serpent-git.tar.bz2 (100%)
 rename {util => modpol/util}/serpent/serpent.lua (100%)
 rename {storage => modpol_minetest/storage}/storage-mod_storage.lua (100%)

diff --git a/init.lua b/init.lua
index 9a318cd..06928af 100644
--- a/init.lua
+++ b/init.lua
@@ -15,7 +15,7 @@ modpol = {}
 
 -- get modpol_minetest's version of directory
 modpol.get_script_dir = function()
-   return minetest.get_modpath("modpol")
+   return minetest.get_modpath("modpol").."/modpol"
 end
 
 -- TKTK: Implement minetest settingtypes for this... for now, the default is to use minetest mod storage. 
@@ -24,7 +24,7 @@ end
 
 -- works with cmd line: "/storage/storage-local.lua", works with Minetest 5.0 and up: "/storage/storage-mod_storage.lua"
 
-modpol.storage_file_path = minetest.get_modpath("modpol").."/storage/storage-mod_storage.lua"
+modpol.storage_file_path = minetest.get_modpath("modpol").."/modpol_minetest/storage/storage-mod_storage.lua"
 
 -- ===================================================================
 -- /init.lua
@@ -35,7 +35,7 @@ modpol.storage_file_path = minetest.get_modpath("modpol").."/storage/storage-mod
 -- ===================================================================
 -- Load modpol system
 
-dofile(minetest.get_modpath("modpol") .. "/modpol.lua")
+dofile(minetest.get_modpath("modpol") .. "/modpol/modpol.lua")
 
 
 -- ===================================================================
diff --git a/DOCS/GOVERNANCE.md b/modpol/DOCS/GOVERNANCE.md
similarity index 100%
rename from DOCS/GOVERNANCE.md
rename to modpol/DOCS/GOVERNANCE.md
diff --git a/modpol/DOCS/Predefinitions.txt b/modpol/DOCS/Predefinitions.txt
new file mode 100644
index 0000000..8498435
--- /dev/null
+++ b/modpol/DOCS/Predefinitions.txt
@@ -0,0 +1,35 @@
+When calling modpol.lua from another file, one may wish to use 
+different functions than those included by default. 
+
+So far, 2 definitions need to be made BEFORE calling modpol.lua, the rest can be overwritten
+after calling modpol.lua .
+
+setup:
+----------------
+Define the global modpol table:
+modpol = {}
+
+the following 2 items *may* be defined, if they are not, then defaults will be used:
+========================
+--------------------
+modpol.get_script_dir()
+--------------------
+type: function
+
+defaults to: a function that can only work in linux
+
+usage: must return the file path of the modpol directory. If modpol is in a
+larger directory, such as a mod filesystem, make sure that the path returned is the "base" 
+modpol folder, i.e. the folder with all the original modpol files.
+========================
+--------------------
+modpol.storage_file_path
+--------------------
+type: string
+
+defaults to: topdir .. "/storage/storage-local.lua", 
+where topdir is the directory defined by modpol.storage_file_path 
+
+usage: if you wish to use another method of storage than that provided by default, 
+then you can save a filepath to the storage script here. 
+
diff --git a/modpol/api.lua b/modpol/api.lua
index 204eb43..c44cf88 100644
--- a/modpol/api.lua
+++ b/modpol/api.lua
@@ -1,6 +1,6 @@
 --call all files in this directory
 
-local localdir = modpol.get_script_dir() .. "/modpol"
+local localdir = modpol.topdir
 
 --Users
 dofile (localdir .. "/users/users.lua")
diff --git a/modpol.lua b/modpol/modpol.lua
similarity index 98%
rename from modpol.lua
rename to modpol/modpol.lua
index 62246dc..b0d2ce7 100644
--- a/modpol.lua
+++ b/modpol/modpol.lua
@@ -71,7 +71,7 @@ modpol.load_storage()
 -- ModPol core features
 
 
-dofile (topdir .. "/modpol/api.lua")
+dofile (topdir .. "/api.lua")
 
 
 -- ===================================================================
diff --git a/storage/storage-local.lua b/modpol/storage/storage-local.lua
similarity index 100%
rename from storage/storage-local.lua
rename to modpol/storage/storage-local.lua
diff --git a/util/ocutil/ocutil.lua b/modpol/util/ocutil/ocutil.lua
similarity index 100%
rename from util/ocutil/ocutil.lua
rename to modpol/util/ocutil/ocutil.lua
diff --git a/util/serpent/LICENSE.txt b/modpol/util/serpent/LICENSE.txt
similarity index 100%
rename from util/serpent/LICENSE.txt
rename to modpol/util/serpent/LICENSE.txt
diff --git a/util/serpent/README.md b/modpol/util/serpent/README.md
similarity index 100%
rename from util/serpent/README.md
rename to modpol/util/serpent/README.md
diff --git a/util/serpent/serpent-git.tar.bz2 b/modpol/util/serpent/serpent-git.tar.bz2
similarity index 100%
rename from util/serpent/serpent-git.tar.bz2
rename to modpol/util/serpent/serpent-git.tar.bz2
diff --git a/util/serpent/serpent.lua b/modpol/util/serpent/serpent.lua
similarity index 100%
rename from util/serpent/serpent.lua
rename to modpol/util/serpent/serpent.lua
diff --git a/modpol_minetest/api.lua b/modpol_minetest/api.lua
index 37d6c5d..800b8c5 100644
--- a/modpol_minetest/api.lua
+++ b/modpol_minetest/api.lua
@@ -7,7 +7,7 @@
 -- ===================================================================
 
 
-local localdir = modpol.get_script_dir() .. "/modpol_minetest"
+local localdir = minetest.get_modpath("modpol") .. "/modpol_minetest"
 
 --Users
 dofile (localdir .. "/overrides/users/users.lua")
diff --git a/storage/storage-mod_storage.lua b/modpol_minetest/storage/storage-mod_storage.lua
similarity index 100%
rename from storage/storage-mod_storage.lua
rename to modpol_minetest/storage/storage-mod_storage.lua