Changed some internal naming. See changelog

master
Nathan Salapat 2022-02-08 21:48:16 -06:00
parent 010b62a5a8
commit 03748463ad
16 changed files with 73 additions and 64 deletions

View File

@ -1,3 +1,8 @@
!!!Important bits and bobs you need to know!!!
2-8-22:
player_attribute play_type renamed to mode. Retrieve with :get_string('mode')
a mode(previously play_type) was renamed.
singleplayer -> solo
2-7-22:
Level buttons (lobby:button_0 and lobby_button_1) now have fields for builders names and a toggle for singleplayer playing. The builder field is referenced when a player with creative sneak punches the button. Only if their name is on the list will they be teleported to the level. This will help prevent foul play, though a player could always fly to the location manually. The singleplayer toggle will allow levels to allow/disallow people visiting by themselves. Any existing buttons will need to be updated to allow singleplayers.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -114,12 +114,12 @@ minetest.register_node('lobby:button_0', {
if name == owner then
puncher:set_pos(pos)
minetest.chat_send_player(name, 'Taking you to the level. Return to the lobby with /spawn')
player_attributes:set_string('play_type', 'builder')
player_attributes:set_string('mode', 'builder')
lobby.game[name] = map_id..'_builder'
elseif minetest.check_player_privs(name, { creative = true }) and puncher:get_player_control().sneak and string.find(builders, name) then
puncher:set_pos(pos)
minetest.chat_send_player(name, 'Taking you to the level. Return to the lobby with /spawn')
player_attributes:set_string('play_type', 'builder')
player_attributes:set_string('mode', 'builder')
lobby.game[name] = map_id..'_builder'
end
end,
@ -255,7 +255,7 @@ minetest.register_node('lobby:button_1', {
if minetest.check_player_privs(name, { creative = true }) and puncher:get_player_control().sneak and string.find(builders, name) then
puncher:set_pos({x=game_pos.x+(math.random(-2,2)),y=game_pos.y+2,z=game_pos.z+(math.random(-2,2))})
minetest.chat_send_player(name, 'Taking you to the level. Return to the lobby with /spawn')
player_attributes:set_string('play_type', 'builder')
player_attributes:set_string('mode', 'builder')
lobby.game[name] = map_id..'_builder'
else
local needed_players = tonumber(meta:get_string('player_count')) or 8
@ -293,7 +293,7 @@ minetest.register_node('lobby:button_1', {
local player = minetest.get_player_by_name(map_players[i])
local player_attributes = player:get_meta()
player_attributes:set_string('voting', 'false')
player_attributes:set_string('play_type', 'player')
player_attributes:set_string('mode', 'player')
local privs = minetest.get_player_privs(map_players[i])
local player_inv = player:get_inventory()
player_inv:set_list('main', {})
@ -317,7 +317,7 @@ minetest.register_node('lobby:button_1', {
color = {a = 0, r = 255, g = 255, b = 255}
})
puncher:set_properties({visual_size = {x = 1, y = 1}, collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}})
player_attributes:set_string('play_type', 'singleplayer')
player_attributes:set_string('mode', 'solo')
local privs = minetest.get_player_privs(name)
local player_inv = puncher:get_inventory()
player_inv:set_list('main', {})
@ -327,7 +327,7 @@ minetest.register_node('lobby:button_1', {
privs.areas = nil
minetest.set_player_privs(name, privs)
puncher:set_pos(game_pos)
lobby.game[name] = map_id..'_singleplayer'
lobby.game[name] = map_id..'_solo'
minetest.chat_send_player(name, 'Travel back to the lobby with the /lobby chat command.')
else
minetest.chat_send_player(name, 'Sorry this level is not able to be played solo.')

View File

@ -44,8 +44,8 @@ minetest.register_chatcommand('lobby', {
func = function(name)
local player = minetest.get_player_by_name(name)
local player_attributes = player:get_meta()
local play_type = player_attributes:get_string('play_type')
if play_type == 'ghost' or play_type == 'singleplayer' then
local mode = player_attributes:get_string('mode')
if mode == 'ghost' or mode == 'solo' then
gamer.player_set_textures(player,{'gamer_skin.png'})
player:set_nametag_attributes({
color = {a = 255, r = 255, g = 255, b = 255}
@ -54,11 +54,11 @@ minetest.register_chatcommand('lobby', {
player:set_pos(lobby.spawn_pos)
lobby.game[name] = 'lobby'
minetest.chat_send_player(name, 'Here you are.')
player_attributes:set_string('play_type', 'singleplayer')
player_attributes:set_string('mode', 'solo')
local player_inv = player:get_inventory()
player_inv:set_list('main', {})
else
minetest.chat_send_player(name, 'You can only run this command when you are a ghost.')
minetest.chat_send_player(name, 'You can only run this command when you are a ghost or playing solo.')
end
end
})

View File

@ -18,10 +18,12 @@ minetest.register_node('lobby:corpse', {
},
on_rightclick = function(pos, node, clicker, itemstack)
local name = clicker:get_player_name()
local voting = clicker:get_attribute('voting')
local player_attributes = player:get_meta()
local mode = player_attributes:get_string('mode')
local voting = player_attributes:get_string('voting')
local map_id = lobby.game[name]
if voting == 'false' then
if map_id ~= 'lobby' and not string.match(map_id, '_ghost') then
if map_id ~= 'lobby' and mode == 'solo' then
minetest.remove_node(pos)
local game_data = lobby.savedata.data[map_id]
local game_pos = game_data['level_pos']
@ -32,7 +34,7 @@ minetest.register_node('lobby:corpse', {
if lobby.game[rname] == map_id then
lobby.voted[rname] = false
player:set_physics_override({speed=0})
player:set_attribute('voting', 'true')
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))})

View File

@ -2,9 +2,10 @@ function lobby.press_button(pos, node, clicker)
local name = clicker:get_player_name()
local player_attributes = clicker:get_meta()
local voting = player_attributes:get_string('voting')
local mode = player_attributes:get_string('mode')
local map_id = lobby.game[name]
if voting == 'false' then
if map_id ~= 'lobby' and not string.match(map_id, '_ghost', '_builder', '_singleplayer') then
if map_id ~= 'lobby' and mode == 'player' then
local game_data = lobby.savedata.data[map_id]
local game_pos = game_data['level_pos']
local survivors = lobby.players_on_level(map_id)
@ -14,7 +15,7 @@ function lobby.press_button(pos, node, clicker)
if lobby.game[rname] == map_id then
lobby.voted[rname] = false
player:set_physics_override({speed=0})
player_attributes:get_string('voting', 'true')
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))
player:setpos({x=game_pos.x+(math.random(-3,3)),y=game_pos.y,z=game_pos.z+(math.random(-3,3))})

View File

@ -24,16 +24,16 @@ Retriving data:
local game_data = lobby.savedata.data[map_id]
local game_pos = game_data['level_pos']
player_attributes:set_string('play_type', 'builder')
player_attributes:set_string('mode', 'builder')
This is set anytime a player goes to a level they have build access on.
player_attributes:set_string('play_type', 'player')
player_attributes:set_string('mode', 'player')
This is set when a player is playing a level with other people, as it's meant to be played.
player_attributes:set_string('play_type', 'singleplayer')
player_attributes:set_string('mode', 'solo')
This is set when a player plays a level solo, usually to earn XP, but could also be to explore levels.
player_attributes:set_string('play_type', 'ghost')
player_attributes:set_string('mode', 'ghost')
This is set when a player, playing with others, dies on a level.
]]

View File

@ -18,7 +18,7 @@ minetest.register_on_joinplayer(function(player)
local privs = minetest.get_player_privs(name)
privs.worldedit = nil
minetest.set_player_privs(name, privs)
player_attributes:set_string('play_type', 'builder')
player_attributes:set_string('mode', 'builder')
lobby.suspect[name] = 0
lobby.game[name] = 'lobby'
lobby.voted[name] = true
@ -27,7 +27,7 @@ minetest.register_on_joinplayer(function(player)
local player_inv = player:get_inventory()
player_inv:set_list('main', {})
player:set_pos(lobby.spawn_pos)
player_attributes:set_string('play_type', 'singleplayer')
player_attributes:set_string('mode', 'solo')
end
if not pro_player(player) then
player:set_pos(lobby.spawn_pos)
@ -39,11 +39,11 @@ minetest.register_on_dieplayer(function(player)
local name = player:get_player_name()
local player_attributes = player:get_meta()
local map_id = lobby.game[name]
local play_type = player_attributes:get_string('play_type')
local mode = player_attributes:get_string('mode')
local pos = vector.round(player:get_pos())
player_attributes:set_string('spawn_pos', minetest.pos_to_string(pos))
player:set_physics_override({speed=1})
if map_id ~= 'lobby' and play_type == 'player' then
if map_id ~= 'lobby' and mode == 'player' then
local player_inv = player:get_inventory()
player_inv:set_list('main', {})
local traitor = lobby.traitors[map_id]
@ -67,7 +67,7 @@ minetest.register_on_dieplayer(function(player)
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_attributes:set_string('play_type', 'ghost')
player_attributes:set_string('mode', 'ghost')
minetest.chat_send_player(name, 'You\'re now a ghost. Return to the lobby with the /lobby chat command.')
lobby.game[name] = map_id..'_ghost'
if name == traitor then
@ -75,7 +75,7 @@ minetest.register_on_dieplayer(function(player)
else
lobby.update_maps(map_id)
end
elseif play_type == 'singleplayer' or play_type == 'ghost' then
elseif mode == 'solo' or mode == 'ghost' then
local player_inv = player:get_inventory()
player_inv:set_list('main', {})
end
@ -86,17 +86,17 @@ minetest.register_on_respawnplayer(function(player)
local player_attributes = player:get_meta()
local pos = minetest.string_to_pos(player_attributes:get_string('spawn_pos'))
local map_id = lobby.game[name]
local play_type = player_attributes:get_string('play_type')
local mode = player_attributes:get_string('mode')
player:set_armor_groups({immortal=1})
minetest.chat_send_player(name, 'You are immortal for 10 seconds.')
minetest.after(10, function()
player:set_armor_groups({})
minetest.chat_send_player(name, 'Immortallity has ended.')
end)
if map_id ~= 'lobby' and play_type == 'ghost' then
if map_id ~= 'lobby' and mode == 'ghost' then
player:set_pos(pos)
return true
elseif play_type == 'builder' then
elseif mode == 'builder' then
player:set_pos(pos)
return true
else
@ -107,7 +107,7 @@ minetest.register_on_respawnplayer(function(player)
})
player:set_properties({visual_size = {x = 1, y = 1}, collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}})
player:set_pos(lobby.spawn_pos)
player_attributes:set_string('play_type', 'singleplayer')
player_attributes:set_string('mode', 'solo')
return true
end
end)

View File

@ -66,7 +66,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
privs.fast = true
minetest.set_player_privs(name, privs)
minetest.show_formspec(name, 'lobby:shop_priv', lobby_shop_priv(player))
player_attributes:set_string('play_type', 'builder')
player_attributes:set_string('mode', 'builder')
else
minetest.chat_send_player(name, 'You either don\'t have 100 XP or you already have the priv.')
end
@ -83,7 +83,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
privs.areas = nil
minetest.set_player_privs(name, privs)
minetest.chat_send_player(name, 'Privs revoked! Play some games in the lobby')
player_attributes:set_string('play_type', 'singleplayer')
player_attributes:set_string('mode', 'solo')
local inv = player:get_inventory()
local old_inv = inv:get_list('main')
inv:set_list('builder', old_inv)
@ -95,7 +95,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
privs.fast = true
minetest.set_player_privs(name, privs)
minetest.chat_send_player(name, 'Privs restored!')
player_attributes:set_string('play_type', 'builder')
player_attributes:set_string('mode', 'builder')
local inv = player:get_inventory()
local old_inv = inv:get_list('builder')
inv:set_list('builder', {})

View File

@ -18,7 +18,6 @@ minetest.register_tool('lobby:shank', {
local death_pos = player:get_pos()
minetest.sound_play('lobby_kill', {pos = death_pos, gain = 1, max_hear_distance = 16})
local count = lobby.map[map_name]-- or 0
print ('number of players left on level is '..count)
if count > 0 then
minetest.chat_send_player(traitor, 'Weapon Cooldown.')
minetest.after(10, function()

View File

@ -14,7 +14,7 @@ sfinv.register_page('sfinv:help', {
local xp = player_attributes:get_float('xp')
local luck = player_attributes:get_int('luck')
local health = player_attributes:get_int('hp')
local play_type = player_attributes:get_string('play_type')
local mode = player_attributes:get_string('mode')
if not creative.is_enabled_for(player:get_player_name()) then
return sfinv.make_formspec(player, context,
'textarea[.25,0;2,2;;;Player Stats:\n XP: '..xp..'\n HP: '..health..'\n Luck: '..luck..']'..
@ -102,11 +102,11 @@ sfinv.register_page('sfinv:debug', {
local xp = player_attributes:get_float('xp')
local luck = player_attributes:get_int('luck')
local health = player_attributes:get_int('hp')
local play_type = player_attributes:get_string('play_type')
local mode = player_attributes:get_string('mode')
local map_id = lobby.game[name]
return sfinv.make_formspec(player, context,
'textarea[.25,0;2,2;;;Player Stats:\n XP: '..xp..'\n HP: '..health..'\n Luck: '..luck..']'..
'textarea[2.5,0;2,3;;;Playing as:\n '..play_type..'\nOn map:\n '..map_id..']'..
'textarea[2.5,0;2,3;;;Playing as:\n '..mode..'\nOn map:\n '..map_id..']'..
'textarea[.25,2.5;8,4;;;This screen will be expanded with time to include helpful debug information for people play testing.]'
, false)
end

View File

@ -86,25 +86,27 @@ minetest.register_node('signs:1_metal', {
on_receive_fields = signs.on_receive_fields
})
minetest.register_node('signs:poster_1', {
description = '',
drawtype = 'mesh',
mesh = 'signs_poster_1.obj',
groups = {breakable=1},
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = 'facedir',
tiles = {'signs_1_steel.png'},
walkable = false,
selection_box = {
type = 'fixed',
fixed = {-.5, -.5, -.5, .5, -.4375, .5},
},
collision_box = {
type = 'fixed',
fixed = {-.5, -.5, -.5, .5, -.4375, .5},
},
on_construct = signs.on_construct,
after_place_node = signs.after_place_node,
on_receive_fields = signs.on_receive_fields
})
for i = 1, 3 do
minetest.register_node('signs:poster_'..i, {
description = 'Poster',
drawtype = 'mesh',
mesh = 'signs_poster_1.obj',
groups = {breakable=1},
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = 'facedir',
tiles = {'signs_poster_'..i..'.png'},
walkable = false,
selection_box = {
type = 'fixed',
fixed = {-.5, -.5, .45, .5, .5, .5},
},
collision_box = {
type = 'fixed',
fixed = {-.5, -.5, .45, .5, .5, .5},
},
on_construct = signs.on_construct,
after_place_node = signs.after_place_node,
on_receive_fields = signs.on_receive_fields
})
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -6,7 +6,7 @@ end
function tasks.add_xp(pos, node, puncher, swap_to) --This function shouldn't be used on nodes that use formspecs.
local player_attributes = puncher:get_meta()
local play_type = player_attributes:get_string('play_type')
local mode = player_attributes:get_string('mode')
local meta = minetest.get_meta(pos)
local earned_xp = meta:get_int('xp') or 1
local wield = puncher:get_wielded_item()
@ -24,12 +24,12 @@ function tasks.add_xp(pos, node, puncher, swap_to) --This function shouldn't be
meta:set_string('formspec', '') --Not sure why I added this.
if map_id ~= 'lobby' then
if name ~= traitor then
if play_type == 'ghost' then
if mode == 'ghost' then
earned_xp = math.floor(earned_xp/2)
map_id = string.sub(map_id, 0, -7)
end
local game_data = lobby.savedata.data[map_id]
if lobby.xp[map_id] and play_type ~= 'singleplayer' then
if lobby.xp[map_id] and mode ~= 'solo' then
lobby.xp[map_id] = lobby.xp[map_id] + earned_xp
local needed_xp = game_data['xp'] - lobby.xp[map_id]
minetest.chat_send_player(name, 'You just earned '..earned_xp..' XP for your team.\nYou need '..needed_xp..' more XP to defeat the imposter.')
@ -49,17 +49,17 @@ end
function tasks.only_add_xp(xp, name) -- This function only adds XP, you are responsible for modifying the task node yourself.
local player = minetest.get_player_by_name(name)
local player_attributes = player:get_meta()
local play_type = player_attributes:get_string('play_type')
local mode = player_attributes:get_string('mode')
local map_id = lobby.game[name] or 'lobby'
local traitor = lobby.traitors[map_id]
if map_id ~= 'lobby' then
if name ~= traitor then
if play_type == 'ghost' then
if mode == 'ghost' then
xp = math.floor(xp/2)
map_id = string.sub(map_id, 0, -7)
end
local game_data = lobby.savedata.data[map_id]
if lobby.xp[map_id] and play_type ~= 'singleplayer' then
if lobby.xp[map_id] and mode ~= 'solo' then
lobby.xp[map_id] = lobby.xp[map_id] + xp
local needed_xp = game_data['xp'] - lobby.xp[map_id]
minetest.chat_send_player(name, 'You just earned '..xp..' XP for your team.\nYou need '..needed_xp..' more XP to defeat the imposter.')