Syncing code to upstream.
|
@ -71,12 +71,12 @@ end
|
|||
|
||||
if minetest.global_exists("sfinv") then -- sfinv installed
|
||||
assert(sfinv.enabled)
|
||||
local orig_get = sfinv.pages["sfinv:main"].get
|
||||
sfinv.override_page("sfinv:main", {
|
||||
local orig_get = sfinv.pages["sfinv:help"].get
|
||||
sfinv.override_page("sfinv:help", {
|
||||
get = function(self, player, context)
|
||||
local can_worldedit = minetest.check_player_privs(player, {worldedit=true})
|
||||
local fs = orig_get(self, player, context)
|
||||
return fs .. (can_worldedit and "image_button[0,0;1,1;inventory_plus_worldedit_gui.png;worldedit_gui;]" or "")
|
||||
return fs .. (can_worldedit and "image_button[7,4;1,1;inventory_plus_worldedit_gui.png;worldedit_gui;]" or "")
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -86,7 +86,7 @@ if minetest.global_exists("sfinv") then -- sfinv installed
|
|||
worldedit.show_page(player:get_player_name(), "worldedit_gui")
|
||||
return true
|
||||
elseif fields.worldedit_gui_exit then --return to original page
|
||||
sfinv.set_page(player, "sfinv:main")
|
||||
sfinv.set_page(player, "sfinv:help")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
|
|
@ -5,17 +5,6 @@ minetest.register_item(':', {
|
|||
wield_image = 'wieldhand.png',
|
||||
wield_scale = {x=1,y=1,z=2.5},
|
||||
range = 10,
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1},
|
||||
snappy = {times={[3]=0.40}, uses=0, maxlevel=1},
|
||||
oddly_breakable_by_hand = {times={[1]=3.50,[2]=2.00,[3]=0.10}, uses=0},
|
||||
cracky = {times={[3]=0.40, [4]=0.30,}, uses=0, maxlevel=2},
|
||||
spawn = {times={[1]=.1,}, uses=0}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
gamer.registered_player_models = { }
|
||||
|
@ -107,7 +96,7 @@ end
|
|||
|
||||
-- Update appearance when the player joins
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
player:get_inventory():set_size('main', 8*3)
|
||||
player:get_inventory():set_size('main', 8*4)
|
||||
gamer.player_attached[player:get_player_name()] = false
|
||||
gamer.player_set_model(player, 'gamer_model.b3d')
|
||||
player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30)
|
||||
|
|
|
@ -24,6 +24,7 @@ minetest.register_node("liquids:water_source", {
|
|||
},
|
||||
},
|
||||
},
|
||||
use_texture_alpha = "blend",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
|
@ -67,6 +68,7 @@ minetest.register_node("liquids:water_flowing", {
|
|||
},
|
||||
},
|
||||
},
|
||||
use_texture_alpha = "blend",
|
||||
paramtype = "light",
|
||||
paramtype2 = "flowingliquid",
|
||||
walkable = false,
|
||||
|
@ -110,6 +112,7 @@ minetest.register_node("liquids:river_water_source", {
|
|||
},
|
||||
},
|
||||
},
|
||||
use_texture_alpha = "blend",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
|
@ -158,6 +161,7 @@ minetest.register_node("liquids:river_water_flowing", {
|
|||
},
|
||||
},
|
||||
},
|
||||
use_texture_alpha = "blend",
|
||||
paramtype = "light",
|
||||
paramtype2 = "flowingliquid",
|
||||
walkable = false,
|
||||
|
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 30 KiB |
|
@ -29,6 +29,7 @@ minetest.register_chatcommand('lobby', {
|
|||
local player = minetest.get_player_by_name(name)
|
||||
local ghost = player:get_attribute('ghost')
|
||||
if ghost == 'true' then
|
||||
local player_attributes = player:get_meta()
|
||||
gamer.player_set_textures(player,{'gamer_skin.png'})
|
||||
player:set_nametag_attributes({
|
||||
color = {a = 255, r = 255, g = 255, b = 255}
|
||||
|
@ -36,7 +37,7 @@ minetest.register_chatcommand('lobby', {
|
|||
player:set_properties({visual_size = {x = 1, y = 1}, collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}})
|
||||
player:setpos({x=0, y=0, z=0})
|
||||
minetest.chat_send_player(name, 'Here you are.')
|
||||
player:set_attribute('ghost', 'false')
|
||||
player_attributes:set_string('ghost', 'false')
|
||||
local player_inv = player:get_inventory()
|
||||
player_inv:set_list('main', {})
|
||||
else
|
||||
|
|
|
@ -29,6 +29,14 @@ function lobby.is_integer(input)
|
|||
end
|
||||
end
|
||||
|
||||
function lobby.give_xp(player, amount)
|
||||
local player_attributes = player:get_meta()
|
||||
local xp = player_attributes:get_float('xp') or 0
|
||||
xp = xp + amount
|
||||
player_attributes:set_float('xp', xp)
|
||||
sfinv.set_player_inventory_formspec(player)
|
||||
end
|
||||
|
||||
function lobby.corpse_entry(pos, map_id)
|
||||
local corpse_pos = lobby.corpses[map_id]
|
||||
table.insert(corpse_pos, pos)
|
||||
|
@ -54,15 +62,22 @@ function lobby.players_on_level(map_id)
|
|||
end
|
||||
|
||||
function lobby.update_maps(map_id)
|
||||
local count = lobby.map[map_id] - 1
|
||||
local count = lobby.map[map_id] - 1 or 10
|
||||
if count <= 1 then
|
||||
lobby.map[map_id] = 0
|
||||
lobby.corpse_removal(map_id)
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local rname = player:get_player_name()
|
||||
local rname = player:get_player_name()
|
||||
if lobby.game[rname] == map_id or map_id..'_ghost' then
|
||||
minetest.chat_send_player(rname, 'Kicking you to the lobby')
|
||||
local player_attributes = player:get_meta()
|
||||
gamer.player_set_textures(player,{'gamer_skin.png'})
|
||||
player:set_nametag_attributes({
|
||||
color = {a = 255, r = 255, g = 255, b = 255}
|
||||
})
|
||||
player:set_properties({visual_size = {x = 1, y = 1}, collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}})
|
||||
player:setpos({x=0, y=0, z=0})
|
||||
player_attributes:set_string('ghost', 'false')
|
||||
minetest.chat_send_player(rname, 'Kicking you to the lobby')
|
||||
player:set_physics_override({speed=1})
|
||||
local player_inv = player:get_inventory()
|
||||
player_inv:set_list('main', {})
|
||||
|
@ -87,13 +102,14 @@ function lobby.vote(map_id, force)
|
|||
local rname = player:get_player_name()
|
||||
if lobby.game[rname] == map_id then
|
||||
local score = lobby.suspect[rname]
|
||||
local player_attributes = player:get_meta()
|
||||
if score > high_score then
|
||||
high_score = score
|
||||
kick = rname
|
||||
end
|
||||
lobby.suspect[rname] = 0
|
||||
player:set_physics_override({speed=1})
|
||||
player:set_attribute('voting', 'false')
|
||||
player_attributes:set_string('voting', 'false')
|
||||
if kick == traitor then
|
||||
lobby.team_win(map_id)
|
||||
elseif needed_votes == 1 and kick ~= traitor then
|
||||
|
@ -103,7 +119,7 @@ function lobby.vote(map_id, force)
|
|||
end
|
||||
if kick ~= '' then
|
||||
lobby.message_to_level(map_id, 'The votes are in, '..kick..' will be kicked.')
|
||||
player = minetest.get_player_by_name(kick)
|
||||
local player = minetest.get_player_by_name(kick)
|
||||
player:setpos({x=0, y=0, z=0})
|
||||
local player_inv = player:get_inventory()
|
||||
player_inv:set_list('main', {})
|
||||
|
@ -119,13 +135,28 @@ function lobby.team_win(map_id)
|
|||
lobby.corpse_removal(map_id)
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local rname = player:get_player_name()
|
||||
if lobby.game[rname] == map_id or map_id..'_ghost' then
|
||||
if lobby.game[rname] == map_id then
|
||||
lobby.give_xp(player, 25)
|
||||
minetest.chat_send_player(rname, 'The traitor was defeated.')
|
||||
player:setpos({x=0, y=0, z=0})
|
||||
player:set_physics_override({speed=1})
|
||||
local player_inv = player:get_inventory()
|
||||
player_inv:set_list('main', {})
|
||||
lobby.game[rname] = 'lobby'
|
||||
elseif lobby.game[rname] == map_id..'_ghost' then
|
||||
local player_attributes = player:get_meta()
|
||||
gamer.player_set_textures(player,{'gamer_skin.png'})
|
||||
player:set_nametag_attributes({
|
||||
color = {a = 255, r = 255, g = 255, b = 255}
|
||||
})
|
||||
player:set_properties({visual_size = {x = 1, y = 1}, collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}})
|
||||
player:setpos({x=0, y=0, z=0})
|
||||
player_attributes:set_string('ghost', 'false')
|
||||
minetest.chat_send_player(rname, 'The traitor was defeated.')
|
||||
player:set_physics_override({speed=1})
|
||||
local player_inv = player:get_inventory()
|
||||
player_inv:set_list('main', {})
|
||||
lobby.game[rname] = 'lobby'
|
||||
end
|
||||
end
|
||||
lobby.map[map_id] = 0
|
||||
|
@ -135,6 +166,7 @@ end
|
|||
function lobby.traitor_win(traitor, map_id)
|
||||
local player = minetest.get_player_by_name(traitor)
|
||||
lobby.corpse_removal(map_id)
|
||||
lobby.give_xp(player, 25)
|
||||
minetest.chat_send_player(traitor, 'CONGRATULATIONS!!! You killed all the crew!')
|
||||
lobby.game[traitor] = 'lobby'
|
||||
player:setpos({x=0, y=0, z=0})
|
||||
|
@ -146,7 +178,14 @@ function lobby.traitor_win(traitor, map_id)
|
|||
local rname = player:get_player_name()
|
||||
if lobby.game[rname] == map_id..'_ghost' then
|
||||
minetest.chat_send_player(rname, 'The traitor won.')
|
||||
local player_attributes = player:get_meta()
|
||||
gamer.player_set_textures(player,{'gamer_skin.png'})
|
||||
player:set_nametag_attributes({
|
||||
color = {a = 255, r = 255, g = 255, b = 255}
|
||||
})
|
||||
player:set_properties({visual_size = {x = 1, y = 1}, collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}})
|
||||
player:setpos({x=0, y=0, z=0})
|
||||
player_attributes:set_string('ghost', 'false')
|
||||
player:set_physics_override({speed=1})
|
||||
local player_inv = player:get_inventory()
|
||||
player_inv:set_list('main', {})
|
||||
|
|
|
@ -114,9 +114,9 @@ minetest.register_node('lobby:button_1', {
|
|||
local meta = minetest.get_meta(pos)
|
||||
local id = meta:get_string('id')
|
||||
local item = itemstack:get_name()
|
||||
local player_name = clicker:get_player_name()
|
||||
local owner = meta:get_string('owner')
|
||||
if item ~= 'creative:tool_breaking' then
|
||||
local player_name = clicker:get_player_name()
|
||||
local owner = meta:get_string('owner')
|
||||
local name = meta:get_string('name')
|
||||
local player_count = meta:get_string('player_count')
|
||||
local xp = meta:get_string('xp')
|
||||
|
@ -185,6 +185,7 @@ minetest.register_node('lobby:button_1', {
|
|||
minetest.set_player_privs(map_players[i], privs)
|
||||
end
|
||||
elseif puncher:get_player_control().sneak then
|
||||
local name = puncher.get_player_name()
|
||||
gamer.player_set_textures(puncher,{'lobby_ghost.png'})
|
||||
puncher:set_nametag_attributes({
|
||||
color = {a = 0, r = 255, g = 255, b = 255}
|
||||
|
|
|
@ -10,11 +10,12 @@ end
|
|||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local player_attributes = player:get_meta()
|
||||
player_attributes:set_string('ghost', 'false')
|
||||
lobby.suspect[name] = 0
|
||||
lobby.game[name] = 'lobby'
|
||||
lobby.voted[name] = true
|
||||
player:set_hp(40)
|
||||
player:set_attribute('ghost', 'false')
|
||||
if not_builder(player) then
|
||||
local player_inv = player:get_inventory()
|
||||
player_inv:set_list('main', {})
|
||||
|
@ -33,6 +34,7 @@ minetest.register_on_dieplayer(function(player)
|
|||
local player_inv = player:get_inventory()
|
||||
player_inv:set_list('main', {})
|
||||
if map_id ~= 'lobby' then
|
||||
local player_attributes = player:get_meta()
|
||||
local traitor = lobby.traitors[map_id]
|
||||
local pos = vector.round(player:get_pos())
|
||||
local param2 = minetest.dir_to_facedir(player:get_look_dir())
|
||||
|
@ -53,7 +55,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:set_attribute('ghost', 'true')
|
||||
player_attributes:set_string('ghost', 'true')
|
||||
player:set_attribute('spawn_pos', minetest.pos_to_string(pos))
|
||||
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'
|
||||
|
@ -68,9 +70,19 @@ end)
|
|||
minetest.register_on_respawnplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local pos = minetest.string_to_pos(player:get_attribute('spawn_pos'))
|
||||
if pos then
|
||||
local map_id = lobby.game[name]
|
||||
if map_id ~= 'lobby' then
|
||||
player:set_pos(pos)
|
||||
return true
|
||||
else
|
||||
local player_attributes = player:get_meta()
|
||||
gamer.player_set_textures(player,{'gamer_skin.png'})
|
||||
player:set_nametag_attributes({
|
||||
color = {a = 255, r = 255, g = 255, b = 255}
|
||||
})
|
||||
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({x=0, y=0, z=0})
|
||||
player_attributes:set_string('ghost', 'true')
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -82,7 +94,9 @@ minetest.register_on_leaveplayer(function(player, timed_out)
|
|||
minetest.chat_send_all('somebody quit the '..map_id..' level')
|
||||
local player_inv = player:get_inventory()
|
||||
player_inv:set_list('main', {})
|
||||
lobby.update_maps(map_id)
|
||||
if not string.find(map_id, 'ghost') then
|
||||
lobby.update_maps(map_id)
|
||||
end
|
||||
if traitor == name then
|
||||
lobby.team_win(map_id)
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ minetest.register_tool('lobby:shank', {
|
|||
local victim = minetest.get_player_by_name(player_name)
|
||||
local player_inv = player:get_inventory()
|
||||
victim:set_hp(0)
|
||||
local count = lobby.map[map_name]
|
||||
local count = lobby.map[map_name] or 0
|
||||
if count > 1 then
|
||||
minetest.chat_send_player(traitor, 'Weapon Cooldown.')
|
||||
minetest.after(10, function()
|
||||
|
|
|
@ -126,3 +126,4 @@ dofile(minetest.get_modpath('plants')..'/crops.lua')
|
|||
dofile(minetest.get_modpath('plants')..'/flowers.lua')
|
||||
dofile(minetest.get_modpath('plants')..'/fungi.lua')
|
||||
dofile(minetest.get_modpath('plants')..'/grass.lua')
|
||||
dofile(minetest.get_modpath('plants')..'/misc.lua')
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
minetest.register_node('plants:pumpkin', {
|
||||
description = 'Pumpkin',
|
||||
tiles = {'plants_pumpkin_top.png', 'plants_pumpkin_top.png', 'plants_pumpkin_side.png'},
|
||||
groups = {breakable=1},
|
||||
paramtype2 = 'facedir',
|
||||
on_place = minetest.rotate_and_place,
|
||||
})
|
||||
|
||||
minetest.register_node('plants:jackolantern_off', {
|
||||
description = 'Jack-O-Lantern (off)',
|
||||
tiles = {'plants_pumpkin_top.png', 'plants_pumpkin_top.png', 'plants_pumpkin_side.png', 'plants_pumpkin_side.png', 'plants_pumpkin_side.png', 'plants_pumpkin_face_off.png'},
|
||||
groups = {breakable=1},
|
||||
paramtype2 = 'facedir',
|
||||
on_place = minetest.rotate_and_place,
|
||||
})
|
||||
|
||||
minetest.register_node('plants:jackolantern_on', {
|
||||
description = 'Jack-O-Lantern (on)',
|
||||
tiles = {'plants_pumpkin_top.png', 'plants_pumpkin_top.png', 'plants_pumpkin_side.png', 'plants_pumpkin_side.png', 'plants_pumpkin_side.png', 'plants_pumpkin_face_on.png'},
|
||||
groups = {breakable=1},
|
||||
paramtype2 = 'facedir',
|
||||
light_source = 10,
|
||||
paramtype = 'light',
|
||||
on_place = minetest.rotate_and_place,
|
||||
})
|
After Width: | Height: | Size: 9.6 KiB |
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 9.6 KiB |
|
@ -37,16 +37,8 @@ function sfinv.get_nav_fs(player, context, nav, current_idx)
|
|||
end
|
||||
|
||||
local theme_inv = [[
|
||||
image[0,5.2;1,1;gui_hb_bg.png]
|
||||
image[1,5.2;1,1;gui_hb_bg.png]
|
||||
image[2,5.2;1,1;gui_hb_bg.png]
|
||||
image[3,5.2;1,1;gui_hb_bg.png]
|
||||
image[4,5.2;1,1;gui_hb_bg.png]
|
||||
image[5,5.2;1,1;gui_hb_bg.png]
|
||||
image[6,5.2;1,1;gui_hb_bg.png]
|
||||
image[7,5.2;1,1;gui_hb_bg.png]
|
||||
list[current_player;main;0,5.2;8,1;]
|
||||
list[current_player;main;0,6.35;8,3;8]
|
||||
listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]
|
||||
list[current_player;main;0,5;8,4;]
|
||||
]]
|
||||
|
||||
function sfinv.make_formspec(player, context, content, show_inv, size)
|
||||
|
@ -60,7 +52,7 @@ function sfinv.make_formspec(player, context, content, show_inv, size)
|
|||
end
|
||||
|
||||
function sfinv.get_homepage_name(player)
|
||||
return "sfinv:main"
|
||||
return "sfinv:help"
|
||||
end
|
||||
|
||||
function sfinv.get_formspec(player, context)
|
||||
|
|
|
@ -5,11 +5,36 @@ dofile(minetest.get_modpath("sfinv") .. "/api.lua")
|
|||
-- Load support for MT game translation.
|
||||
local S = minetest.get_translator("sfinv")
|
||||
|
||||
sfinv.register_page("sfinv:main", {
|
||||
title = S("Main"),
|
||||
get = function(self, player, context)
|
||||
return sfinv.make_formspec(player, context, [[
|
||||
textarea[1.5,.5;7,5;;Description of map;I have no idea what this will look like. LOL so I just need to make this super long and put in a whole bunch of nonesense text to see how it wraps and stuff. I suppose at some point this could be possibly used to display information about the current game, XP levels, remaining players, etc.]
|
||||
]], true)
|
||||
end
|
||||
sfinv.register_page("sfinv:help", {
|
||||
title = S("Help"),
|
||||
get = function(self, player, context)
|
||||
if not creative.is_enabled_for(player:get_player_name()) then
|
||||
return sfinv.make_formspec(player, context,
|
||||
'textarea[.25,0;8.5,5;;; Traitor is a game based on Among Us. Your goal is to vote out the traitor if you are not the traitor, or to kill all the other players if you are the traitor.\n'..
|
||||
' I will add more help information here in the future. For the time being use the /help chat command and look at the lobby entries.]'
|
||||
, true)
|
||||
else
|
||||
return sfinv.make_formspec(player, context,
|
||||
'textarea[.25,0;8.5,5;;; Traitor is a game based on Among Us. Your goal is to vote out the traitor if you are not the traitor, or to kill all the other players if you are the traitor.\n'..
|
||||
' I will add more help information here in the future. For the time being use the /help chat command and look at the lobby entries.\n'..
|
||||
' Hey look at you, you have the ability to build new levels!]'
|
||||
, true)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
sfinv.register_page('sfinv:xp', {
|
||||
title = 'XP',
|
||||
is_in_nav = function(self, player, context)
|
||||
return not creative.is_enabled_for(player:get_player_name())
|
||||
end,
|
||||
get = function(self, player, context)
|
||||
local player_attributes = player:get_meta()
|
||||
local xp = player_attributes:get_float('xp') or 0
|
||||
return sfinv.make_formspec(player, context,
|
||||
'textarea[.25,0;8.5,3;;; You currently have '..xp..' points available. Once implemented you\'ll be able to use these points to buy perks in a store.\n'..
|
||||
' This is NOT a pay to win scheme. Items will include clothing/skins extra health, and breath. (The shank insta-kills no matter how much health you have)\n\n'..
|
||||
' You earn 25 points for every level you win, either as the traitor, or a surviving team member. You can also earn 1 point for each task you complete in the lobby.]'
|
||||
, true)
|
||||
end
|
||||
})
|
||||
|
|
|
@ -5,54 +5,65 @@ function tasks.check_xp(map_id, needed_xp)
|
|||
end
|
||||
|
||||
function tasks.add_xp(pos, node, puncher, swap_to)
|
||||
local ghost = puncher:get_attribute('ghost')
|
||||
if ghost == 'false' then
|
||||
local player_attributes = puncher:get_meta()
|
||||
local ghost = player_attributes:get_string('ghost')
|
||||
local meta = minetest.get_meta(pos)
|
||||
local timer_length = tonumber(meta:get_string('timer')) or 60
|
||||
local earned_xp = tonumber(meta:get_string('xp')) or 1
|
||||
local wield = puncher:get_wielded_item()
|
||||
local wield_name = wield:get_name()
|
||||
if wield_name ~= 'creative:tool_breaking' then
|
||||
local name = puncher:get_player_name()
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
local map_id = lobby.game[name]
|
||||
local traitor = lobby.traitors[map_id]
|
||||
minetest.swap_node(pos, {name = swap_to, param2 = node.param2})
|
||||
local meta = minetest.get_meta(pos)
|
||||
local timer_length = tonumber(meta:get_string('timer')) or 60
|
||||
local earned_xp = tonumber(meta:get_string('xp')) or 1
|
||||
local wield = puncher:get_wielded_item()
|
||||
local wield_name = wield:get_name()
|
||||
if wield_name == '' then
|
||||
local name = puncher:get_player_name()
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
local map_id = lobby.game[name]
|
||||
local traitor = lobby.traitors[map_id]
|
||||
minetest.swap_node(pos, {name = swap_to, param2 = node.param2})
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string('formspec', '')
|
||||
timer:start(timer_length)
|
||||
if map_id ~= 'lobby' then
|
||||
if name ~= traitor then
|
||||
local game_data = lobby.savedata.data[map_id]
|
||||
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.')
|
||||
tasks.check_xp(map_id, needed_xp)
|
||||
else
|
||||
minetest.chat_send_player(name, 'You\'re the traitor, you can do tasks, but you won\'t earn XP. Try killing the other players.')
|
||||
meta:set_string('formspec', '')
|
||||
timer:start(timer_length)
|
||||
if map_id ~= 'lobby' then
|
||||
if name ~= traitor then
|
||||
if ghost == 'true' 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]
|
||||
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.')
|
||||
tasks.check_xp(map_id, needed_xp)
|
||||
else
|
||||
minetest.chat_send_player(name, 'You\'re the traitor, you can do tasks, but you won\'t earn XP. Try killing the other players.')
|
||||
end
|
||||
elseif map_id == 'lobby' then
|
||||
lobby.give_xp(puncher, 1)
|
||||
end
|
||||
end
|
||||
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 ghost = player:get_attribute('ghost')
|
||||
if ghost == 'false' then
|
||||
local map_id = lobby.game[name]
|
||||
local traitor = lobby.traitors[map_id]
|
||||
if map_id ~= 'lobby' then
|
||||
if name ~= traitor then
|
||||
local game_data = lobby.savedata.data[map_id]
|
||||
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.')
|
||||
tasks.check_xp(map_id, needed_xp)
|
||||
else
|
||||
minetest.chat_send_player(name, 'You\'re the traitor, you can do tasks, but you won\'t earn XP. Try killing the other players.')
|
||||
local player_attributes = player:get_meta()
|
||||
local ghost = player_attributes:get_string('ghost')
|
||||
local map_id = lobby.game[name]
|
||||
local traitor = lobby.traitors[map_id]
|
||||
if map_id ~= 'lobby' then
|
||||
if name ~= traitor then
|
||||
if ghost == 'true' then
|
||||
xp = math.floor(xp/2)
|
||||
map_id = string.sub(map_id, 0, -7)
|
||||
print (xp..' is xp, level is '..map_id)
|
||||
end
|
||||
local game_data = lobby.savedata.data[map_id]
|
||||
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.')
|
||||
tasks.check_xp(map_id, needed_xp)
|
||||
else
|
||||
minetest.chat_send_player(name, 'You\'re the traitor, you can do tasks, but you won\'t earn XP. Try killing the other players.')
|
||||
end
|
||||
elseif map_id == 'lobby' then
|
||||
lobby.give_xp(player, 1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,11 @@ local storage_locker =
|
|||
'textarea[2.25,.5;4.25,2.1;;Instructions;Place an item request in the left, and take your item out of the slot on the right.\nPlease be patient, it takes time to find the part you want.]' ..
|
||||
'list[current_name;src;.75,1;1,1;]'..
|
||||
'list[current_name;dst;6.25,1;1,1;]'..
|
||||
'list[current_player;main;0,3;8,3;]'
|
||||
'list[current_player;main;0,3;8,3;]'..
|
||||
'listring[current_player;main]'..
|
||||
'listring[current_name;src]'..
|
||||
'listring[current_name;dst]'..
|
||||
'listring[current_player;main]'
|
||||
|
||||
minetest.register_node('tasks:storage_locker_0', {
|
||||
description = 'Red Storage Locker',
|
||||
|
|