More data collection for stats, and easier viewing of stats.
BIN
menu/icon.png
Before Width: | Height: | Size: 1002 B After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.2 KiB |
|
@ -55,7 +55,8 @@ local function button_display(id, name, owner, player_count, xp, pos, desc)
|
||||||
'textarea[0.5,3;4,.5;;Required XP:;'..esc(xp)..']'..
|
'textarea[0.5,3;4,.5;;Required XP:;'..esc(xp)..']'..
|
||||||
'textarea[0.5,3.75;11,4;;Description of map:;'..esc(desc)..']'..
|
'textarea[0.5,3.75;11,4;;Description of map:;'..esc(desc)..']'..
|
||||||
'textarea[5,.5;6.5,3;;;Sneak punch to visit without starting a game. Return with /lobby.\n'..
|
'textarea[5,.5;6.5,3;;;Sneak punch to visit without starting a game. Return with /lobby.\n'..
|
||||||
'Be sure all interested parties are standing within three nodes of the button before punching.]'
|
'Be sure all interested parties are standing within three nodes of the button before punching.]'..
|
||||||
|
'button[9.5,6.5;2,1;stats;Stats]'
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -99,6 +100,7 @@ minetest.register_node('lobby:button_0', {
|
||||||
meta:set_string('formspec', button_create(id, name, player_count, xp, pos, desc, builders, solo))
|
meta:set_string('formspec', button_create(id, name, player_count, xp, pos, desc, builders, solo))
|
||||||
else
|
else
|
||||||
minetest.show_formspec(player_name, 'lobby:button_display', button_display(id, name, owner, player_count, xp, pos, desc))
|
minetest.show_formspec(player_name, 'lobby:button_display', button_display(id, name, owner, player_count, xp, pos, desc))
|
||||||
|
lobby.stat[player_name] = id
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_punch = function(pos, node, puncher, pointed_thing)
|
on_punch = function(pos, node, puncher, pointed_thing)
|
||||||
|
@ -247,6 +249,7 @@ minetest.register_node('lobby:button_1', {
|
||||||
local desc = meta:get_string('desc')
|
local desc = meta:get_string('desc')
|
||||||
local owner = meta:get_string('owner')
|
local owner = meta:get_string('owner')
|
||||||
minetest.show_formspec(player_name, 'lobby:button_display', button_display(id, name, owner, player_count, xp, pos, desc))
|
minetest.show_formspec(player_name, 'lobby:button_display', button_display(id, name, owner, player_count, xp, pos, desc))
|
||||||
|
lobby.stat[player_name] = id
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_punch = function(pos, node, puncher, pointed_thing)
|
on_punch = function(pos, node, puncher, pointed_thing)
|
||||||
|
@ -303,6 +306,7 @@ minetest.register_node('lobby:button_1', {
|
||||||
local privs = minetest.get_player_privs(map_players[i])
|
local privs = minetest.get_player_privs(map_players[i])
|
||||||
local player_inv = player:get_inventory()
|
local player_inv = player:get_inventory()
|
||||||
player_inv:set_list('main', {})
|
player_inv:set_list('main', {})
|
||||||
|
player_inv:set_size('main', 16)
|
||||||
lobby.game[map_players[i]] = map_id
|
lobby.game[map_players[i]] = map_id
|
||||||
player:set_pos({x=game_pos.x+(math.random(-2,2)),y=game_pos.y,z=game_pos.z+(math.random(-2,2))})
|
player:set_pos({x=game_pos.x+(math.random(-2,2)),y=game_pos.y,z=game_pos.z+(math.random(-2,2))})
|
||||||
privs.fly = nil
|
privs.fly = nil
|
||||||
|
@ -328,6 +332,7 @@ minetest.register_node('lobby:button_1', {
|
||||||
local privs = minetest.get_player_privs(name)
|
local privs = minetest.get_player_privs(name)
|
||||||
local player_inv = puncher:get_inventory()
|
local player_inv = puncher:get_inventory()
|
||||||
player_inv:set_list('main', {})
|
player_inv:set_list('main', {})
|
||||||
|
player_inv:set_size('main', 16)
|
||||||
privs.fly = nil
|
privs.fly = nil
|
||||||
privs.fast = nil
|
privs.fast = nil
|
||||||
privs.creative = nil
|
privs.creative = nil
|
||||||
|
@ -345,3 +350,13 @@ minetest.register_node('lobby:button_1', {
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if formname == 'lobby:button_display' then
|
||||||
|
if fields.stats then
|
||||||
|
local map_id = lobby.stat[name]
|
||||||
|
minetest.show_formspec(name, 'lobby:stats', lobby.retrieve_stats(map_id))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
|
@ -136,11 +136,13 @@ function lobby.vote(map_id, force)
|
||||||
elseif kick ~= '' then
|
elseif kick ~= '' then
|
||||||
lobby.message_to_level(map_id, 'The votes are in, '..kick..' will be kicked.')
|
lobby.message_to_level(map_id, 'The votes are in, '..kick..' will be kicked.')
|
||||||
local player = minetest.get_player_by_name(kick)
|
local player = minetest.get_player_by_name(kick)
|
||||||
|
local player_attributes = player:get_meta()
|
||||||
gamer.player_set_textures(player,{'lobby_ghost.png'})
|
gamer.player_set_textures(player,{'lobby_ghost.png'})
|
||||||
player:set_nametag_attributes({
|
player:set_nametag_attributes({
|
||||||
color = {a = 0, r = 255, g = 255, b = 255}
|
color = {a = 0, r = 255, g = 255, b = 255}
|
||||||
})
|
})
|
||||||
player:set_properties({visual_size = {x = 0, y = 0}, collisionbox = {-0.3, 0.0, -0.3, 0.3, .2, 0.3}})
|
player:set_properties({visual_size = {x = 0, y = 0}, collisionbox = {-0.3, 0.0, -0.3, 0.3, .2, 0.3}})
|
||||||
|
player:set_physics_override({speed=1})
|
||||||
player_attributes:set_string('mode', 'ghost')
|
player_attributes:set_string('mode', 'ghost')
|
||||||
minetest.chat_send_player(kick, 'You were kicked, and are now a ghost. Return to the lobby with the /lobby chat command.')
|
minetest.chat_send_player(kick, 'You were kicked, and are now a ghost. Return to the lobby with the /lobby chat command.')
|
||||||
lobby.game[kick] = map_id..'_ghost'
|
lobby.game[kick] = map_id..'_ghost'
|
||||||
|
|
|
@ -9,6 +9,7 @@ lobby.traitors = {} --
|
||||||
lobby.corpses = {}
|
lobby.corpses = {}
|
||||||
lobby.vote_timer = {}
|
lobby.vote_timer = {}
|
||||||
lobby.spawn_pos = {x=29996, y=-4.5, z=30041.5}
|
lobby.spawn_pos = {x=29996, y=-4.5, z=30041.5}
|
||||||
|
lobby.stat = {}
|
||||||
--Yes I know these table names are not very clear.
|
--Yes I know these table names are not very clear.
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
|
|
@ -115,8 +115,9 @@ end)
|
||||||
minetest.register_on_leaveplayer(function(player, timed_out)
|
minetest.register_on_leaveplayer(function(player, timed_out)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local map_id = lobby.game[name]
|
local map_id = lobby.game[name]
|
||||||
print (map_id)
|
local player_attributes = player:get_meta()
|
||||||
if map_id ~= 'lobby' and not string.find(map_id, 'ghost') then
|
local mode = player_attributes:get_string('mode')
|
||||||
|
if map_id ~= 'lobby' and mode == 'player' then
|
||||||
local game_data = lobby.savedata.data[map_id]
|
local game_data = lobby.savedata.data[map_id]
|
||||||
local map_name = game_data['map_name'] or map_id
|
local map_name = game_data['map_name'] or map_id
|
||||||
local traitor = lobby.traitors[map_id]
|
local traitor = lobby.traitors[map_id]
|
||||||
|
|
|
@ -5,6 +5,7 @@ function lobby.update_stats(map_id, mode, win, player_count)
|
||||||
stats.winner_traitor = stats.winner_traitor or 0
|
stats.winner_traitor = stats.winner_traitor or 0
|
||||||
stats.winner_team = stats.winner_team or 0
|
stats.winner_team = stats.winner_team or 0
|
||||||
stats.player_count = stats.player_count or 0
|
stats.player_count = stats.player_count or 0
|
||||||
|
stats.max_players = stats.max_players or 0
|
||||||
if mode == 'solo' then --Solo sessions played.
|
if mode == 'solo' then --Solo sessions played.
|
||||||
stats.solo_play = stats.solo_play + 1
|
stats.solo_play = stats.solo_play + 1
|
||||||
elseif mode == 'player' then --Team sessions played.
|
elseif mode == 'player' then --Team sessions played.
|
||||||
|
@ -16,11 +17,14 @@ function lobby.update_stats(map_id, mode, win, player_count)
|
||||||
stats.winner_team = stats.winner_team + 1
|
stats.winner_team = stats.winner_team + 1
|
||||||
end
|
end
|
||||||
if player_count then --takes an integer as input
|
if player_count then --takes an integer as input
|
||||||
local count = stats.solo_play + stats.multi_play
|
local count = stats.multi_play
|
||||||
local avg = stats.player_count
|
local avg = stats.player_count
|
||||||
local total = count * avg
|
local total = count * avg
|
||||||
local player_count_avg = (total + player_count) / count
|
local player_count_avg = (total + player_count) / (count + 1)
|
||||||
stats.player_count = player_count_avg
|
stats.player_count = player_count_avg
|
||||||
|
if player_count > stats.max_players then
|
||||||
|
stats.max_players = player_count
|
||||||
|
end
|
||||||
end
|
end
|
||||||
lobby.savedata.stats[map_id] = stats
|
lobby.savedata.stats[map_id] = stats
|
||||||
end
|
end
|
||||||
|
@ -36,25 +40,27 @@ function lobby.retrieve_stats(map_id)
|
||||||
local traitor = stats.winner_traitor
|
local traitor = stats.winner_traitor
|
||||||
local team = stats.winner_team
|
local team = stats.winner_team
|
||||||
local avg_players = stats.player_count
|
local avg_players = stats.player_count
|
||||||
local count = solo + player
|
--local max = stats.max_players
|
||||||
formspec =
|
formspec =
|
||||||
'formspec_version[3]'..
|
'formspec_version[3]'..
|
||||||
'size[16,9]'..
|
'size[16,9]'..
|
||||||
'label[.5,.5;Viewing stats for '..map_name..', ('..map_id..')]'..
|
'label[.5,.5;Viewing stats for '..map_name..', ('..map_id..')]'..
|
||||||
'textarea[.5,1;7.5,5;;; This level has been played '..player..' times.'..
|
'textarea[.5,1;7.5,5;;; This level has been played '..player..' times.'..
|
||||||
' The average number of players in a session is '..avg_players..'.\n'..
|
' On average '..avg_players..' players join a session.\n'..
|
||||||
|
--The most ever recorded was '..max..'!
|
||||||
' The traitor has won '..traitor..' games, whereas '..team..' have been team wins.\n'..
|
' The traitor has won '..traitor..' games, whereas '..team..' have been team wins.\n'..
|
||||||
' This level has been visited by single players '..solo..' times.]'..
|
' This level has been visited by single players '..solo..' times.]'..
|
||||||
'textarea[8.5,.5;7,5;;; What does this all mean and why should you care?\n'..
|
'textarea[8.5,.5;7,5;;; What does this all mean and why should you care?\n'..
|
||||||
' If you find that your level\'s wins strongly favor one party you might want to tweak the number of tasks,'..
|
' If you find that your level\'s wins strongly favor one party you might want to tweak the number of tasks,'..
|
||||||
' the granted XP, or the required XP. People are more likely to play your level when the chances of winning are fairly even.]'..
|
' the granted XP, or the required XP. People are more likely to play your level when the chances of winning are fairly even.'..
|
||||||
|
' You may find that the wins don\'t add up to the times played, that is due to crashes. :()]'..
|
||||||
'label[.5,5.5;This space reserved for eventual charts and tables.]'
|
'label[.5,5.5;This space reserved for eventual charts and tables.]'
|
||||||
else
|
else
|
||||||
formspec =
|
formspec =
|
||||||
'formspec_version[3]'..
|
'formspec_version[3]'..
|
||||||
'size[16,9]'..
|
'size[16,9]'..
|
||||||
'label[.5,2;No data on this level yet! Get some friends and play a round.]'..
|
'label[.5,2;No data on this level yet! Get some friends and play a round.]'..
|
||||||
'label[.5,5.5;This space reserved for eventual charts and tables.]'
|
'label[.5,5.5;This space reserved for eventual charts and tables.]'
|
||||||
end
|
end
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
|
@ -86,7 +86,7 @@ minetest.register_node('signs:1_metal', {
|
||||||
on_receive_fields = signs.on_receive_fields
|
on_receive_fields = signs.on_receive_fields
|
||||||
})
|
})
|
||||||
|
|
||||||
for i = 1, 3 do
|
for i = 1, 6 do
|
||||||
minetest.register_node('signs:poster_'..i, {
|
minetest.register_node('signs:poster_'..i, {
|
||||||
description = 'Poster',
|
description = 'Poster',
|
||||||
drawtype = 'mesh',
|
drawtype = 'mesh',
|
||||||
|
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 2.2 KiB |
|
@ -14,8 +14,8 @@ function tasks.add_xp(pos, node, puncher, swap_to) --This function shouldn't be
|
||||||
if wield_name ~= 'creative:tool_breaking' then
|
if wield_name ~= 'creative:tool_breaking' then
|
||||||
local name = puncher:get_player_name()
|
local name = puncher:get_player_name()
|
||||||
local timer = minetest.get_node_timer(pos)
|
local timer = minetest.get_node_timer(pos)
|
||||||
local min = meta:get_int('time_min') or 30
|
local min = math.max(meta:get_int('time_min'), 5)
|
||||||
local max = meta:get_int('time_max') or 60
|
local max = math.max(meta:get_int('time_max'), 20)
|
||||||
local random_number = math.random(min,max)
|
local random_number = math.random(min,max)
|
||||||
timer:start(random_number)
|
timer:start(random_number)
|
||||||
local map_id = lobby.game[name]
|
local map_id = lobby.game[name]
|
||||||
|
|