Fixed a crash related to stats, and some minor bug fixes.
parent
30e9bb65b0
commit
118a5f52eb
|
@ -1,4 +1,7 @@
|
|||
!!!Important bits and bobs you need to know!!!
|
||||
2-11-22:
|
||||
IMPORTANT!!! After updating you'll need to uncomment line 6 in lobby/functions.lua to create the table that the stats are saved in. Remove or comment out the line after the first run, or you'll clear the stats every restart. This will be removed in the near future. Check git history if you need to add the line in to update your database. Any newly created worlds do not need this step.
|
||||
|
||||
2-8-22:
|
||||
player_attribute play_type renamed to mode. Retrieve with :get_string('mode')
|
||||
a mode(previously play_type) was renamed.
|
||||
|
|
|
@ -18,7 +18,7 @@ minetest.register_node('lobby:corpse', {
|
|||
},
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
local name = clicker:get_player_name()
|
||||
local player_attributes = player:get_meta()
|
||||
local player_attributes = clicker:get_meta()
|
||||
local mode = player_attributes:get_string('mode')
|
||||
local voting = player_attributes:get_string('voting')
|
||||
local map_id = lobby.game[name]
|
||||
|
@ -37,7 +37,7 @@ minetest.register_node('lobby:corpse', {
|
|||
player_attributes:set_string('voting', 'true')
|
||||
minetest.chat_send_player(rname, minetest.colorize('#FF0000', 'Somebody discovered a corpse!'))
|
||||
minetest.show_formspec(rname, 'lobby:voting', lobby.voting_formspec(survivors))
|
||||
player:setpos({x=game_pos.x+(math.random(-3,3)),y=game_pos.y,z=game_pos.z+(math.random(-3,3))})
|
||||
player:set_pos({x=game_pos.x+(math.random(-3,3)),y=game_pos.y,z=game_pos.z+(math.random(-3,3))})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@ function lobby.load()
|
|||
if file then
|
||||
lobby.savedata = minetest.deserialize(file:read())
|
||||
file:close()
|
||||
--lobby.savedata.stats = {}
|
||||
else
|
||||
lobby.savedata = {}
|
||||
lobby.savedata.IDs = {}
|
||||
|
|
|
@ -26,7 +26,7 @@ function lobby.update_stats(map_id, mode, win, player_count)
|
|||
end
|
||||
|
||||
function lobby.retrieve_stats(map_id)
|
||||
if lobby.savedata.IDs[map_id] then
|
||||
if lobby.savedata.stats[map_id] then
|
||||
local stats = lobby.savedata.stats[map_id]
|
||||
local solo = stats.solo_play
|
||||
local player = stats.multi_play
|
||||
|
|
|
@ -31,13 +31,7 @@ minetest.register_node('tasks:code_0', {
|
|||
light_source = 14,
|
||||
selection_box = box,
|
||||
collision_box = box,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string('infotext', '')
|
||||
meta:set_int('time_min', 30)
|
||||
meta:set_int('time_max', 90)
|
||||
meta:set_int('xp', 5)
|
||||
end,
|
||||
on_construct = tasks.on_contruct,
|
||||
on_rightclick = tasks.right_click,
|
||||
on_timer = function(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
|
|
|
@ -1,65 +1,31 @@
|
|||
--[[
|
||||
These three nodes could probably be registered with a single function, maybe in the future I'll code that.
|
||||
|
||||
]]
|
||||
|
||||
minetest.register_node('tasks:example_setup', { --This is the node that can be placed.
|
||||
description = 'Example node setup',
|
||||
tiles = {name='task_1.png'},
|
||||
groups = {breakable=1, not_in_creative_inventory=1},
|
||||
light_source = 2,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string('infotext', 'Unconfigured task')
|
||||
meta:set_string('formspec', tasks.formspec_configuration)
|
||||
meta:set_string('xp', '')
|
||||
meta:set_string('timer', '')
|
||||
end,
|
||||
on_receive_fields = function(pos, forname, fields, sender)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if fields ['save'] then
|
||||
if not fields.input or fields.input == "" then
|
||||
return
|
||||
end
|
||||
if tasks.valid_input(fields.input) then
|
||||
local input_text = fields.input:split(', ')
|
||||
meta:set_string('xp', input_text[1])
|
||||
meta:set_string('timer', input_text[2])
|
||||
meta:set_string('infotext', input_text[3])
|
||||
meta:set_string('formspec', '')
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.swap_node(pos, {name = 'tasks:example_1', param2 = node.param2}) --Swap to the active node.
|
||||
else
|
||||
minetest.chat_send_player(sender:get_player_name(), 'Double check your formatting please.')
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
--This is provided as a super basic example of a task that only needs to be punched to gain XP.
|
||||
|
||||
minetest.register_node('tasks:example_0', { --This node is inactive, so somebody completed the task.
|
||||
description = 'example',
|
||||
tiles = {name='task_1.png'},
|
||||
groups = {breakable=1, not_in_creative_inventory=1},
|
||||
groups = {breakable=1, not_in_creative_inventory=1, tasks=1},
|
||||
light_source = 14,
|
||||
drop = 'tasks:example_setup',
|
||||
on_construct = tasks.on_construct,
|
||||
on_timer = function(pos)
|
||||
local this_node = minetest.get_node(pos)
|
||||
minetest.swap_node(pos, {name = 'tasks:example_1', param2 = this_node.param2})
|
||||
end,
|
||||
on_punch = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local timer_duration = tonumber(meta:get_string('timer')) or 120
|
||||
local time_min = meta:get_int('time_min') or 60
|
||||
local time_max = meta:get_int('time_max') or 120
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(timer_duration*2) --Make the player wait twice as long if they try to do a task that isn't available.
|
||||
local random_number = math.random(time_min, time_max)
|
||||
timer:start(random_number*2)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node('tasks:example_1', { --This node is waiting for somebody to come along and complete the task.
|
||||
description = 'example',
|
||||
tiles = {name='task_1.png'},
|
||||
groups = {breakable=1, not_in_creative_inventory=1},
|
||||
groups = {breakable=1, not_in_creative_inventory=1, tasks=1},
|
||||
light_source = 2,
|
||||
drop = 'tasks:example_setup',
|
||||
drop = 'tasks:example_0',
|
||||
on_punch = function(pos, node, puncher, pointed_thing)
|
||||
tasks.add_xp(pos, node, puncher, 'tasks:example_0') --Everything is pulled from the node meta expect for what node to swap to.
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ function tasks.add_xp(pos, node, puncher, swap_to) --This function shouldn't be
|
|||
local map_id = lobby.game[name]
|
||||
local traitor = lobby.traitors[map_id]
|
||||
minetest.swap_node(pos, {name = swap_to, param2 = node.param2})
|
||||
meta:set_string('formspec', '') --Not sure why I added this.
|
||||
meta:set_string('formspec', '')
|
||||
if map_id ~= 'lobby' then
|
||||
if name ~= traitor then
|
||||
if mode == 'ghost' then
|
||||
|
|
Loading…
Reference in New Issue