Add equipment slots and jump dampener
parent
c04a61c950
commit
fba7f0f853
|
@ -85,6 +85,7 @@ Items:
|
|||
|
||||
Action groups:
|
||||
* `bagslots=X`: Bag with X slots
|
||||
* `equipment=1`: Item for the Equipment slots
|
||||
* `food=1`: Food (unspecified type)
|
||||
* `food=2`: Food (eating)
|
||||
* `food=3`: Food (drinking)
|
||||
|
|
|
@ -47,7 +47,6 @@ in the Minetest data folder.
|
|||
|
||||
## Important notices and short game guide
|
||||
|
||||
* Press the Aux1/Special key to change your jump strength
|
||||
* Be sure the `minetest.conf` file in the main Minetest directory doesn't have any parameters who are in conflict with the `minetest.conf` file from the `hades_revisited` directory. Especially mapgen parameters or stuff like `give_initial_stuff = false`
|
||||
* There only 1 biome, with the focus on terraforming and landscaping
|
||||
* Not everyone will like this game. But maybe there are some freaks out there ;-)
|
||||
|
|
|
@ -82,7 +82,8 @@ minetest.register_node("bones:bones", {
|
|||
})
|
||||
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
if minetest.is_creative_enabled(player:get_player_name()) then
|
||||
local name = player:get_player_name()
|
||||
if minetest.is_creative_enabled(name) then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -97,12 +98,11 @@ minetest.register_on_dieplayer(function(player)
|
|||
not minetest.registered_nodes[nn].can_dig(pos, player) then
|
||||
local player_inv = player:get_inventory()
|
||||
|
||||
for i=1,player_inv:get_size("main") do
|
||||
player_inv:set_stack("main", i, nil)
|
||||
end
|
||||
for i=1,player_inv:get_size("craft") do
|
||||
player_inv:set_stack("craft", i, nil)
|
||||
end
|
||||
player_inv:set_list("main", {})
|
||||
player_inv:set_list("craft", {})
|
||||
player_inv:set_list("equipment", {})
|
||||
local equipment_inv = minetest.get_inventory({type="detached", name=name.."_equipment"})
|
||||
equipment_inv:set_list("equipment", {})
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -114,22 +114,28 @@ minetest.register_on_dieplayer(function(player)
|
|||
local player_inv = player:get_inventory()
|
||||
inv:set_size("main", 10*4)
|
||||
|
||||
local empty_list = inv:get_list("main")
|
||||
inv:set_list("main", player_inv:get_list("main"))
|
||||
player_inv:set_list("main", empty_list)
|
||||
|
||||
for i=1,player_inv:get_size("craft") do
|
||||
inv:add_item("main", player_inv:get_stack("craft", i))
|
||||
player_inv:set_stack("craft", i, nil)
|
||||
end
|
||||
|
||||
for i=1,player_inv:get_size("equipment") do
|
||||
inv:add_item("main", player_inv:get_stack("equipment", i))
|
||||
end
|
||||
player_inv:set_list("main", {})
|
||||
player_inv:set_list("craft", {})
|
||||
player_inv:set_list("equipment", {})
|
||||
local equipment_inv = minetest.get_inventory({type="detached", name=name.."_equipment"})
|
||||
equipment_inv:set_list("equipment", {})
|
||||
|
||||
meta:set_string("formspec", "size[10,9]"..
|
||||
"list[current_name;main;0,0;10,4;]"..
|
||||
"list[current_player;main;0,5;10,4;]"..
|
||||
"listring[]"..
|
||||
"background9[25,22;10,9;bones_inventory.png;true;25,22,-20,-23]")
|
||||
meta:set_string("infotext", S("@1's fresh bones", player:get_player_name()))
|
||||
meta:set_string("owner", player:get_player_name())
|
||||
meta:set_string("infotext", S("@1's fresh bones", name))
|
||||
meta:set_string("owner", name)
|
||||
meta:set_int("time", 0)
|
||||
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
local S = minetest.get_translator("hades_equipment")
|
||||
local F = minetest.formspec_escape
|
||||
|
||||
hades_equipment = {}
|
||||
|
||||
local EQUIPMENT_COUNT = 4
|
||||
|
||||
local get_formspec = function(player, page)
|
||||
if page=="equipment" then
|
||||
local name = player:get_player_name()
|
||||
return "list[detached:"..name.."_equipment;equipment;3,2;4,1;0]"..
|
||||
"listring[]"
|
||||
end
|
||||
end
|
||||
|
||||
function hades_equipment.has_equipped(player, itemname, also_check_hotbar)
|
||||
local inv = player:get_inventory()
|
||||
if inv:contains_item("equipment", ItemStack(itemname)) then
|
||||
return true
|
||||
end
|
||||
if also_check_hotbar then
|
||||
-- Check if player carries the item in the hotbar
|
||||
local hotbar = player:hud_get_hotbar_itemcount()
|
||||
for i=1, hotbar do
|
||||
if inv:get_stack("main", i):get_name() == itemname then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
sfinv.register_page("hades_equipment:equipment", {
|
||||
title = S("Equipment"),
|
||||
is_in_nav = function(self, player, context)
|
||||
return true
|
||||
end,
|
||||
get = function(self, player, context)
|
||||
local player_name = player:get_player_name()
|
||||
local inv = player:get_inventory()
|
||||
local page
|
||||
page = "equipment"
|
||||
return sfinv.make_formspec(player, context, get_formspec(player, page), true)
|
||||
end,
|
||||
})
|
||||
|
||||
-- register_on_joinplayer
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local player_inv = player:get_inventory()
|
||||
local equipment_inv = minetest.create_detached_inventory(player:get_player_name().."_equipment",{
|
||||
on_put = function(inv, listname, index, stack, player)
|
||||
player:get_inventory():set_stack(listname, index, stack)
|
||||
end,
|
||||
on_take = function(inv, listname, index, stack, player)
|
||||
player:get_inventory():set_stack(listname, index, nil)
|
||||
end,
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
if stack:get_definition().groups.equipment and inv:get_stack(listname, index):is_empty() then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
allow_take = function(inv, listname, index, stack, player)
|
||||
local equipmentname = "equipment"..index
|
||||
if equipmentname and player:get_inventory():is_empty(equipmentname.."contents")==true then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
}, player:get_player_name())
|
||||
player_inv:set_size("equipment", EQUIPMENT_COUNT)
|
||||
equipment_inv:set_size("equipment", EQUIPMENT_COUNT)
|
||||
equipment_inv:set_list("equipment", player_inv:get_list("equipment"))
|
||||
end)
|
|
@ -0,0 +1,2 @@
|
|||
name = hades_equipment
|
||||
depends = sfinv
|
|
@ -1,3 +1,5 @@
|
|||
local S = minetest.get_translator("hades_movement")
|
||||
|
||||
local HIDE_JUMP_HUD_AFTER = 5 -- seconds after which to hide jump HUD
|
||||
local JUMP_FACTOR_HIGH = 1
|
||||
local JUMP_FACTOR_MED = 0.85
|
||||
|
@ -11,6 +13,26 @@ local jump_modes = {} -- current jump modes of each player
|
|||
local jump_huds = {} -- current HUD IDs of each player
|
||||
local remove_time = {} -- countdown timer to hide the jump HUD icon again
|
||||
|
||||
local update_mode = function(player, mode)
|
||||
local playername = player:get_player_name()
|
||||
jump_modes[playername] = mode
|
||||
local jump_height = JUMP_FACTOR_HIGH
|
||||
local img = "hades_movement_jump_high.png"
|
||||
if (mode == 1) then
|
||||
jump_height = JUMP_FACTOR_MED
|
||||
img = "hades_movement_jump_med.png"
|
||||
elseif (mode == 2) then
|
||||
jump_height = JUMP_FACTOR_LOW
|
||||
img = "hades_movement_jump_low.png"
|
||||
end
|
||||
playerphysics.add_physics_factor(player, "jump", "jump_mode", jump_height)
|
||||
if jump_huds[playername] then
|
||||
player:hud_change(jump_huds[playername], "text", img)
|
||||
end
|
||||
minetest.sound_play({name="hades_movement_change_jump_mode", gain=0.4}, {pitch=1-mode*0.1}, true)
|
||||
remove_time[playername] = HIDE_JUMP_HUD_AFTER
|
||||
end
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
|
@ -22,26 +44,14 @@ minetest.register_globalstep(function(dtime)
|
|||
jump_modes[name] = 0
|
||||
end
|
||||
-- Aux1 key: Cycle jump mode (high, medium, low jump strength)
|
||||
if ctrl.aux1 == true then
|
||||
local equipped = hades_equipment.has_equipped(player, "hades_movement:jump_dampener", false)
|
||||
if jump_modes[name] ~= 0 and not equipped then
|
||||
update_mode(player, 0)
|
||||
elseif ctrl.aux1 == true and equipped then
|
||||
if not ctrls[name].aux1 then
|
||||
local mode = jump_modes[name]
|
||||
mode = (mode - 1) % 3
|
||||
jump_modes[name] = mode
|
||||
local jump_height = JUMP_FACTOR_HIGH
|
||||
local img = "hades_movement_jump_high.png"
|
||||
if (mode == 1) then
|
||||
jump_height = JUMP_FACTOR_MED
|
||||
img = "hades_movement_jump_med.png"
|
||||
elseif (mode == 2) then
|
||||
jump_height = JUMP_FACTOR_LOW
|
||||
img = "hades_movement_jump_low.png"
|
||||
end
|
||||
playerphysics.add_physics_factor(player, "jump", "jump_mode", jump_height)
|
||||
if jump_huds[name] then
|
||||
player:hud_change(jump_huds[name], "text", img)
|
||||
end
|
||||
minetest.sound_play({name="hades_movement_change_jump_mode", gain=0.4}, {pitch=1-mode*0.1}, true)
|
||||
remove_time[name] = HIDE_JUMP_HUD_AFTER
|
||||
update_mode(player, mode)
|
||||
end
|
||||
ctrls[name].aux1 = true
|
||||
else
|
||||
|
@ -82,3 +92,21 @@ minetest.register_on_leaveplayer(function(player)
|
|||
jump_huds[name] = nil
|
||||
remove_time[name] = nil
|
||||
end)
|
||||
|
||||
minetest.register_tool("hades_movement:jump_dampener", {
|
||||
description = S("Jump Dampener"),
|
||||
_tt_help = S("Allows you to reduce your jumping height").."\n"..
|
||||
S("Put in Equipment slot to enable").."\n"..
|
||||
S("Push the 'Aux1' control to toggle"),
|
||||
-- TODO: Better inventory img
|
||||
inventory_image = "hades_movement_jump_dampener.png",
|
||||
groups = { equipment = 1, disable_repair = 1 },
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "hades_movement:jump_dampener",
|
||||
recipe = {
|
||||
{"group:wool","","group:wool"},
|
||||
{"hades_core:tin_ingot","","hades_core:tin_ingot"},
|
||||
},
|
||||
})
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
name = hades_movement
|
||||
description = Press Aux1 to change jump strength.
|
||||
depends = playerphysics
|
||||
depends = playerphysics, hades_equipment
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 478 B |
|
@ -14,6 +14,12 @@ hades_seasons.SEASON_SPRING = 0
|
|||
hades_seasons.SEASON_SUMMER = 1
|
||||
hades_seasons.SEASON_FALL = 2
|
||||
|
||||
hades_seasons.SEASON_IDS = {
|
||||
hades_seasons.SEASON_SPRING,
|
||||
hades_seasons.SEASON_SUMMER,
|
||||
hades_seasons.SEASON_FALL,
|
||||
}
|
||||
|
||||
hades_seasons.SEASON_NAMES = {
|
||||
[hades_seasons.SEASON_SPRING] = S("Spring"),
|
||||
[hades_seasons.SEASON_SUMMER] = S("Summer"),
|
||||
|
|
|
@ -28,100 +28,101 @@ function orienteering.toggle_time_mode(itemstack, user, pointed_thing)
|
|||
end
|
||||
|
||||
local use = S("Put this tool in your hotbar to see the data it provides.")
|
||||
local use_tt = S("Put in Equipment or hotbar slot to activate")
|
||||
local use_time = S("Put this tool in your hotbar to make use of its functionality. Leftclick to toggle between 24-hour and 12-hour display for the time feature.")
|
||||
|
||||
-- Displays height (Y)
|
||||
minetest.register_tool("orienteering:altimeter", {
|
||||
description = S("Altimeter"),
|
||||
_tt_help = S("Shows your elevation"),
|
||||
_tt_help = S("Shows your elevation").."\n"..use_tt,
|
||||
_doc_items_longdesc = S("It shows you your current elevation (Y)."),
|
||||
_doc_items_usagehelp = use,
|
||||
wield_image = "orienteering_altimeter.png",
|
||||
inventory_image = "orienteering_altimeter.png",
|
||||
groups = { disable_repair = 1 },
|
||||
groups = { equipment = 1, disable_repair = 1 },
|
||||
})
|
||||
|
||||
-- Displays X and Z coordinates
|
||||
minetest.register_tool("orienteering:triangulator", {
|
||||
description = S("Triangulator"),
|
||||
_tt_help = S("Shows your horizontal coordinates"),
|
||||
_tt_help = S("Shows your horizontal coordinates").."\n"..use_tt,
|
||||
_doc_items_longdesc = S("It shows you the coordinates of your current position in the horizontal plane (X and Z)."),
|
||||
_doc_items_usagehelp = use,
|
||||
wield_image = "orienteering_triangulator.png",
|
||||
inventory_image = "orienteering_triangulator.png",
|
||||
groups = { disable_repair = 1 },
|
||||
groups = { equipment = 1, disable_repair = 1 },
|
||||
})
|
||||
|
||||
-- Displays player yaw
|
||||
-- TODO: calculate yaw difference between 2 points
|
||||
minetest.register_tool("orienteering:compass", {
|
||||
description = S("Compass"),
|
||||
_tt_help = S("Shows the cardinal direction you're looking at"),
|
||||
_tt_help = S("Shows the cardinal direction you're looking at").."\n"..use_tt,
|
||||
_doc_items_longdesc = S("It shows where you're looking: North, East, South or West."),
|
||||
_doc_items_usagehelp = use,
|
||||
wield_image = "orienteering_compass_wield.png",
|
||||
inventory_image = "orienteering_compass_inv.png",
|
||||
groups = { disable_repair = 1 },
|
||||
groups = { equipment = 1, disable_repair = 1 },
|
||||
})
|
||||
|
||||
-- Ultimate orienteering tool: Displays X,Y,Z, yaw, pitch, time, speed and enables the minimap
|
||||
minetest.register_tool("orienteering:quadcorder", {
|
||||
description = S("Quadcorder"),
|
||||
_tt_help = S("Shows your coordinates, cardinal direction, pitch, time, speed and enables minimap"),
|
||||
_tt_help = S("Shows your coordinates, cardinal direction, pitch, time, speed and enables minimap").."\n"..use_tt,
|
||||
_doc_items_longdesc = S("This is the ultimate orientieering tool. It shows you your coordinates (X, Y and Z), shows the cardinal direction, the current time, your current speed and it enables you to access the minimap."),
|
||||
wield_image = "orienteering_quadcorder.png",
|
||||
_doc_items_usagehelp = use_time,
|
||||
wield_scale = { x=1, y=1, z=3.5 },
|
||||
inventory_image = "orienteering_quadcorder.png",
|
||||
groups = { disable_repair = 1 },
|
||||
groups = { equipment = 1, disable_repair = 1 },
|
||||
on_use = orienteering.toggle_time_mode,
|
||||
})
|
||||
|
||||
-- Displays game time
|
||||
minetest.register_tool("orienteering:watch", {
|
||||
description = S("Watch"),
|
||||
_tt_help = S("Shows the time"),
|
||||
_tt_help = S("Shows the time").."\n"..use_tt,
|
||||
_doc_items_longdesc = S("It shows you the current time."),
|
||||
_doc_items_usagehelp = S("Put the watch in your hotbar to see the time. Leftclick to toggle between the 24-hour and 12-hour display."),
|
||||
wield_image = "orienteering_watch.png",
|
||||
inventory_image = "orienteering_watch.png",
|
||||
groups = { disable_repair = 1 },
|
||||
groups = { equipment = 1, disable_repair = 1 },
|
||||
on_use = orienteering.toggle_time_mode,
|
||||
})
|
||||
|
||||
-- Displays speed
|
||||
minetest.register_tool("orienteering:speedometer", {
|
||||
description = S("Speedometer"),
|
||||
_tt_help = S("Shows your speed"),
|
||||
_tt_help = S("Shows your speed").."\n"..use_tt,
|
||||
_doc_items_longdesc = S("It shows you your current horizontal (“hor.”) and vertical (“ver.”) speed in meters per second, where one meter is the side length of a single cube."),
|
||||
_doc_items_usagehelp = use,
|
||||
wield_image = "orienteering_speedometer_wield.png",
|
||||
inventory_image = "orienteering_speedometer_inv.png",
|
||||
groups = { disable_repair = 1 },
|
||||
groups = { equipment = 1, disable_repair = 1 },
|
||||
})
|
||||
|
||||
-- Enables minimap
|
||||
minetest.register_tool("orienteering:automapper", {
|
||||
description = S("Automapper"),
|
||||
_tt_help = S("Allows using the minimap"),
|
||||
_tt_help = S("Allows using the minimap").."\n"..use_tt,
|
||||
_doc_items_longdesc = S("The automapper automatically creates a map of the area around you and enables you to view a minimap of your surroundings. It also has a built-in radar."),
|
||||
_doc_items_usagehelp = S("If you put an automapper in your hotbar, you will be able to access the minimap. By default the minimap can be opened with [F7]."),
|
||||
wield_image = "orienteering_automapper_wield.png",
|
||||
wield_scale = { x=1, y=1, z=2 },
|
||||
inventory_image = "orienteering_automapper_inv.png",
|
||||
groups = { disable_repair = 1 },
|
||||
groups = { equipment = 1, disable_repair = 1 },
|
||||
})
|
||||
|
||||
-- Displays X,Y,Z coordinates, yaw and game time
|
||||
minetest.register_tool("orienteering:gps", {
|
||||
description = S("GPS device"),
|
||||
_tt_help = S("Shows your coordinates, cardinal direction and the time"),
|
||||
_tt_help = S("Shows your coordinates, cardinal direction and the time").."\n"..use_tt,
|
||||
_doc_items_longdesc = S("The GPS device shows you your coordinates (X, Y and Z), your cardinal direction and the time."),
|
||||
_doc_items_usagehelp = use_time,
|
||||
wield_image = "orienteering_gps_wield.png",
|
||||
wield_scale = { x=1, y=1, z=2 },
|
||||
inventory_image = "orienteering_gps_inv.png",
|
||||
groups = { disable_repair = 1 },
|
||||
groups = { equipment = 1, disable_repair = 1 },
|
||||
on_use = orienteering.toggle_time_mode,
|
||||
})
|
||||
|
||||
|
@ -217,15 +218,7 @@ end
|
|||
|
||||
-- Checks whether a certain orienteering tool is “active” and ready for use
|
||||
function orienteering.tool_active(player, item)
|
||||
-- Requirement: player carries the tool in the hotbar
|
||||
local inv = player:get_inventory()
|
||||
local hotbar = player:hud_get_hotbar_itemcount()
|
||||
for i=1, hotbar do
|
||||
if inv:get_stack("main", i):get_name() == item then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
return hades_equipment.has_equipped(player, item, true)
|
||||
end
|
||||
|
||||
function orienteering.init_hud(player)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name = orienteering
|
||||
description = A collection of tools to help you orient yourselves in the world, such as compass, altimeter, etc.
|
||||
depends = hades_compass
|
||||
depends = hades_compass, hades_equipment
|
||||
optional_depends = hades_core, awards
|
||||
|
|
Loading…
Reference in New Issue