mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-27 17:43:53 +01:00
added WEA Core
This commit is contained in:
parent
d65fe98de6
commit
ba93cb7bea
18
worldeditadditions_core/init.lua
Normal file
18
worldeditadditions_core/init.lua
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
--- WorldEditAdditions-Core
|
||||||
|
-- @module worldeditadditions_core
|
||||||
|
-- @release 1.13
|
||||||
|
-- @copyright 2021 Starbeamrainbowlabs and VorTechnix
|
||||||
|
-- @license Mozilla Public License, 2.0
|
||||||
|
-- @author Starbeamrainbowlabs and VorTechnix
|
||||||
|
|
||||||
|
worldeditadditions_core = {}
|
||||||
|
local we_c = worldeditadditions_core
|
||||||
|
|
||||||
|
we_c.modpath = minetest.get_modpath("worldeditadditions_core")
|
||||||
|
|
||||||
|
-- Initialze WorldEdit stuff if the WorldEdit mod is not present
|
||||||
|
if not minetest.get_modpath("worldedit") then
|
||||||
|
dofile(we_c.modpath.."/worldedit/init.lua")
|
||||||
|
end
|
||||||
|
|
||||||
|
dofile(we_c.modpath.."/register/init.lua")
|
14
worldeditadditions_core/register/check.lua
Normal file
14
worldeditadditions_core/register/check.lua
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
function worldeditadditions.register_command(def)
|
||||||
|
local def = table.copy(def)
|
||||||
|
assert(name and #name > 0)
|
||||||
|
assert(def.privs)
|
||||||
|
def.require_pos = def.require_pos or 0
|
||||||
|
assert(def.require_pos >= 0 and def.require_pos < 3)
|
||||||
|
if def.params == "" and not def.parse then
|
||||||
|
def.parse = function(param) return true end
|
||||||
|
else
|
||||||
|
assert(def.parse)
|
||||||
|
end
|
||||||
|
assert(def.nodes_needed == nil or type(def.nodes_needed) == "function")
|
||||||
|
assert(def.func)
|
||||||
|
end
|
15
worldeditadditions_core/register/init.lua
Normal file
15
worldeditadditions_core/register/init.lua
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
-- ██████ ███████ ██████ ██ ███████ ████████ ███████ ██████
|
||||||
|
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||||
|
-- ██████ █████ ██ ███ ██ ███████ ██ █████ ██████
|
||||||
|
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||||
|
-- ██ ██ ███████ ██████ ██ ███████ ██ ███████ ██ ██
|
||||||
|
|
||||||
|
-- WorldEditAdditions Register/Overwrite Functions
|
||||||
|
|
||||||
|
--TODO: Replicate chatcommand_handler functionality (worldedit_commands/init.lua line 21-60)
|
||||||
|
|
||||||
|
local we_cm = worldeditadditions_core.modpath .. "/register/"
|
||||||
|
|
||||||
|
dofile(we_cm.."check.lua")
|
||||||
|
dofile(we_cm.."register.lua")
|
||||||
|
dofile(we_cm.."override.lua")
|
18
worldeditadditions_core/register/override.lua
Normal file
18
worldeditadditions_core/register/override.lua
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
local we_c = worldeditadditions_core
|
||||||
|
function we_c.override_command(name, def)
|
||||||
|
local success, def = we_c.check(def)
|
||||||
|
|
||||||
|
if not success then
|
||||||
|
return false, def
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.override_chatcommand("/" .. name, {
|
||||||
|
privs = def.privs,
|
||||||
|
params = def.params,
|
||||||
|
description = def.description,
|
||||||
|
func = function(player_name, param)
|
||||||
|
return chatcommand_handler(name, player_name, param)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
worldedit.registered_commands[name] = def
|
||||||
|
end
|
18
worldeditadditions_core/register/register.lua
Normal file
18
worldeditadditions_core/register/register.lua
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
local we_c = worldeditadditions_core
|
||||||
|
function we_c.register_command(name, def)
|
||||||
|
local success, def = we_c.check(def)
|
||||||
|
|
||||||
|
if not success then
|
||||||
|
return false, def
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_chatcommand("/" .. name, {
|
||||||
|
privs = def.privs,
|
||||||
|
params = def.params,
|
||||||
|
description = def.description,
|
||||||
|
func = function(player_name, param)
|
||||||
|
return chatcommand_handler(name, player_name, param)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
worldedit.registered_commands[name] = def
|
||||||
|
end
|
5
worldeditadditions_core/worldedit/init.lua
Normal file
5
worldeditadditions_core/worldedit/init.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
--- WorldEdit dependencies for WorldEditAdditions
|
||||||
|
|
||||||
|
worldedit = {
|
||||||
|
registered_commands = {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user