added WEA Core

This commit is contained in:
VorTechnix 2021-06-29 18:53:14 -07:00
parent d65fe98de6
commit ba93cb7bea
6 changed files with 88 additions and 0 deletions

View 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")

View 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

View 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")

View 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

View 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

View file

@ -0,0 +1,5 @@
--- WorldEdit dependencies for WorldEditAdditions
worldedit = {
registered_commands = {}
}