Fixing bugs from the last steam.

master
Nathan Salapat 2022-08-10 19:52:36 -05:00
parent bca34b03e8
commit 872d2800d0
17 changed files with 157 additions and 28 deletions

View File

@ -1,4 +1,7 @@
!!!Important bits and bobs you need to know!!!
8-2-22:
After updating you'll need to uncomment line 8 in lobby/functions.lua the first run. New table added to easier retrival of global stats.
3-2-22:
You can now set the spawn pos for the lobby by a game setting (technical name: traitor_lobby_spawn). By default, the game uses the same position as the popular "In our midst" server.

View File

@ -48,6 +48,36 @@ minetest.register_craftitem('clothing:shirt_t_5', {
on_drop = lobby.no_drop
})
minetest.register_craftitem('clothing:shirt_t_6', {
description = 'Abstract Design T',
tex = 'clothing_shirt_t_6.png',
cost = 24,
inventory_image = 'clothing_shirt_t_6_inv.png',
stack_max = 1,
groups = {clothing = 1, not_in_creative_inventory=1, clothing_shirts=1},
on_drop = lobby.no_drop
})
minetest.register_craftitem('clothing:shirt_t_7', {
description = 'Shoulderless Top',
tex = 'clothing_shirt_t_7.png',
cost = 30,
inventory_image = 'clothing_shirt_t_7_inv.png',
stack_max = 1,
groups = {clothing = 1, not_in_creative_inventory=1, clothing_shirts=1},
on_drop = lobby.no_drop
})
minetest.register_craftitem('clothing:hoodie_1', {
description = 'Winter Degin Hoodie',
tex = 'clothing_hoodie_1.png',
cost = 50,
inventory_image = 'clothing_hoodie_1_inv.png',
stack_max = 1,
groups = {clothing = 1, not_in_creative_inventory=1, clothing_shirts=1},
on_drop = lobby.no_drop
})
minetest.register_craftitem('clothing:vest_1', {
description = 'Vest (Blue)',
tex = 'clothing_vest_1.png',

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Binary file not shown.

View File

@ -21,8 +21,8 @@ end
local function button_create(id, name, player_count, xp, pos_string, desc, builders, solo)
local pos = minetest.string_to_pos(pos_string)
local clean_pos = pos.x..','..pos.y..','..pos.z
local builders = builders or ''
local solo = solo or 'true'
builders = builders or ''
solo = solo or 'true'
local formspec =
'formspec_version[3]'..
'size[12,8.5]'..
@ -49,11 +49,13 @@ local function button_display(id, name, owner, player_count, xp, pos, desc)
local formspec =
'formspec_version[3]'..
'size[12,8]'..
--'image_button[10.5,.5;1,1;lobby_report_icon.png;report;;;false]'..
--'tooltip[report;Report this level as incomplete.]'..
'style_type[textarea;textcolor=#ccddff;border=true]'..
'label[0.5,.7;Map Name:]'..
'textarea[3.25,.55;8.25,.4;;;'..esc(name)..' (by '..owner..')]'..
'textarea[3.25,.55;7,.4;;;'..esc(name)..' (by '..owner..')]'..
'label[0.5,1.1;Map ID:]'..
'textarea[3.25,.95;8.25,.4;;;'..esc(id)..']'..
'textarea[3.25,.95;7,.4;;;'..esc(id)..']'..
'label[0.5,1.5;Req. # of Players:]'..
'textarea[3.25,1.35;4,.4;;;'..esc(player_count)..']'..
'label[0.5,1.9;Req. XP:]'..
@ -135,7 +137,7 @@ minetest.register_node('lobby:button_0', {
local meta = minetest.get_meta(pos)
local owner = meta:get_string('owner')
local player_name = sender:get_player_name()
if fields ['claim'] then
if fields ['claim'] then --Should make it so only builders can claim a button.
if lobby.take_xp(sender, 15) then
minetest.show_formspec(player_name, 'lobby:get_started', lobby.getting_started)
meta:set_string('owner', player_name)
@ -231,6 +233,7 @@ minetest.register_node('lobby:button_0', {
data.xp = math.max(tonumber(fields.xp),1)
lobby.savedata.data[map_id] = data
lobby.savedata.name_2_id[fields.name] = map_id
lobby.savedata.id_2_name[map_id] = fields.name
lobby.savedata.IDs[map_id] = true
minetest.swap_node(pos, {name = 'lobby:button_1'})
end
@ -378,10 +381,34 @@ minetest.register_node('lobby:button_1', {
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname == 'lobby:button_display' then
local name = player:get_player_name()
local map_id = lobby.stat[name]
if fields.stats then
local name = player:get_player_name()
local map_id = lobby.stat[name]
minetest.show_formspec(name, 'lobby:stats', lobby.retrieve_stats(map_id))
elseif fields.report then
if not lobby.is_builder(player) then
minetest.chat_send_player(name, 'Sorry, only builders can report levels.')
else
minetest.show_formspec(name, 'lobby:report', lobby.report_level(map_id))
end
end
elseif formname == 'lobby:report' then
local name = player:get_player_name()
local map_id = lobby.stat[name]
if fields.save then
local reason = fields.reason
if reason then
if lobby.take_xp(player, 1) then
local input = fields.input
print (reason)
print (input)
minetest.chat_send_player(name, 'Thanks for your report')
else
minetest.chat_send_player(name, 'Sorry, you need 1 XP to submit this report.')
end
else
minetest.chat_send_player(name, 'You need to select a reason.')
end
end
end
end)

View File

@ -18,10 +18,12 @@ function lobby.press_button(pos, node, clicker)
lobby.voted[rname] = false
local vel = player:get_velocity()
local vel_x = vel.x * -1
local vel_y = vel.y * -1
local vel_z = vel.z * -1
player:add_velocity({x=vel_x, y=vel.y, z=vel_z})
player:set_pos({x=game_pos.x+(math.random(-3,3)),y=game_pos.y,z=game_pos.z+(math.random(-3,3))})
player:set_physics_override({speed=0})
player:add_velocity({x=vel_x, y=vel_y, z=vel_z})
player:set_pos({x=game_pos.x+(math.random(-2.5,2.5)),y=game_pos.y-1,z=game_pos.z+(math.random(-2.5,2.5))})
player:set_physics_override({speed=.001})
player:set_armor_groups({immortal=1})
player_attributes:set_string('voting', 'true')
minetest.chat_send_player(rname, minetest.colorize('#FF0000', name..' called an emergency meeting!'))
minetest.show_formspec(rname, 'lobby:voting', lobby.voting_formspec(survivors))

View File

@ -110,3 +110,20 @@ lobby.getting_started =
'size[12,10]'..
'textarea[.5,.5;11,8;;;'..text_body..']'..
'button_exit[4,9;4,1;close;Close This Dialog]'
function lobby.report_level(map_id)
local map_name = lobby.savedata.id_2_name[map_id]
local formspec =
'formspec_version[3]'..
'size[12,8]'..
'style_type[label;textcolor=red;font=bold;font_size=20]'..
'label[2,.5;Report Level ('..map_name..')]'..
'style_type[label;textcolor=;font=;font_size=]'..
'label[.75,1.5;Report Reason:]'..
'dropdown[.5,2;5,.5;reason;Incomplete,Broken,No tasks,Broken spawn;0]'..
'textarea[.5,2.75;5,3.75;;This is where we explain what the different options mean and what this actually does.;]'..
'textarea[6,1.66;5.5,5;input;Further Details (optional);]'..
'button_exit[2,7;3,.75;save;Submit (1xp)]'..
'button_exit[7,7;3,.75;lol;Cancel]'
return formspec
end

View File

@ -5,12 +5,14 @@ function lobby.load()
file:close()
--lobby.savedata.stats = {}
--lobby.savedata.name_2_id = {}
--lobby.savedata.id_2_name = {}
else
lobby.savedata = {}
lobby.savedata.IDs = {}
lobby.savedata.data = {}
lobby.savedata.stats = {}
lobby.savedata.name_2_id = {}
lobby.savedata.id_2_name = {}
end
end
@ -151,6 +153,7 @@ function lobby.vote(map_id, force)
end
lobby.suspect[rname] = 0
player:set_physics_override({speed=1})
player:set_armor_groups({})
player_attributes:set_string('voting', 'false')
end
end

View File

@ -55,16 +55,17 @@ minetest.register_on_dieplayer(function(player)
tone = 4
end
local corpse_col = 'lobby:corpse_'..tone
if pos_node.name ~= 'air' then --check if in water
if pos_node.name ~= 'air' then
if minetest.get_item_group(pos_node.name, 'liquid') > 0 then
minetest.set_node(pos, {name = corpse_col, param2 = param2})
lobby.corpse_entry(pos, map_id)
end
local air = minetest.find_node_near(pos, 1, {'air'})
if air then
minetest.set_node(air, {name = corpse_col, param2 = param2})
lobby.corpse_entry(air, map_id)
pos = air
else
local air = minetest.find_node_near(pos, 1, {'air'})
if air then
minetest.set_node(air, {name = corpse_col, param2 = param2})
lobby.corpse_entry(air, map_id)
pos = air
end
end
else
minetest.set_node(pos, {name = corpse_col, param2 = param2})

View File

@ -1,15 +1,28 @@
function lobby.update_stats(map_id, mode, win, player_count)
local stats = lobby.savedata.stats[map_id] or {}
local server_stats = lobby.savedata.stats['server'] or {}
stats.solo_play = stats.solo_play or 0
stats.multi_play = stats.multi_play or 0
stats.winner_traitor = stats.winner_traitor or 0
stats.winner_team = stats.winner_team or 0
stats.player_count = stats.player_count or 0
stats.max_players = stats.max_players or 0
server_stats.max_players = server_stats.max_players or 0
server_stats.most_played = server_stats.most_played or 0
server_stats.team_wins = server_stats.team_wins or 0
server_stats.traitor_wins = server_stats.traitor_wins or 0
if win == 'traitor' then
stats.winner_traitor = stats.winner_traitor + 1
if stats.winner_traitor > server_stats.traitor_wins then
server_stats.traitor_wins = stats.winner_traitor
server_stats.traitor_wins_id = map_id
end
elseif win == 'team' then
stats.winner_team = stats.winner_team + 1
if stats.winner_team > server_stats.team_wins then
server_stats.team_wins = stats.winner_team
server_stats.team_wins_id = map_id
end
end
if player_count then --takes an integer as input
local count = stats.multi_play
@ -20,17 +33,27 @@ function lobby.update_stats(map_id, mode, win, player_count)
if player_count > stats.max_players then
stats.max_players = player_count
end
if player_count > server_stats.max_players then
server_stats.max_players = player_count
server_stats.max_players_id = map_id
end
end
if mode == 'solo' then --Solo sessions played.
stats.solo_play = stats.solo_play + 1
elseif mode == 'player' then --Team sessions played.
stats.multi_play = stats.multi_play + 1
if stats.multi_play > server_stats.most_played then
server_stats.most_played = stats.multi_play
server_stats.most_played_id = map_id
end
end
lobby.savedata.stats[map_id] = stats
lobby.savedata.stats['server'] = server_stats
end
function lobby.retrieve_stats(map_id)
local formspec = ''
local formspec = 'formspec_version[3]'..
'size[16,9]'
if lobby.savedata.stats[map_id] then
local data = lobby.savedata.data[map_id]
local map_name = data['map_name'] or map_id
@ -45,26 +68,49 @@ function lobby.retrieve_stats(map_id)
avg_players = max
end
local avg = string.format("%.2f", avg_players)
formspec =
'formspec_version[3]'..
'size[16,9]'..
formspec = formspec ..
'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,4;;; This level has been played '..player..' times.'..
' On average '..avg..' players join a session. The most ever recorded was '..max..'!\n'..
' The traitor has won '..traitor..' games, whereas '..team..' have been team wins.\n'..
' This level has been visited by single players '..solo..' time(s).]'..
'textarea[8.5,.5;7,5;;; What does this all mean and why should you care?\n'..
'textarea[8.5,.5;7,4.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,'..
' 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.]'
' You may find that the wins don\'t add up to the times played, that is due to crashes. :(]'
else
formspec =
formspec = formspec ..
'formspec_version[3]'..
'size[16,9]'..
'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,2;No data on this level yet! Get some friends and play a round.]'
end
formspec = formspec .. lobby.server_stats()
return formspec
end
function lobby.server_stats()
local stats = lobby.savedata.stats['server']
local max_players = stats.max_players
local max_id = stats.max_players_id
local max_name = lobby.savedata.id_2_name[max_id]
local most_players = stats.most_played
local most_id = stats.most_played_id
local most_name = lobby.savedata.id_2_name[most_id]
local traitor_wins = stats.traitor_wins
local traitor_id = stats.traitor_wins_id
local traitor_name = lobby.savedata.id_2_name[traitor_id]
local team_wins = stats.team_wins
local team_id = stats.team_wins_id
local team_name = lobby.savedata.id_2_name[team_id]
local formspec =
'textarea[.5,5.25;15,3.25;;;Serverwide Stats and Rankings:\n'..
max_name..' has the highest player count of any level with '..max_players..' playing at once.\n'..
most_name..' is the most played level, being played '..most_players..' times.\n'..
'Traitors have won '..traitor_wins..' times on '..traitor_name..'.\n'..
'Teams have won '..team_wins..' times on '..team_name..'.\n]'
return formspec
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B