Reorganise game into modpacks

This commit is contained in:
rubenwardy 2019-01-11 15:45:27 +00:00
parent 86a5266bb5
commit b38a89c2fe
762 changed files with 9 additions and 8 deletions

View file

@ -0,0 +1,7 @@
Copyright 2018 by rubenwardy and GunshipPenguin
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,31 @@
# Sprint Mod For minetest
Allows players to sprint by holding E, by default increasing their travel speed
by 80% and their jump speed by 10%. Also adds a stamina bar that goes down when
the player sprints and goes up they're not sprinting.
This mod is compatible with the HUD bars [hudbars] mod, but does not depend on
it. In this case, a green HUD bar will be displayed, also showing a number.
If this mod is not present, a standard statbar with 0-20 “half-arrows” is shown,
which is a bit more coarse than the HUD bar version.
This mod is by rubenwardy, and is based on a mod by GunshipPenguin but heavily
rewritten to be more performant.
License: MIT (see license.txt)
## Settings
1.0 represents normal speed so 1.5 would mean that a sprinting player would
travel 50% faster than a walking player and 2.4 would mean that a sprinting
player would travel 140% faster than a walking player.
* `sprint_speed`- 1 is normal walking speed, defaults to 1.8.
* `sprint_jump` - 1 is normal jump speed, defaults to 1.1.
* `sprint_stamina` - How long the sprint lasts in seconds, defaults to 20.
* `sprint_heal_rate` - Multiply this by the stamina to get how long it takes to recharge, defaults to 0.5.
* `sprint_min` - The minimum value at which you can start sprinting, defaults to 0.5.
## Recharging when the sprint key is down
Follow the instructions in comments marked by `##number##`.

View file

@ -0,0 +1 @@
hudbars?

123
mods/other/sprint/init.lua Normal file
View file

@ -0,0 +1,123 @@
-- Sprint mod by rubenwardy. License: MIT.
-- Heavily modified from a mod by GunshipPenguin
-- Config, see README.md
local MOD_WALK = tonumber(minetest.settings:get("sprint_speed") or 1.8)
local MOD_JUMP = tonumber(minetest.settings:get("sprint_jump") or 1.1)
local STAMINA_MAX = tonumber(minetest.settings:get("sprint_stamina") or 20)
local HEAL_RATE = tonumber(minetest.settings:get("sprint_heal_rate") or 0.5)
local MIN_SPRINT = tonumber(minetest.settings:get("sprint_min") or 0.5)
local SPRINT_MODIFIERS = {
[true] = { speed = MOD_WALK, jump = MOD_JUMP },
[false] = { speed = 1.0, jump = 1.0 },
}
if minetest.get_modpath("hudbars") ~= nil then
hb.register_hudbar("sprint", 0xFFFFFF, "Stamina",
{ bar = "sprint_stamina_bar.png", icon = "sprint_stamina_icon.png" },
STAMINA_MAX, STAMINA_MAX,
false, "%s: %.1f/%.1f")
SPRINT_HUDBARS_USED = true
else
SPRINT_HUDBARS_USED = false
end
local players = {}
local function setSprinting(player, info, sprinting)
if info.sprinting ~= sprinting then
player:set_physics_override(SPRINT_MODIFIERS[sprinting])
end
info.sprinting = sprinting
end
minetest.register_globalstep(function(dtime)
for name, info in pairs(players) do
local player = minetest.get_player_by_name(name)
if not player then
players[name] = nil
else
-- ##?## You can enable recharging when the E key is pressed by
-- following these instructions.
--Check if the player should be sprinting
local controls = player:get_player_control()
local sprintRequested = controls.aux1 and controls.up
-- ##1## replace info.sprintRequested with info.sprinting
if sprintRequested ~= info.sprintRequested then
if sprintRequested and info.stamina > MIN_SPRINT then
setSprinting(player, info, true)
end
if not sprintRequested then
setSprinting(player, info, false)
end
end
info.sprintRequested = sprintRequested
local staminaChanged = false
if info.sprinting then
info.stamina = info.stamina - dtime
staminaChanged = true
if info.stamina <= 0 then
info.stamina = 0
setSprinting(player, info, false)
end
-- ##2## remove `not info.sprintRequested and`
elseif not info.sprintRequested and info.stamina < STAMINA_MAX then
info.stamina = info.stamina + dtime * HEAL_RATE
staminaChanged = true
if info.stamina > STAMINA_MAX then
info.stamina = STAMINA_MAX
end
end
if staminaChanged then
if SPRINT_HUDBARS_USED then
hb.change_hudbar(player, "sprint", info.stamina)
else
local numBars = math.floor(20 * info.stamina / STAMINA_MAX)
if info.lastHudSendValue ~= numBars then
info.lastHudSendValue = numBars
player:hud_change(info.hud, "number", numBars)
print("Sending hud value")
end
end
end
end
end
end)
minetest.register_on_joinplayer(function(player)
local info = {
sprinting = false, -- Is the player actually sprinting?
stamina = STAMINA_MAX, -- integer, the stamina we have left
sprintRequested = false, -- is the sprint key down / etc?
}
if SPRINT_HUDBARS_USED then
hb.init_hudbar(player, "sprint")
else
info.hud = player:hud_add({
hud_elem_type = "statbar",
position = {x=0.5, y=1},
size = {x=24, y=24},
text = "sprint_stamina_icon.png",
number = 20,
alignment = {x=0, y=1},
offset = {x=-263, y=-110},
})
end
players[player:get_player_name()] = info
end)
minetest.register_on_respawnplayer(function(player)
players[player:get_player_name()].stamina = STAMINA_MAX
end)
minetest.register_on_leaveplayer(function(player)
players[player:get_player_name()] = nil
end)

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B