Team chests, balance spawning
This commit is contained in:
parent
4a54721d44
commit
3c9581bcf0
8 changed files with 91 additions and 61 deletions
|
@ -1,5 +0,0 @@
|
||||||
ctf.register_on_new_game(function()
|
|
||||||
minetest.after(5, function()
|
|
||||||
|
|
||||||
end)
|
|
||||||
end)
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d273457d9928b306c4e18c211d465637ed85f20b
|
Subproject commit 9804ec7518a5c94108fc19f59e67e7a84fc698a3
|
78
mods/ctf_team_chest/init.lua
Normal file
78
mods/ctf_team_chest/init.lua
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
local chest_formspec =
|
||||||
|
"size[8,9]" ..
|
||||||
|
default.gui_bg ..
|
||||||
|
default.gui_bg_img ..
|
||||||
|
default.gui_slots ..
|
||||||
|
"list[current_name;main;0,0.3;8,4;]" ..
|
||||||
|
"list[current_player;main;0,4.85;8,1;]" ..
|
||||||
|
"list[current_player;main;0,6.08;8,3;8]" ..
|
||||||
|
"listring[current_name;main]" ..
|
||||||
|
"listring[current_player;main]" ..
|
||||||
|
default.get_hotbar_bg(0,4.85)
|
||||||
|
|
||||||
|
minetest.register_node("ctf_team_chest:chest", {
|
||||||
|
description = "Chest",
|
||||||
|
tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
|
||||||
|
"default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {choppy = 2, oddly_breakable_by_hand = 2},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
is_ground_content = false,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", chest_formspec)
|
||||||
|
meta:set_string("infotext", "Chest")
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("main", 8*4)
|
||||||
|
end,
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
on_metadata_inventory_move = function(pos, from_list, from_index,
|
||||||
|
to_list, to_index, count, player)
|
||||||
|
minetest.log("action", player:get_player_name() ..
|
||||||
|
" moves stuff in chest at " .. minetest.pos_to_string(pos))
|
||||||
|
end,
|
||||||
|
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
minetest.log("action", player:get_player_name() ..
|
||||||
|
" moves stuff to chest at " .. minetest.pos_to_string(pos))
|
||||||
|
end,
|
||||||
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
minetest.log("action", player:get_player_name() ..
|
||||||
|
" takes stuff from chest at " .. minetest.pos_to_string(pos))
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
|
for tname, team in pairs(ctf.teams) do
|
||||||
|
for _, flag in pairs(team.flags) do
|
||||||
|
if minp.x <= flag.x and maxp.x >= flag.x and
|
||||||
|
minp.y <= flag.y and maxp.y >= flag.y and
|
||||||
|
minp.z <= flag.z and maxp.z >= flag.z then
|
||||||
|
|
||||||
|
local chest = {name = "ctf_team_chest:chest"}
|
||||||
|
local dz = 2
|
||||||
|
if flag.z < 0 then
|
||||||
|
dz = -2
|
||||||
|
chest.param2 = minetest.dir_to_facedir({x=0,y=0,z=-1})
|
||||||
|
end
|
||||||
|
local pos = {
|
||||||
|
x = flag.x,
|
||||||
|
y = flag.y,
|
||||||
|
z = flag.z + dz
|
||||||
|
}
|
||||||
|
|
||||||
|
minetest.set_node(pos, chest)
|
||||||
|
print("Flag " .. dump(flag))
|
||||||
|
|
||||||
|
local inv = minetest.get_inventory({type = "node", pos=pos})
|
||||||
|
inv:add_item("main", ItemStack("default:stone 99"))
|
||||||
|
inv:add_item("main", ItemStack("default:stone 99"))
|
||||||
|
inv:add_item("main", ItemStack("default:glass 10"))
|
||||||
|
inv:add_item("main", ItemStack("default:torch 10"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
|
@ -1,33 +1,13 @@
|
||||||
--treasurer.register_treasure("firearms:m3",0.5,2,{1,2})
|
treasurer.register_treasure("default:ladder",0.3,5,{1,20})
|
||||||
--treasurer.register_treasure("firearms:bullet_12g",0.7,1,{1,10})
|
treasurer.register_treasure("default:torch",0.3,5,{1,20})
|
||||||
--treasurer.register_treasure("firearms:m4",0.3,3,{1,2})
|
treasurer.register_treasure("default:cobble",0.3,5,{45,99})
|
||||||
--treasurer.register_treasure("firearms:bullet_556mm", 0.5, 2,{1,10})
|
|
||||||
--treasurer.register_treasure("firearms:m9",0.2,3,{1,2})
|
|
||||||
--treasurer.register_treasure("firearms:bullet_45",0.5,2,{1,20})
|
|
||||||
--[[treasurer.register_treasure("firearms:awp",0.05,8,1)
|
|
||||||
treasurer.register_treasure("firearms:bullet_762mm",0.1,5,{1,22})
|
|
||||||
]]--
|
|
||||||
|
|
||||||
|
treasurer.register_treasure("default:pick_steel",0.5,5,{1,10})
|
||||||
|
treasurer.register_treasure("default:pick_mese",0.005,5,1)
|
||||||
|
treasurer.register_treasure("default:sword_steel",0.8,5,{1,10})
|
||||||
|
|
||||||
treasurer.register_treasure("shooter:pistol",0.5,2,{1,5})
|
treasurer.register_treasure("shooter:pistol",0.4,2,{1,5})
|
||||||
treasurer.register_treasure("shooter:rifle",0.1,2,{1,2})
|
treasurer.register_treasure("shooter:rifle",0.1,2,{1,2})
|
||||||
treasurer.register_treasure("shooter:shotgun",0.05,2,1)
|
treasurer.register_treasure("shooter:shotgun",0.05,2,1)
|
||||||
treasurer.register_treasure("shooter:machine_gun",0.01,2,1)
|
treasurer.register_treasure("shooter:machine_gun",0.01,2,1)
|
||||||
treasurer.register_treasure("shooter:ammo",0.3,2,{1,10})
|
treasurer.register_treasure("shooter:ammo",0.3,2,{1,10})
|
||||||
|
|
||||||
--[[
|
|
||||||
treasurer.register_treasure("throwing:arrow_steel",0.1,5,{1,12})
|
|
||||||
treasurer.register_treasure("throwing:arrow_stone",0.2,5,{1,12})
|
|
||||||
treasurer.register_treasure("throwing:arrow_obsidian",0.3,5,{1,8})
|
|
||||||
--treasurer.register_treasure("throwing:arrow_fire",0.1,5,{1,2})
|
|
||||||
--treasurer.register_treasure("throwing:arrow_tnt",0.1,5,1)
|
|
||||||
treasurer.register_treasure("throwing:arrow_steel",0.2,5,{1,12})
|
|
||||||
treasurer.register_treasure("throwing:bow_wood",0.9,5,{1,12})
|
|
||||||
treasurer.register_treasure("throwing:longbow",0.4,5,1)
|
|
||||||
treasurer.register_treasure("throwing:bow_steel",0.1,5,1)
|
|
||||||
]]
|
|
||||||
|
|
||||||
treasurer.register_treasure("default:pick_steel",0.3,5,{1,10})
|
|
||||||
treasurer.register_treasure("default:pick_mese",0.005,5,1)
|
|
||||||
treasurer.register_treasure("default:cobble",0.9,5,{20,99})
|
|
||||||
treasurer.register_treasure("default:sword_steel",0.8,5,{1,10})
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
This is also called “spawning treasures”.
|
This is also called “spawning treasures”.
|
||||||
How it does this task is completely free to the programmer of the TSM.
|
How it does this task is completely free to the programmer of the TSM.
|
||||||
|
|
||||||
This TSM spawns the treasures by placing chests (default:chest) between 20 and 200 node lengths below the water surface. This cau
|
This TSM spawns the treasures by placing chests (tsm_chests:chest) between 20 and 200 node lengths below the water surface. This cau
|
||||||
The chests are provided by the default mod, therefore this TSM depends on the default mod.
|
The chests are provided by the default mod, therefore this TSM depends on the default mod.
|
||||||
The treasures are requested from the treasurer mod. The TSM asks the treasurer mod for some treasures.
|
The treasures are requested from the treasurer mod. The TSM asks the treasurer mod for some treasures.
|
||||||
|
|
||||||
|
@ -28,30 +28,7 @@ local chest_formspec =
|
||||||
"listring[current_player;main]" ..
|
"listring[current_player;main]" ..
|
||||||
default.get_hotbar_bg(0,4.85)
|
default.get_hotbar_bg(0,4.85)
|
||||||
|
|
||||||
local function get_locked_chest_formspec(pos)
|
minetest.register_node("tsm_chests:chest", {
|
||||||
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
|
|
||||||
local formspec =
|
|
||||||
"size[8,9]" ..
|
|
||||||
default.gui_bg ..
|
|
||||||
default.gui_bg_img ..
|
|
||||||
default.gui_slots ..
|
|
||||||
"list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
|
|
||||||
"list[current_player;main;0,4.85;8,1;]" ..
|
|
||||||
"list[current_player;main;0,6.08;8,3;8]" ..
|
|
||||||
"listring[nodemeta:" .. spos .. ";main]" ..
|
|
||||||
"listring[current_player;main]" ..
|
|
||||||
default.get_hotbar_bg(0,4.85)
|
|
||||||
return formspec
|
|
||||||
end
|
|
||||||
|
|
||||||
local function has_locked_chest_privilege(meta, player)
|
|
||||||
if player:get_player_name() ~= meta:get_string("owner") then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node(":default:chest", {
|
|
||||||
description = "Chest",
|
description = "Chest",
|
||||||
tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
|
tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
|
||||||
"default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
|
"default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
|
||||||
|
@ -104,10 +81,10 @@ minetest.register_node(":default:chest", {
|
||||||
--[[ here are some configuration variables ]]
|
--[[ here are some configuration variables ]]
|
||||||
|
|
||||||
local chests_per_chunk = 5 -- number of chests per chunk. 15 is a bit high, an actual mod might have a lower number
|
local chests_per_chunk = 5 -- number of chests per chunk. 15 is a bit high, an actual mod might have a lower number
|
||||||
local h_min = 0 -- minimum chest spawning height, relative to water_level
|
local h_min = -1 -- minimum chest spawning height, relative to water_level
|
||||||
local h_max = 15 -- maximum chest spawning height, relative to water_level
|
local h_max = 15 -- maximum chest spawning height, relative to water_level
|
||||||
local t_min = 3 -- minimum amount of treasures found in a chest
|
local t_min = 3 -- minimum amount of treasures found in a chest
|
||||||
local t_max = 7 -- maximum amount of treasures found in a chest
|
local t_max = 6 -- maximum amount of treasures found in a chest
|
||||||
|
|
||||||
--[[ here comes the generation code
|
--[[ here comes the generation code
|
||||||
the interesting part which involes treasurer comes way below
|
the interesting part which involes treasurer comes way below
|
||||||
|
@ -165,7 +142,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
-->>>> chest spawning starts here <<<<--
|
-->>>> chest spawning starts here <<<<--
|
||||||
|
|
||||||
-- first: spawn the chest
|
-- first: spawn the chest
|
||||||
local chest = {name = "default:chest"}
|
local chest = {name = "tsm_chests:chest"}
|
||||||
|
|
||||||
-- secondly: rotate the chest
|
-- secondly: rotate the chest
|
||||||
-- find possible faces
|
-- find possible faces
|
Loading…
Reference in a new issue