add editor tools for setting the positions of the arena

master
MisterE123 2021-03-12 00:51:17 -05:00
parent c8c67658dc
commit 05d6e79796
6 changed files with 64 additions and 1 deletions

54
editor.lua Normal file
View File

@ -0,0 +1,54 @@
arena_lib.register_editor_section("wormball", {
name = "wormball_settings",
icon = "wormball_menu.png",
hotbar_message = "Wormball Arena Settings",
give_items = function(itemstack, user, arena)
local tbl = {"wormball:pos1","wormball:pos2"}
return tbl
end,
})
minetest.register_tool("wormball:pos1",{
description = "Area to Clear Pos 1",
inventory_image = "wormball_pos1.png",
wield_image = "wormball_pos1.png",
groups = {not_in_creative_inventory = 1},
on_place = function() end,
on_drop = function() end,
on_use = function(itemstack, user, pointed_thing)
local mod = user:get_meta():get_string("arena_lib_editor.mod")
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
local pos = vector.floor(user:get_pos())
local pos_string = '{ x = '..pos.x .. ", y = " .. pos.y .. ", z = " .. pos.z .. "}"
arena_lib.change_arena_property(user:get_player_name(), 'wormball', arena_name, "area_to_clear_after_game_pos_1", pos_string , true)
minetest.chat_send_player(user:get_player_name(), "Pos_1 has been set to :"..dump(pos))
end
})
minetest.register_tool("wormball:pos2",{
description = "Area to Clear Pos 2",
inventory_image = "wormball_pos2.png",
wield_image = "wormball_pos2.png",
groups = {not_in_creative_inventory = 1},
on_place = function() end,
on_drop = function() end,
on_use = function(itemstack, user, pointed_thing)
local mod = user:get_meta():get_string("arena_lib_editor.mod")
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
local pos = vector.floor(user:get_pos())
local pos_string = '{ x = '..pos.x .. ", y = " .. pos.y .. ", z = " .. pos.z .. "}"
arena_lib.change_arena_property(user:get_player_name(), 'wormball', arena_name, "area_to_clear_after_game_pos_2", pos_string , true) minetest.chat_send_player(user:get_player_name(), "Pos_2 has been set to :"..dump(pos))
minetest.chat_send_player(user:get_player_name(), "Pos_2 has been set to :"..dump(pos))
end
})

View File

@ -83,6 +83,8 @@ if not minetest.get_modpath("lib_chatcmdbuilder") then
dofile(minetest.get_modpath("wormball") .. "/chatcmdbuilder.lua")
end
dofile(minetest.get_modpath("wormball") .. "/editor.lua")
dofile(minetest.get_modpath("wormball") .. "/commands.lua")
--nodes includes the attachment entity, also there are creative decorative worm body parts for decorating minigame hubs
dofile(minetest.get_modpath("wormball") .. "/nodes.lua")
@ -91,6 +93,13 @@ dofile(minetest.get_modpath("wormball") .. "/privs.lua")
dofile(minetest.get_modpath("wormball") .. "/minigame_manager.lua")
-- get highscores from storage if found
-- it doesnt seem to work for some reason
-- you will have to play one game before scores are available.
if arena_lib.mods and arena_lib.mods["wormball"] and arena_lib.mods["wormball"].arenas and # arena_lib.mods["wormball"].arenas > 0 then
for arena_name, arena_stats in pairs(arena_lib.mods["wormball"].arenas) do
if wormball.storage:get_string(arena_name .. "_highscores") then

View File

@ -1,4 +1,4 @@
name = wormball
description = Wormball subgame
depends = default, arena_lib, player_api, dye
depends_optional = lib_chatcmdbuilder, panel_lib
depends_optional = lib_chatcmdbuilder

BIN
textures/wormball_menu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
textures/wormball_pos1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
textures/wormball_pos2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB