split into 3 mods in a modpack
17
gems/init.lua
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
gems = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_privilege("gems_admin", "Set up Gems arenas")
|
||||||
|
|
||||||
|
|
||||||
|
dofile(minetest.get_modpath("gems") .. "/api.lua")
|
||||||
|
|
||||||
|
dofile(minetest.get_modpath("gems") .. "/nodes.lua")
|
||||||
|
dofile(minetest.get_modpath("gems") .. "/shop.lua")
|
||||||
|
dofile(minetest.get_modpath("gems") .. "/armor.lua")
|
||||||
|
dofile(minetest.get_modpath("gems") .. "/items.lua")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
0
gems/mod.conf
Normal file
Before Width: | Height: | Size: 731 B After Width: | Height: | Size: 731 B |
Before Width: | Height: | Size: 720 B After Width: | Height: | Size: 720 B |
Before Width: | Height: | Size: 736 B After Width: | Height: | Size: 736 B |
Before Width: | Height: | Size: 749 B After Width: | Height: | Size: 749 B |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 677 B After Width: | Height: | Size: 677 B |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 752 B After Width: | Height: | Size: 752 B |
Before Width: | Height: | Size: 766 B After Width: | Height: | Size: 766 B |
Before Width: | Height: | Size: 771 B After Width: | Height: | Size: 771 B |
Before Width: | Height: | Size: 775 B After Width: | Height: | Size: 775 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 328 B After Width: | Height: | Size: 328 B |
Before Width: | Height: | Size: 363 B After Width: | Height: | Size: 363 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 703 B After Width: | Height: | Size: 703 B |
Before Width: | Height: | Size: 726 B After Width: | Height: | Size: 726 B |
Before Width: | Height: | Size: 700 B After Width: | Height: | Size: 700 B |
Before Width: | Height: | Size: 756 B After Width: | Height: | Size: 756 B |
Before Width: | Height: | Size: 750 B After Width: | Height: | Size: 750 B |
Before Width: | Height: | Size: 758 B After Width: | Height: | Size: 758 B |
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 183 B |
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 322 B After Width: | Height: | Size: 322 B |
Before Width: | Height: | Size: 317 B After Width: | Height: | Size: 317 B |
Before Width: | Height: | Size: 702 B After Width: | Height: | Size: 702 B |
Before Width: | Height: | Size: 664 B After Width: | Height: | Size: 664 B |
Before Width: | Height: | Size: 715 B After Width: | Height: | Size: 715 B |
Before Width: | Height: | Size: 168 B After Width: | Height: | Size: 168 B |
@ -19,12 +19,6 @@ arena_lib.on_load('gems_2', function(arena)
|
|||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
arena_lib.on_load('gems_4', function(arena)
|
|
||||||
|
|
||||||
gems.place_arena(arena)
|
|
||||||
worldedit.keep_loaded(arena.area_to_clear_pos_1, arena.area_to_clear_pos_2)
|
|
||||||
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -39,12 +33,6 @@ arena_lib.on_start('gems_2', function(arena)
|
|||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
arena_lib.on_start('gems_4', function(arena)
|
|
||||||
|
|
||||||
worldedit.keep_loaded(arena.area_to_clear_pos_1, arena.area_to_clear_pos_2)
|
|
||||||
gems.clearobjects(arena.area_to_clear_pos_1, arena.area_to_clear_pos_2)
|
|
||||||
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- TODO: add HUD
|
-- TODO: add HUD
|
||||||
|
|
||||||
@ -61,12 +49,6 @@ arena_lib.on_death('gems_2', function(arena, p_name, reason)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
arena_lib.on_death('gems_4', function(arena, p_name, reason)
|
|
||||||
|
|
||||||
gems.on_death( arena , p_name , reason )
|
|
||||||
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
--####################################################################
|
--####################################################################
|
||||||
--################ ON TIME_TICK #######################
|
--################ ON TIME_TICK #######################
|
||||||
@ -81,12 +63,3 @@ arena_lib.on_time_tick('gems_2', function(arena)
|
|||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
arena_lib.on_time_tick('gems_4', function(arena)
|
|
||||||
|
|
||||||
worldedit.keep_loaded(arena.area_to_clear_pos_1, arena.area_to_clear_pos_2)
|
|
||||||
local teams = {"ruby","sapphire","emerald", "opal"}
|
|
||||||
|
|
||||||
gems.on_time_tick(arena,teams)
|
|
||||||
end)
|
|
||||||
|
|
306
gems_2/chatcmdbuilder.lua
Normal file
@ -0,0 +1,306 @@
|
|||||||
|
ChatCmdBuilder = {}
|
||||||
|
|
||||||
|
function ChatCmdBuilder.new(name, func, def)
|
||||||
|
def = def or {}
|
||||||
|
local cmd = ChatCmdBuilder.build(func)
|
||||||
|
cmd.def = def
|
||||||
|
def.func = cmd.run
|
||||||
|
minetest.register_chatcommand(name, def)
|
||||||
|
return cmd
|
||||||
|
end
|
||||||
|
|
||||||
|
local STATE_READY = 1
|
||||||
|
local STATE_PARAM = 2
|
||||||
|
local STATE_PARAM_TYPE = 3
|
||||||
|
local bad_chars = {}
|
||||||
|
bad_chars["("] = true
|
||||||
|
bad_chars[")"] = true
|
||||||
|
bad_chars["."] = true
|
||||||
|
bad_chars["%"] = true
|
||||||
|
bad_chars["+"] = true
|
||||||
|
bad_chars["-"] = true
|
||||||
|
bad_chars["*"] = true
|
||||||
|
bad_chars["?"] = true
|
||||||
|
bad_chars["["] = true
|
||||||
|
bad_chars["^"] = true
|
||||||
|
bad_chars["$"] = true
|
||||||
|
local function escape(char)
|
||||||
|
if bad_chars[char] then
|
||||||
|
return "%" .. char
|
||||||
|
else
|
||||||
|
return char
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local dprint = function() end
|
||||||
|
|
||||||
|
ChatCmdBuilder.types = {
|
||||||
|
pos = "%(? *(%-?[%d.]+) *, *(%-?[%d.]+) *, *(%-?[%d.]+) *%)?",
|
||||||
|
text = "(.+)",
|
||||||
|
number = "(%-?[%d.]+)",
|
||||||
|
int = "(%-?[%d]+)",
|
||||||
|
word = "([^ ]+)",
|
||||||
|
alpha = "([A-Za-z]+)",
|
||||||
|
modname = "([a-z0-9_]+)",
|
||||||
|
alphascore = "([A-Za-z_]+)",
|
||||||
|
alphanumeric = "([A-Za-z0-9]+)",
|
||||||
|
username = "([A-Za-z0-9-_]+)",
|
||||||
|
}
|
||||||
|
|
||||||
|
function ChatCmdBuilder.build(func)
|
||||||
|
local cmd = {
|
||||||
|
_subs = {}
|
||||||
|
}
|
||||||
|
function cmd:sub(route, func, def)
|
||||||
|
dprint("Parsing " .. route)
|
||||||
|
|
||||||
|
def = def or {}
|
||||||
|
if string.trim then
|
||||||
|
route = string.trim(route)
|
||||||
|
end
|
||||||
|
|
||||||
|
local sub = {
|
||||||
|
pattern = "^",
|
||||||
|
params = {},
|
||||||
|
func = func
|
||||||
|
}
|
||||||
|
|
||||||
|
-- End of param reached: add it to the pattern
|
||||||
|
local param = ""
|
||||||
|
local param_type = ""
|
||||||
|
local should_be_eos = false
|
||||||
|
local function finishParam()
|
||||||
|
if param ~= "" and param_type ~= "" then
|
||||||
|
dprint(" - Found param " .. param .. " type " .. param_type)
|
||||||
|
|
||||||
|
local pattern = ChatCmdBuilder.types[param_type]
|
||||||
|
if not pattern then
|
||||||
|
error("Unrecognised param_type=" .. param_type)
|
||||||
|
end
|
||||||
|
|
||||||
|
sub.pattern = sub.pattern .. pattern
|
||||||
|
|
||||||
|
table.insert(sub.params, param_type)
|
||||||
|
|
||||||
|
param = ""
|
||||||
|
param_type = ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Iterate through the route to find params
|
||||||
|
local state = STATE_READY
|
||||||
|
local catching_space = false
|
||||||
|
local match_space = " " -- change to "%s" to also catch tabs and newlines
|
||||||
|
local catch_space = match_space.."+"
|
||||||
|
for i = 1, #route do
|
||||||
|
local c = route:sub(i, i)
|
||||||
|
if should_be_eos then
|
||||||
|
error("Should be end of string. Nothing is allowed after a param of type text.")
|
||||||
|
end
|
||||||
|
|
||||||
|
if state == STATE_READY then
|
||||||
|
if c == ":" then
|
||||||
|
dprint(" - Found :, entering param")
|
||||||
|
state = STATE_PARAM
|
||||||
|
param_type = "word"
|
||||||
|
catching_space = false
|
||||||
|
elseif c:match(match_space) then
|
||||||
|
print(" - Found space")
|
||||||
|
if not catching_space then
|
||||||
|
catching_space = true
|
||||||
|
sub.pattern = sub.pattern .. catch_space
|
||||||
|
end
|
||||||
|
else
|
||||||
|
catching_space = false
|
||||||
|
sub.pattern = sub.pattern .. escape(c)
|
||||||
|
end
|
||||||
|
elseif state == STATE_PARAM then
|
||||||
|
if c == ":" then
|
||||||
|
dprint(" - Found :, entering param type")
|
||||||
|
state = STATE_PARAM_TYPE
|
||||||
|
param_type = ""
|
||||||
|
elseif c:match(match_space) then
|
||||||
|
print(" - Found whitespace, leaving param")
|
||||||
|
state = STATE_READY
|
||||||
|
finishParam()
|
||||||
|
catching_space = true
|
||||||
|
sub.pattern = sub.pattern .. catch_space
|
||||||
|
elseif c:match("%W") then
|
||||||
|
dprint(" - Found nonalphanum, leaving param")
|
||||||
|
state = STATE_READY
|
||||||
|
finishParam()
|
||||||
|
sub.pattern = sub.pattern .. escape(c)
|
||||||
|
else
|
||||||
|
param = param .. c
|
||||||
|
end
|
||||||
|
elseif state == STATE_PARAM_TYPE then
|
||||||
|
if c:match(match_space) then
|
||||||
|
print(" - Found space, leaving param type")
|
||||||
|
state = STATE_READY
|
||||||
|
finishParam()
|
||||||
|
catching_space = true
|
||||||
|
sub.pattern = sub.pattern .. catch_space
|
||||||
|
elseif c:match("%W") then
|
||||||
|
dprint(" - Found nonalphanum, leaving param type")
|
||||||
|
state = STATE_READY
|
||||||
|
finishParam()
|
||||||
|
sub.pattern = sub.pattern .. escape(c)
|
||||||
|
else
|
||||||
|
param_type = param_type .. c
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
dprint(" - End of route")
|
||||||
|
finishParam()
|
||||||
|
sub.pattern = sub.pattern .. "$"
|
||||||
|
dprint("Pattern: " .. sub.pattern)
|
||||||
|
|
||||||
|
table.insert(self._subs, sub)
|
||||||
|
end
|
||||||
|
|
||||||
|
if func then
|
||||||
|
func(cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
cmd.run = function(name, param)
|
||||||
|
for i = 1, #cmd._subs do
|
||||||
|
local sub = cmd._subs[i]
|
||||||
|
local res = { string.match(param, sub.pattern) }
|
||||||
|
if #res > 0 then
|
||||||
|
local pointer = 1
|
||||||
|
local params = { name }
|
||||||
|
for j = 1, #sub.params do
|
||||||
|
local param = sub.params[j]
|
||||||
|
if param == "pos" then
|
||||||
|
local pos = {
|
||||||
|
x = tonumber(res[pointer]),
|
||||||
|
y = tonumber(res[pointer + 1]),
|
||||||
|
z = tonumber(res[pointer + 2])
|
||||||
|
}
|
||||||
|
table.insert(params, pos)
|
||||||
|
pointer = pointer + 3
|
||||||
|
elseif param == "number" or param == "int" then
|
||||||
|
table.insert(params, tonumber(res[pointer]))
|
||||||
|
pointer = pointer + 1
|
||||||
|
else
|
||||||
|
table.insert(params, res[pointer])
|
||||||
|
pointer = pointer + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if table.unpack then
|
||||||
|
-- lua 5.2 or later
|
||||||
|
return sub.func(table.unpack(params))
|
||||||
|
else
|
||||||
|
-- lua 5.1 or earlier
|
||||||
|
return sub.func(unpack(params))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false, "Invalid command"
|
||||||
|
end
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
end
|
||||||
|
|
||||||
|
local function run_tests()
|
||||||
|
if not (ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("bar :one and :two:word", function(name, one, two)
|
||||||
|
if name == "singleplayer" and one == "abc" and two == "def" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)).run("singleplayer", "bar abc and def") then
|
||||||
|
error("Test 1 failed")
|
||||||
|
end
|
||||||
|
|
||||||
|
local move = ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("move :target to :pos:pos", function(name, target, pos)
|
||||||
|
if name == "singleplayer" and target == "player1" and
|
||||||
|
pos.x == 0 and pos.y == 1 and pos.z == 2 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end).run
|
||||||
|
if not move("singleplayer", "move player1 to 0,1,2") then
|
||||||
|
error("Test 2 failed")
|
||||||
|
end
|
||||||
|
if not move("singleplayer", "move player1 to (0,1,2)") then
|
||||||
|
error("Test 3 failed")
|
||||||
|
end
|
||||||
|
if not move("singleplayer", "move player1 to 0, 1,2") then
|
||||||
|
error("Test 4 failed")
|
||||||
|
end
|
||||||
|
if not move("singleplayer", "move player1 to 0 ,1, 2") then
|
||||||
|
error("Test 5 failed")
|
||||||
|
end
|
||||||
|
if not move("singleplayer", "move player1 to 0, 1, 2") then
|
||||||
|
error("Test 6 failed")
|
||||||
|
end
|
||||||
|
if not move("singleplayer", "move player1 to 0 ,1 ,2") then
|
||||||
|
error("Test 7 failed")
|
||||||
|
end
|
||||||
|
if not move("singleplayer", "move player1 to ( 0 ,1 ,2)") then
|
||||||
|
error("Test 8 failed")
|
||||||
|
end
|
||||||
|
if move("singleplayer", "move player1 to abc,def,sdosd") then
|
||||||
|
error("Test 9 failed")
|
||||||
|
end
|
||||||
|
if move("singleplayer", "move player1 to abc def sdosd") then
|
||||||
|
error("Test 10 failed")
|
||||||
|
end
|
||||||
|
|
||||||
|
if not (ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("does :one:int plus :two:int equal :three:int", function(name, one, two, three)
|
||||||
|
if name == "singleplayer" and one + two == three then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)).run("singleplayer", "does 1 plus 2 equal 3") then
|
||||||
|
error("Test 11 failed")
|
||||||
|
end
|
||||||
|
|
||||||
|
local checknegint = ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("checknegint :x:int", function(name, x)
|
||||||
|
return x
|
||||||
|
end)
|
||||||
|
end).run
|
||||||
|
if checknegint("checker","checknegint -2") ~= -2 then
|
||||||
|
error("Test 12 failed")
|
||||||
|
end
|
||||||
|
|
||||||
|
local checknegnumber = ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("checknegnumber :x:number", function(name, x)
|
||||||
|
return x
|
||||||
|
end)
|
||||||
|
end).run
|
||||||
|
if checknegnumber("checker","checknegnumber -3.3") ~= -3.3 then
|
||||||
|
error("Test 13 failed")
|
||||||
|
end
|
||||||
|
|
||||||
|
local checknegpos = ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("checknegpos :pos:pos", function(name, pos)
|
||||||
|
return pos
|
||||||
|
end)
|
||||||
|
end).run
|
||||||
|
local negpos = checknegpos("checker","checknegpos (-13.3,-4.6,-1234.5)")
|
||||||
|
if negpos.x ~= -13.3 or negpos.y ~= -4.6 or negpos.z ~= -1234.5 then
|
||||||
|
error("Test 14 failed")
|
||||||
|
end
|
||||||
|
|
||||||
|
local checktypes = ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("checktypes :int:int :number:number :pos:pos :word:word :text:text", function(name, int, number, pos, word, text)
|
||||||
|
return int, number, pos.x, pos.y, pos.z, word, text
|
||||||
|
end)
|
||||||
|
end).run
|
||||||
|
local int, number, posx, posy, posz, word, text
|
||||||
|
int, number, posx, posy, posz, word, text = checktypes("checker","checktypes -1 -2.4 (-3,-5.3,6.12) some text to finish off with")
|
||||||
|
--dprint(int, number, posx, posy, posz, word, text)
|
||||||
|
if int ~= -1 or number ~= -2.4 or posx ~= -3 or posy ~= -5.3 or posz ~= 6.12 or word ~= "some" or text ~= "text to finish off with" then
|
||||||
|
error("Test 15 failed")
|
||||||
|
end
|
||||||
|
dprint("All tests passed")
|
||||||
|
|
||||||
|
end
|
||||||
|
if not minetest then
|
||||||
|
run_tests()
|
||||||
|
end
|
95
gems_2/init.lua
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
|
||||||
|
if not minetest.get_modpath("lib_chatcmdbuilder") then
|
||||||
|
dofile(minetest.get_modpath("gems") .. "/chatcmdbuilder.lua")
|
||||||
|
end
|
||||||
|
|
||||||
|
arena_lib.register_minigame("gems_2", {
|
||||||
|
|
||||||
|
prefix = "[Gems]",
|
||||||
|
show_minimap = true,
|
||||||
|
teams = {
|
||||||
|
"ruby", -- red
|
||||||
|
"emerald", --green
|
||||||
|
},
|
||||||
|
teams_color_overlay = { "red", "green", },
|
||||||
|
properties = {
|
||||||
|
schem_name = "You_dont_need_the_file_extention",
|
||||||
|
schem_location = { x = 0, y = 0, z = 0 },
|
||||||
|
area_to_clear_pos_1 = { x = 0, y = 0, z = 0 },
|
||||||
|
area_to_clear_pos_2 = { x = 0, y = 0, z = 0 },
|
||||||
|
ruby_gem = { x = 0, y = 0, z = 0 },
|
||||||
|
emerald_gem = { x = 0, y = 0, z = 0 },
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
team_properties = {
|
||||||
|
gem_exists = true,
|
||||||
|
},
|
||||||
|
disabled_damage_types = {},
|
||||||
|
is_team_chat_default = false,
|
||||||
|
time_mode = "incremental",
|
||||||
|
join_while_in_progress = true,
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dofile(minetest.get_modpath("gems_2") .. "/auto.lua")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ChatCmdBuilder.new("gems_2", function(cmd)
|
||||||
|
-- create arena
|
||||||
|
cmd:sub("create :arena", function(name, arena_name)
|
||||||
|
arena_lib.create_arena(name, "gems_2", arena_name)
|
||||||
|
end)
|
||||||
|
|
||||||
|
cmd:sub("create :arena :minplayers:int :maxplayers:int", function(name, arena_name, min_players, max_players)
|
||||||
|
arena_lib.create_arena(name, "gems_2", arena_name, min_players, max_players)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- remove arena
|
||||||
|
cmd:sub("remove :arena", function(name, arena_name)
|
||||||
|
arena_lib.remove_arena(name, "gems_2", arena_name)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- list of the arenas
|
||||||
|
cmd:sub("list", function(name)
|
||||||
|
arena_lib.print_arenas(name, "gems_2")
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- enter editor mode
|
||||||
|
cmd:sub("edit :arena", function(sender, arena)
|
||||||
|
arena_lib.enter_editor(sender, "gems_2", arena)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- enable and disable arenas
|
||||||
|
cmd:sub("enable :arena", function(name, arena)
|
||||||
|
arena_lib.enable_arena(name, "gems_2", arena)
|
||||||
|
end)
|
||||||
|
|
||||||
|
cmd:sub("disable :arena", function(name, arena)
|
||||||
|
arena_lib.disable_arena(name, "gems_2", arena)
|
||||||
|
end)
|
||||||
|
|
||||||
|
end, {
|
||||||
|
description = [[
|
||||||
|
|
||||||
|
(/help gems_2)
|
||||||
|
|
||||||
|
Use this to configure your arena:
|
||||||
|
- create <arena name> [min players] [max players]
|
||||||
|
- edit <arena name>
|
||||||
|
- enable <arena name>
|
||||||
|
|
||||||
|
Other commands:
|
||||||
|
- remove <arena name>
|
||||||
|
- disable <arena>
|
||||||
|
]],
|
||||||
|
privs = {
|
||||||
|
gems_admin = true
|
||||||
|
},
|
||||||
|
})
|
36
gems_2/license.txt
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
hex_crystal_big.obj = CC0 Facedeer
|
||||||
|
glow<gem>.png,glow<gem>4x.png = WTFPL HeroOfTheWinds
|
||||||
|
shield textures modified by MisterE, Copyright (C) 2017-2019 davidthecreator - CC-BY-SA 3.0
|
||||||
|
|
||||||
|
thx to elceejo for bugfixes and code snippets
|
||||||
|
|
||||||
|
Code MIT (C) MisterE <MisterE@ircnow.org>, debiankaios
|
||||||
|
|
||||||
|
|
||||||
|
shops formspecs modified by MisterE from mesewars (gems.shop in api.lua), Copyright (c) 2019-date, Lejo <Lejo_1@web.de>, MIT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
4
gems_2/mod.conf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
name = gems_2
|
||||||
|
description = a minigame similar to eggwars
|
||||||
|
depends = gems, arena_lib, worldedit, 3d_armor
|
||||||
|
depends_optional = server_manager
|
12
gems_2/sounds/BGM license and info
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
============================================================
|
||||||
|
Music by audionautix.com
|
||||||
|
CC by 4.0
|
||||||
|
https://creativecommons.org/licenses/by/4.0/
|
||||||
|
|
||||||
|
Remember the Heroes - RememberTheHeroes
|
||||||
|
Search and Destroy
|
||||||
|
The Voyage
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
============================================================
|
BIN
gems_2/sounds/SearchAndDestroy.ogg
Normal file
BIN
gems_2/sounds/TheVoyage.ogg
Normal file
68
gems_4/auto.lua
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
-- What needs to happen is:
|
||||||
|
-- On_load: 1) set the schem, 2) clear the objects, 3) Take the gem locations out of arena properties and store them in team properties
|
||||||
|
-- on start, set huds, eventually, not a priority (TODO)
|
||||||
|
-- on_death, check if gem exists. If it does, send the player back to a spawner. If not, then eliminate the player
|
||||||
|
-- on_time_tick, 1) handle mine drops, 2) check if the great gem is at the location of each team's great gem location:
|
||||||
|
-- if it is not, set that team's properties to indicate gem_exists = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--####################################################################
|
||||||
|
--################ ON LOAD #######################
|
||||||
|
--####################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
arena_lib.on_load('gems_4', function(arena)
|
||||||
|
|
||||||
|
gems.place_arena(arena)
|
||||||
|
worldedit.keep_loaded(arena.area_to_clear_pos_1, arena.area_to_clear_pos_2)
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--####################################################################
|
||||||
|
--################ ON START #######################
|
||||||
|
--####################################################################
|
||||||
|
|
||||||
|
|
||||||
|
arena_lib.on_start('gems_4', function(arena)
|
||||||
|
|
||||||
|
worldedit.keep_loaded(arena.area_to_clear_pos_1, arena.area_to_clear_pos_2)
|
||||||
|
gems.clearobjects(arena.area_to_clear_pos_1, arena.area_to_clear_pos_2)
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- TODO: add HUD
|
||||||
|
|
||||||
|
|
||||||
|
--####################################################################
|
||||||
|
--################ ON DEATH #######################
|
||||||
|
--####################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
arena_lib.on_death('gems_4', function(arena, p_name, reason)
|
||||||
|
|
||||||
|
gems.on_death( arena , p_name , reason )
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
--####################################################################
|
||||||
|
--################ ON TIME_TICK #######################
|
||||||
|
--####################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
arena_lib.on_time_tick('gems_4', function(arena)
|
||||||
|
|
||||||
|
worldedit.keep_loaded(arena.area_to_clear_pos_1, arena.area_to_clear_pos_2)
|
||||||
|
local teams = {"ruby","sapphire","emerald", "opal"}
|
||||||
|
|
||||||
|
gems.on_time_tick(arena,teams)
|
||||||
|
end)
|
||||||
|
|
306
gems_4/chatcmdbuilder.lua
Normal file
@ -0,0 +1,306 @@
|
|||||||
|
ChatCmdBuilder = {}
|
||||||
|
|
||||||
|
function ChatCmdBuilder.new(name, func, def)
|
||||||
|
def = def or {}
|
||||||
|
local cmd = ChatCmdBuilder.build(func)
|
||||||
|
cmd.def = def
|
||||||
|
def.func = cmd.run
|
||||||
|
minetest.register_chatcommand(name, def)
|
||||||
|
return cmd
|
||||||
|
end
|
||||||
|
|
||||||
|
local STATE_READY = 1
|
||||||
|
local STATE_PARAM = 2
|
||||||
|
local STATE_PARAM_TYPE = 3
|
||||||
|
local bad_chars = {}
|
||||||
|
bad_chars["("] = true
|
||||||
|
bad_chars[")"] = true
|
||||||
|
bad_chars["."] = true
|
||||||
|
bad_chars["%"] = true
|
||||||
|
bad_chars["+"] = true
|
||||||
|
bad_chars["-"] = true
|
||||||
|
bad_chars["*"] = true
|
||||||
|
bad_chars["?"] = true
|
||||||
|
bad_chars["["] = true
|
||||||
|
bad_chars["^"] = true
|
||||||
|
bad_chars["$"] = true
|
||||||
|
local function escape(char)
|
||||||
|
if bad_chars[char] then
|
||||||
|
return "%" .. char
|
||||||
|
else
|
||||||
|
return char
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local dprint = function() end
|
||||||
|
|
||||||
|
ChatCmdBuilder.types = {
|
||||||
|
pos = "%(? *(%-?[%d.]+) *, *(%-?[%d.]+) *, *(%-?[%d.]+) *%)?",
|
||||||
|
text = "(.+)",
|
||||||
|
number = "(%-?[%d.]+)",
|
||||||
|
int = "(%-?[%d]+)",
|
||||||
|
word = "([^ ]+)",
|
||||||
|
alpha = "([A-Za-z]+)",
|
||||||
|
modname = "([a-z0-9_]+)",
|
||||||
|
alphascore = "([A-Za-z_]+)",
|
||||||
|
alphanumeric = "([A-Za-z0-9]+)",
|
||||||
|
username = "([A-Za-z0-9-_]+)",
|
||||||
|
}
|
||||||
|
|
||||||
|
function ChatCmdBuilder.build(func)
|
||||||
|
local cmd = {
|
||||||
|
_subs = {}
|
||||||
|
}
|
||||||
|
function cmd:sub(route, func, def)
|
||||||
|
dprint("Parsing " .. route)
|
||||||
|
|
||||||
|
def = def or {}
|
||||||
|
if string.trim then
|
||||||
|
route = string.trim(route)
|
||||||
|
end
|
||||||
|
|
||||||
|
local sub = {
|
||||||
|
pattern = "^",
|
||||||
|
params = {},
|
||||||
|
func = func
|
||||||
|
}
|
||||||
|
|
||||||
|
-- End of param reached: add it to the pattern
|
||||||
|
local param = ""
|
||||||
|
local param_type = ""
|
||||||
|
local should_be_eos = false
|
||||||
|
local function finishParam()
|
||||||
|
if param ~= "" and param_type ~= "" then
|
||||||
|
dprint(" - Found param " .. param .. " type " .. param_type)
|
||||||
|
|
||||||
|
local pattern = ChatCmdBuilder.types[param_type]
|
||||||
|
if not pattern then
|
||||||
|
error("Unrecognised param_type=" .. param_type)
|
||||||
|
end
|
||||||
|
|
||||||
|
sub.pattern = sub.pattern .. pattern
|
||||||
|
|
||||||
|
table.insert(sub.params, param_type)
|
||||||
|
|
||||||
|
param = ""
|
||||||
|
param_type = ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Iterate through the route to find params
|
||||||
|
local state = STATE_READY
|
||||||
|
local catching_space = false
|
||||||
|
local match_space = " " -- change to "%s" to also catch tabs and newlines
|
||||||
|
local catch_space = match_space.."+"
|
||||||
|
for i = 1, #route do
|
||||||
|
local c = route:sub(i, i)
|
||||||
|
if should_be_eos then
|
||||||
|
error("Should be end of string. Nothing is allowed after a param of type text.")
|
||||||
|
end
|
||||||
|
|
||||||
|
if state == STATE_READY then
|
||||||
|
if c == ":" then
|
||||||
|
dprint(" - Found :, entering param")
|
||||||
|
state = STATE_PARAM
|
||||||
|
param_type = "word"
|
||||||
|
catching_space = false
|
||||||
|
elseif c:match(match_space) then
|
||||||
|
print(" - Found space")
|
||||||
|
if not catching_space then
|
||||||
|
catching_space = true
|
||||||
|
sub.pattern = sub.pattern .. catch_space
|
||||||
|
end
|
||||||
|
else
|
||||||
|
catching_space = false
|
||||||
|
sub.pattern = sub.pattern .. escape(c)
|
||||||
|
end
|
||||||
|
elseif state == STATE_PARAM then
|
||||||
|
if c == ":" then
|
||||||
|
dprint(" - Found :, entering param type")
|
||||||
|
state = STATE_PARAM_TYPE
|
||||||
|
param_type = ""
|
||||||
|
elseif c:match(match_space) then
|
||||||
|
print(" - Found whitespace, leaving param")
|
||||||
|
state = STATE_READY
|
||||||
|
finishParam()
|
||||||
|
catching_space = true
|
||||||
|
sub.pattern = sub.pattern .. catch_space
|
||||||
|
elseif c:match("%W") then
|
||||||
|
dprint(" - Found nonalphanum, leaving param")
|
||||||
|
state = STATE_READY
|
||||||
|
finishParam()
|
||||||
|
sub.pattern = sub.pattern .. escape(c)
|
||||||
|
else
|
||||||
|
param = param .. c
|
||||||
|
end
|
||||||
|
elseif state == STATE_PARAM_TYPE then
|
||||||
|
if c:match(match_space) then
|
||||||
|
print(" - Found space, leaving param type")
|
||||||
|
state = STATE_READY
|
||||||
|
finishParam()
|
||||||
|
catching_space = true
|
||||||
|
sub.pattern = sub.pattern .. catch_space
|
||||||
|
elseif c:match("%W") then
|
||||||
|
dprint(" - Found nonalphanum, leaving param type")
|
||||||
|
state = STATE_READY
|
||||||
|
finishParam()
|
||||||
|
sub.pattern = sub.pattern .. escape(c)
|
||||||
|
else
|
||||||
|
param_type = param_type .. c
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
dprint(" - End of route")
|
||||||
|
finishParam()
|
||||||
|
sub.pattern = sub.pattern .. "$"
|
||||||
|
dprint("Pattern: " .. sub.pattern)
|
||||||
|
|
||||||
|
table.insert(self._subs, sub)
|
||||||
|
end
|
||||||
|
|
||||||
|
if func then
|
||||||
|
func(cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
cmd.run = function(name, param)
|
||||||
|
for i = 1, #cmd._subs do
|
||||||
|
local sub = cmd._subs[i]
|
||||||
|
local res = { string.match(param, sub.pattern) }
|
||||||
|
if #res > 0 then
|
||||||
|
local pointer = 1
|
||||||
|
local params = { name }
|
||||||
|
for j = 1, #sub.params do
|
||||||
|
local param = sub.params[j]
|
||||||
|
if param == "pos" then
|
||||||
|
local pos = {
|
||||||
|
x = tonumber(res[pointer]),
|
||||||
|
y = tonumber(res[pointer + 1]),
|
||||||
|
z = tonumber(res[pointer + 2])
|
||||||
|
}
|
||||||
|
table.insert(params, pos)
|
||||||
|
pointer = pointer + 3
|
||||||
|
elseif param == "number" or param == "int" then
|
||||||
|
table.insert(params, tonumber(res[pointer]))
|
||||||
|
pointer = pointer + 1
|
||||||
|
else
|
||||||
|
table.insert(params, res[pointer])
|
||||||
|
pointer = pointer + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if table.unpack then
|
||||||
|
-- lua 5.2 or later
|
||||||
|
return sub.func(table.unpack(params))
|
||||||
|
else
|
||||||
|
-- lua 5.1 or earlier
|
||||||
|
return sub.func(unpack(params))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false, "Invalid command"
|
||||||
|
end
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
end
|
||||||
|
|
||||||
|
local function run_tests()
|
||||||
|
if not (ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("bar :one and :two:word", function(name, one, two)
|
||||||
|
if name == "singleplayer" and one == "abc" and two == "def" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)).run("singleplayer", "bar abc and def") then
|
||||||
|
error("Test 1 failed")
|
||||||
|
end
|
||||||
|
|
||||||
|
local move = ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("move :target to :pos:pos", function(name, target, pos)
|
||||||
|
if name == "singleplayer" and target == "player1" and
|
||||||
|
pos.x == 0 and pos.y == 1 and pos.z == 2 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end).run
|
||||||
|
if not move("singleplayer", "move player1 to 0,1,2") then
|
||||||
|
error("Test 2 failed")
|
||||||
|
end
|
||||||
|
if not move("singleplayer", "move player1 to (0,1,2)") then
|
||||||
|
error("Test 3 failed")
|
||||||
|
end
|
||||||
|
if not move("singleplayer", "move player1 to 0, 1,2") then
|
||||||
|
error("Test 4 failed")
|
||||||
|
end
|
||||||
|
if not move("singleplayer", "move player1 to 0 ,1, 2") then
|
||||||
|
error("Test 5 failed")
|
||||||
|
end
|
||||||
|
if not move("singleplayer", "move player1 to 0, 1, 2") then
|
||||||
|
error("Test 6 failed")
|
||||||
|
end
|
||||||
|
if not move("singleplayer", "move player1 to 0 ,1 ,2") then
|
||||||
|
error("Test 7 failed")
|
||||||
|
end
|
||||||
|
if not move("singleplayer", "move player1 to ( 0 ,1 ,2)") then
|
||||||
|
error("Test 8 failed")
|
||||||
|
end
|
||||||
|
if move("singleplayer", "move player1 to abc,def,sdosd") then
|
||||||
|
error("Test 9 failed")
|
||||||
|
end
|
||||||
|
if move("singleplayer", "move player1 to abc def sdosd") then
|
||||||
|
error("Test 10 failed")
|
||||||
|
end
|
||||||
|
|
||||||
|
if not (ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("does :one:int plus :two:int equal :three:int", function(name, one, two, three)
|
||||||
|
if name == "singleplayer" and one + two == three then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)).run("singleplayer", "does 1 plus 2 equal 3") then
|
||||||
|
error("Test 11 failed")
|
||||||
|
end
|
||||||
|
|
||||||
|
local checknegint = ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("checknegint :x:int", function(name, x)
|
||||||
|
return x
|
||||||
|
end)
|
||||||
|
end).run
|
||||||
|
if checknegint("checker","checknegint -2") ~= -2 then
|
||||||
|
error("Test 12 failed")
|
||||||
|
end
|
||||||
|
|
||||||
|
local checknegnumber = ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("checknegnumber :x:number", function(name, x)
|
||||||
|
return x
|
||||||
|
end)
|
||||||
|
end).run
|
||||||
|
if checknegnumber("checker","checknegnumber -3.3") ~= -3.3 then
|
||||||
|
error("Test 13 failed")
|
||||||
|
end
|
||||||
|
|
||||||
|
local checknegpos = ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("checknegpos :pos:pos", function(name, pos)
|
||||||
|
return pos
|
||||||
|
end)
|
||||||
|
end).run
|
||||||
|
local negpos = checknegpos("checker","checknegpos (-13.3,-4.6,-1234.5)")
|
||||||
|
if negpos.x ~= -13.3 or negpos.y ~= -4.6 or negpos.z ~= -1234.5 then
|
||||||
|
error("Test 14 failed")
|
||||||
|
end
|
||||||
|
|
||||||
|
local checktypes = ChatCmdBuilder.build(function(cmd)
|
||||||
|
cmd:sub("checktypes :int:int :number:number :pos:pos :word:word :text:text", function(name, int, number, pos, word, text)
|
||||||
|
return int, number, pos.x, pos.y, pos.z, word, text
|
||||||
|
end)
|
||||||
|
end).run
|
||||||
|
local int, number, posx, posy, posz, word, text
|
||||||
|
int, number, posx, posy, posz, word, text = checktypes("checker","checktypes -1 -2.4 (-3,-5.3,6.12) some text to finish off with")
|
||||||
|
--dprint(int, number, posx, posy, posz, word, text)
|
||||||
|
if int ~= -1 or number ~= -2.4 or posx ~= -3 or posy ~= -5.3 or posz ~= 6.12 or word ~= "some" or text ~= "text to finish off with" then
|
||||||
|
error("Test 15 failed")
|
||||||
|
end
|
||||||
|
dprint("All tests passed")
|
||||||
|
|
||||||
|
end
|
||||||
|
if not minetest then
|
||||||
|
run_tests()
|
||||||
|
end
|
104
gems_4/init.lua
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
|
||||||
|
|
||||||
|
if not minetest.get_modpath("lib_chatcmdbuilder") then
|
||||||
|
dofile(minetest.get_modpath("gems") .. "/chatcmdbuilder.lua")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
arena_lib.register_minigame("gems_4", {
|
||||||
|
|
||||||
|
prefix = "[Gems]",
|
||||||
|
show_minimap = true,
|
||||||
|
teams = {
|
||||||
|
"ruby", -- red
|
||||||
|
"sapphire", --blue
|
||||||
|
"emerald", --green
|
||||||
|
"opal", --yellow
|
||||||
|
},
|
||||||
|
teams_color_overlay = { "orange", "blue", "green", "yellow"},
|
||||||
|
properties = {
|
||||||
|
schem_name = "You_dont_need_the_file_extention",
|
||||||
|
schem_location = { x = 0, y = 0, z = 0 },
|
||||||
|
area_to_clear_pos_1 = { x = 0, y = 0, z = 0 },
|
||||||
|
area_to_clear_pos_2 = { x = 0, y = 0, z = 0 },
|
||||||
|
ruby_gem = { x = 0, y = 0, z = 0 },
|
||||||
|
sapphire_gem = { x = 0, y = 0, z = 0 },
|
||||||
|
emerald_gem = { x = 0, y = 0, z = 0 },
|
||||||
|
opal_gem = { x = 0, y = 0, z = 0 },
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
team_properties = {
|
||||||
|
gem_exists = true,
|
||||||
|
},
|
||||||
|
disabled_damage_types = {},
|
||||||
|
is_team_chat_default = false,
|
||||||
|
time_mode = "incremental",
|
||||||
|
join_while_in_progress = true,
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dofile(minetest.get_modpath("gems_4") .. "/auto.lua")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ChatCmdBuilder.new("gems_4", function(cmd)
|
||||||
|
-- create arena
|
||||||
|
cmd:sub("create :arena", function(name, arena_name)
|
||||||
|
arena_lib.create_arena(name, "gems_4", arena_name)
|
||||||
|
end)
|
||||||
|
|
||||||
|
cmd:sub("create :arena :minplayers:int :maxplayers:int", function(name, arena_name, min_players, max_players)
|
||||||
|
arena_lib.create_arena(name, "gems_4", arena_name, min_players, max_players)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- remove arena
|
||||||
|
cmd:sub("remove :arena", function(name, arena_name)
|
||||||
|
arena_lib.remove_arena(name, "gems_4", arena_name)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- list of the arenas
|
||||||
|
cmd:sub("list", function(name)
|
||||||
|
arena_lib.print_arenas(name, "gems_4")
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- enter editor mode
|
||||||
|
cmd:sub("edit :arena", function(sender, arena)
|
||||||
|
arena_lib.enter_editor(sender, "gems_4", arena)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- enable and disable arenas
|
||||||
|
cmd:sub("enable :arena", function(name, arena)
|
||||||
|
arena_lib.enable_arena(name, "gems_4", arena)
|
||||||
|
end)
|
||||||
|
|
||||||
|
cmd:sub("disable :arena", function(name, arena)
|
||||||
|
arena_lib.disable_arena(name, "gems_4", arena)
|
||||||
|
end)
|
||||||
|
|
||||||
|
end, {
|
||||||
|
description = [[
|
||||||
|
|
||||||
|
(/help gems_4)
|
||||||
|
|
||||||
|
Use this to configure your arena:
|
||||||
|
- create <arena name> [min players] [max players]
|
||||||
|
- edit <arena name>
|
||||||
|
- enable <arena name>
|
||||||
|
|
||||||
|
Other commands:
|
||||||
|
- remove <arena name>
|
||||||
|
- disable <arena>
|
||||||
|
]],
|
||||||
|
privs = {
|
||||||
|
gems_admin = true
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
36
gems_4/license.txt
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
hex_crystal_big.obj = CC0 Facedeer
|
||||||
|
glow<gem>.png,glow<gem>4x.png = WTFPL HeroOfTheWinds
|
||||||
|
shield textures modified by MisterE, Copyright (C) 2017-2019 davidthecreator - CC-BY-SA 3.0
|
||||||
|
|
||||||
|
thx to elceejo for bugfixes and code snippets
|
||||||
|
|
||||||
|
Code MIT (C) MisterE <MisterE@ircnow.org>, debiankaios
|
||||||
|
|
||||||
|
|
||||||
|
shops formspecs modified by MisterE from mesewars (gems.shop in api.lua), Copyright (c) 2019-date, Lejo <Lejo_1@web.de>, MIT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
4
gems_4/mod.conf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
name = gems_4
|
||||||
|
description = a minigame similar to eggwars
|
||||||
|
depends = gems, arena_lib, worldedit, 3d_armor
|
||||||
|
depends_optional = server_manager
|
12
gems_4/sounds/BGM license and info
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
============================================================
|
||||||
|
Music by audionautix.com
|
||||||
|
CC by 4.0
|
||||||
|
https://creativecommons.org/licenses/by/4.0/
|
||||||
|
|
||||||
|
Remember the Heroes - RememberTheHeroes
|
||||||
|
Search and Destroy
|
||||||
|
The Voyage
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
============================================================
|
BIN
gems_4/sounds/RememberTheHeroes.ogg
Normal file
216
init.lua
@ -1,216 +0,0 @@
|
|||||||
gems = {}
|
|
||||||
|
|
||||||
if not minetest.get_modpath("lib_chatcmdbuilder") then
|
|
||||||
dofile(minetest.get_modpath("gems") .. "/chatcmdbuilder.lua")
|
|
||||||
end
|
|
||||||
|
|
||||||
arena_lib.register_minigame("gems_2", {
|
|
||||||
|
|
||||||
prefix = "[Gems]",
|
|
||||||
show_minimap = true,
|
|
||||||
teams = {
|
|
||||||
"ruby", -- red
|
|
||||||
"emerald", --green
|
|
||||||
},
|
|
||||||
teams_color_overlay = { "red", "green", },
|
|
||||||
properties = {
|
|
||||||
schem_name = "You_dont_need_the_file_extention",
|
|
||||||
schem_location = { x = 0, y = 0, z = 0 },
|
|
||||||
area_to_clear_pos_1 = { x = 0, y = 0, z = 0 },
|
|
||||||
area_to_clear_pos_2 = { x = 0, y = 0, z = 0 },
|
|
||||||
ruby_gem = { x = 0, y = 0, z = 0 },
|
|
||||||
emerald_gem = { x = 0, y = 0, z = 0 },
|
|
||||||
-- ruby_mines = {
|
|
||||||
-- { x = 0, y = 0, z = 0 },
|
|
||||||
-- -- },
|
|
||||||
-- emerald_mines = {
|
|
||||||
-- { x = 0, y = 0, z = 0 },
|
|
||||||
-- },
|
|
||||||
|
|
||||||
},
|
|
||||||
team_properties = {
|
|
||||||
--gem_location = { x = 0, y = 0, z = 0 },
|
|
||||||
gem_exists = true,
|
|
||||||
},
|
|
||||||
disabled_damage_types = {},
|
|
||||||
is_team_chat_default = false,
|
|
||||||
time_mode = "incremental",
|
|
||||||
join_while_in_progress = true,
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
arena_lib.register_minigame("gems_4", {
|
|
||||||
|
|
||||||
prefix = "[Gems]",
|
|
||||||
show_minimap = true,
|
|
||||||
teams = {
|
|
||||||
"ruby", -- red
|
|
||||||
"sapphire", --blue
|
|
||||||
"emerald", --green
|
|
||||||
"opal", --yellow
|
|
||||||
},
|
|
||||||
teams_color_overlay = { "orange", "blue", "green", "yellow"},
|
|
||||||
properties = {
|
|
||||||
schem_name = "You_dont_need_the_file_extention",
|
|
||||||
schem_location = { x = 0, y = 0, z = 0 },
|
|
||||||
area_to_clear_pos_1 = { x = 0, y = 0, z = 0 },
|
|
||||||
area_to_clear_pos_2 = { x = 0, y = 0, z = 0 },
|
|
||||||
ruby_gem = { x = 0, y = 0, z = 0 },
|
|
||||||
sapphire_gem = { x = 0, y = 0, z = 0 },
|
|
||||||
emerald_gem = { x = 0, y = 0, z = 0 },
|
|
||||||
opal_gem = { x = 0, y = 0, z = 0 },
|
|
||||||
-- ruby_mines = {
|
|
||||||
-- { x = 0, y = 0, z = 0 },
|
|
||||||
-- },
|
|
||||||
-- sapphire_mines = {
|
|
||||||
-- { x = 0, y = 0, z = 0 },
|
|
||||||
-- },
|
|
||||||
-- emerald_mines = {
|
|
||||||
-- { x = 0, y = 0, z = 0 },
|
|
||||||
-- },
|
|
||||||
-- opal_mines = {
|
|
||||||
-- { x = 0, y = 0, z = 0 },
|
|
||||||
-- },
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
team_properties = {
|
|
||||||
--gem_location = { x = 0, y = 0, z = 0 },
|
|
||||||
gem_exists = true,
|
|
||||||
},
|
|
||||||
disabled_damage_types = {},
|
|
||||||
is_team_chat_default = false,
|
|
||||||
time_mode = "incremental",
|
|
||||||
join_while_in_progress = true,
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_privilege("gems_admin", "Set up Gems arenas")
|
|
||||||
|
|
||||||
|
|
||||||
dofile(minetest.get_modpath("gems") .. "/api.lua")
|
|
||||||
|
|
||||||
dofile(minetest.get_modpath("gems") .. "/nodes.lua")
|
|
||||||
dofile(minetest.get_modpath("gems") .. "/shop.lua")
|
|
||||||
dofile(minetest.get_modpath("gems") .. "/armor.lua")
|
|
||||||
dofile(minetest.get_modpath("gems") .. "/items.lua")
|
|
||||||
|
|
||||||
|
|
||||||
dofile(minetest.get_modpath("gems") .. "/auto.lua")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ChatCmdBuilder.new("gems_4", function(cmd)
|
|
||||||
-- create arena
|
|
||||||
cmd:sub("create :arena", function(name, arena_name)
|
|
||||||
arena_lib.create_arena(name, "gems_4", arena_name)
|
|
||||||
end)
|
|
||||||
|
|
||||||
cmd:sub("create :arena :minplayers:int :maxplayers:int", function(name, arena_name, min_players, max_players)
|
|
||||||
arena_lib.create_arena(name, "gems_4", arena_name, min_players, max_players)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- remove arena
|
|
||||||
cmd:sub("remove :arena", function(name, arena_name)
|
|
||||||
arena_lib.remove_arena(name, "gems_4", arena_name)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- list of the arenas
|
|
||||||
cmd:sub("list", function(name)
|
|
||||||
arena_lib.print_arenas(name, "gems_4")
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- enter editor mode
|
|
||||||
cmd:sub("edit :arena", function(sender, arena)
|
|
||||||
arena_lib.enter_editor(sender, "gems_4", arena)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- enable and disable arenas
|
|
||||||
cmd:sub("enable :arena", function(name, arena)
|
|
||||||
arena_lib.enable_arena(name, "gems_4", arena)
|
|
||||||
end)
|
|
||||||
|
|
||||||
cmd:sub("disable :arena", function(name, arena)
|
|
||||||
arena_lib.disable_arena(name, "gems_4", arena)
|
|
||||||
end)
|
|
||||||
|
|
||||||
end, {
|
|
||||||
description = [[
|
|
||||||
|
|
||||||
(/help gems_4)
|
|
||||||
|
|
||||||
Use this to configure your arena:
|
|
||||||
- create <arena name> [min players] [max players]
|
|
||||||
- edit <arena name>
|
|
||||||
- enable <arena name>
|
|
||||||
|
|
||||||
Other commands:
|
|
||||||
- remove <arena name>
|
|
||||||
- disable <arena>
|
|
||||||
]],
|
|
||||||
privs = {
|
|
||||||
gems_admin = true
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
ChatCmdBuilder.new("gems_2", function(cmd)
|
|
||||||
-- create arena
|
|
||||||
cmd:sub("create :arena", function(name, arena_name)
|
|
||||||
arena_lib.create_arena(name, "gems_2", arena_name)
|
|
||||||
end)
|
|
||||||
|
|
||||||
cmd:sub("create :arena :minplayers:int :maxplayers:int", function(name, arena_name, min_players, max_players)
|
|
||||||
arena_lib.create_arena(name, "gems_2", arena_name, min_players, max_players)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- remove arena
|
|
||||||
cmd:sub("remove :arena", function(name, arena_name)
|
|
||||||
arena_lib.remove_arena(name, "gems_2", arena_name)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- list of the arenas
|
|
||||||
cmd:sub("list", function(name)
|
|
||||||
arena_lib.print_arenas(name, "gems_2")
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- enter editor mode
|
|
||||||
cmd:sub("edit :arena", function(sender, arena)
|
|
||||||
arena_lib.enter_editor(sender, "gems_2", arena)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- enable and disable arenas
|
|
||||||
cmd:sub("enable :arena", function(name, arena)
|
|
||||||
arena_lib.enable_arena(name, "gems_2", arena)
|
|
||||||
end)
|
|
||||||
|
|
||||||
cmd:sub("disable :arena", function(name, arena)
|
|
||||||
arena_lib.disable_arena(name, "gems_2", arena)
|
|
||||||
end)
|
|
||||||
|
|
||||||
end, {
|
|
||||||
description = [[
|
|
||||||
|
|
||||||
(/help gems_2)
|
|
||||||
|
|
||||||
Use this to configure your arena:
|
|
||||||
- create <arena name> [min players] [max players]
|
|
||||||
- edit <arena name>
|
|
||||||
- enable <arena name>
|
|
||||||
|
|
||||||
Other commands:
|
|
||||||
- remove <arena name>
|
|
||||||
- disable <arena>
|
|
||||||
]],
|
|
||||||
privs = {
|
|
||||||
gems_admin = true
|
|
||||||
},
|
|
||||||
})
|
|
4
mod.conf
@ -1,4 +0,0 @@
|
|||||||
name = gems
|
|
||||||
description = a minigame similar to eggwars
|
|
||||||
depends = arena_lib, worldedit, 3d_armor
|
|
||||||
depends_optional = server_manager
|
|
2
modpack.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
name = gems
|
||||||
|
description = 2 and 4 team gems minigames
|