*Reorganized code so that further expansion is possible in a very organized manner.
*modpol.add_member() -- added a check if the member is already a member of that organized *storage -- fixed bug by moving storageref to top of file *added on_joinplayer to add players to instance *moved minetest specific code in init.lua to modpol_minetest, organized in folders. All overrides in one folder, all chatcommands in another, the on_joinplayer in modpol_minetest/orgs/instance.lua
This commit is contained in:
36
modpol.lua
36
modpol.lua
@ -6,8 +6,7 @@
|
||||
-- Basic tables
|
||||
|
||||
-- Main API table
|
||||
modpol = {
|
||||
}
|
||||
if not modpol then modpol = {} end
|
||||
|
||||
-- Table for modpol data
|
||||
modpol.orgs = {
|
||||
@ -17,14 +16,21 @@ modpol.orgs = {
|
||||
modpol.ledger = {
|
||||
}
|
||||
|
||||
|
||||
-- ===================================================================
|
||||
-- Locate framework top-level directory.
|
||||
|
||||
-- This function is intended for use under Linux and/or UNIX only. It
|
||||
-- This function is intended for use under Linux and/or UNIX only.
|
||||
|
||||
-- It
|
||||
-- returns a relative or absolute path for the framework top-level
|
||||
-- directory without a trailing slash.
|
||||
|
||||
local get_script_dir = function()
|
||||
-- if your application has a different method of getting the script directory,
|
||||
-- then feel free to overwrite this in an init.lua or other such file by first
|
||||
-- defining the modpol table and then defining the get_script_dir() function
|
||||
|
||||
local get_script_dir = modpol.get_script_dir or function()
|
||||
local str = debug.getinfo (2, "S").source:sub (2)
|
||||
str = str:match ("(.*/)") or "."
|
||||
str = str:gsub ("/$", "", 1)
|
||||
@ -40,17 +46,23 @@ print (topdir)
|
||||
-- Load dependencies
|
||||
|
||||
-- OldCoder utilities
|
||||
dofile (topdir .. "/ocutil.lua")
|
||||
dofile (topdir .. "/util/ocutil/ocutil.lua")
|
||||
|
||||
-- ===================================================================
|
||||
-- Persistent storage
|
||||
-- must implement modpol.load_storage() and modpol.store_data()
|
||||
|
||||
|
||||
-- Select a storage method
|
||||
-- -- preferably, declare this in the init.lua that calls modpol.lua This is the default.
|
||||
-- Works with CLI:
|
||||
dofile (topdir .. "/storage-local.lua")
|
||||
modpol.storage_file_path = modpol.storage_file_path or topdir .. "/storage/storage-local.lua"
|
||||
-- Works with Minetest 5:
|
||||
-- dofile (topdir .. "/storage-mod_storage.lua")
|
||||
--modpol.storage_file_path = modpol.storage_file_path or topdir .. "/storage/storage-mod_storage.lua")
|
||||
|
||||
--execute the storage file
|
||||
dofile (modpol.storage_file_path)
|
||||
|
||||
|
||||
-- If available, load persistent storage into active tables
|
||||
modpol.load_storage()
|
||||
@ -58,11 +70,9 @@ modpol.load_storage()
|
||||
-- ===================================================================
|
||||
-- ModPol core features
|
||||
|
||||
dofile (topdir .. "/users.lua")
|
||||
dofile (topdir .. "/orgs.lua")
|
||||
dofile (topdir .. "/interactions.lua")
|
||||
-- messaging functions
|
||||
dofile (topdir .. "/processes.lua")
|
||||
|
||||
dofile (topdir .. "/modpol/api.lua")
|
||||
|
||||
|
||||
-- ===================================================================
|
||||
-- Final checks
|
||||
@ -72,7 +82,7 @@ if (modpol.orgs["instance"] == nil) then
|
||||
modpol.add_org("instance", modpol.list_users())
|
||||
end
|
||||
|
||||
ocutil.log ("modpol loaded")
|
||||
modpol.ocutil.log ("modpol loaded")
|
||||
|
||||
-- ===================================================================
|
||||
-- End of file.
|
||||
|
Reference in New Issue
Block a user