From d0fe2a33a2c9d7f787a2fa30cc723e9a93e0fc63 Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Sat, 12 Aug 2017 07:18:18 -0700 Subject: [PATCH 1/3] Change stamina icon textures: - License: CC0 - Based on 'Running man icon' by manio1: https://openclipart.org/detail/254287 --- README.md | 9 ++++++++- textures/sprint_stamina_bgicon.png | Bin 91 -> 171 bytes textures/sprint_stamina_icon.png | Bin 180 -> 245 bytes 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e2b912a..c080bd7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ # hbSprint -License: LGPLv2.1/CC BY-SA 3.0. Particle code: copyright (c) 2017 Elijah Duffy. ## Description A flexible sprint mod supporting stamina, hunger and coexistance with other physics altering mods. +## Licensing +- LGPLv2.1/CC BY-SA 3.0. Particle code: copyright (c) 2017 Elijah Duffy. +- sprint_stamina_\*icon textures: + - CC0 + - Created by Jordan Irwin (AntumDeluge) + - Based on [Running man icon by manio1](https://openclipart.org/detail/254287) + ## Notes hbSprint can be played with Minetest 0.4.16 or above. It has no dependencies, but it supports on [hudbars](http://repo.or.cz/w/minetest_hudbars.git), [hbhunger](http://repo.or.cz/w/minetest_hbhunger.git) and [player_monoids](https://github.com/minetest-mods/player_monoids). @@ -18,6 +24,7 @@ It has no dependencies, but it supports on [hudbars](http://repo.or.cz/w/minetes - Particle spawning based on ground type (Thanks to [octacian](https://github.com/octacian/sprint/)) - All variables customizable in Advanced settings or directly in minetest.conf + ## Known issues - Forward double tap support not implemented diff --git a/textures/sprint_stamina_bgicon.png b/textures/sprint_stamina_bgicon.png index baade32543b44c47357c0aa17e228110e10fbe96..8e56295150d6e03b4b3d21c6b6143eba5fe7d2e2 100644 GIT binary patch delta 142 zcma!E%{W1&p0mIsvY3H^_c{nOI%&+VU|?WiFY)wsWq-)Q!^gz5_sotcppciRi(`n! z`KkVnTnq*rt6n^`t8G8nQRFJ8_ZNZB_X- t=|Pb9v!h3w=ebo_DRGC#n>h0Fb!YQRe->}F0-DOe;pyt@_hGa&!~ delta 61 zcmZ3@7(GG7T*=eLF{FYqSwYr>K~a)RVA2z<1u^Dj9svg(ezhE`P!MHc`20bEvE|4d QZ3ZClboFyt=akR{07+pJtN;K2 diff --git a/textures/sprint_stamina_icon.png b/textures/sprint_stamina_icon.png index f37fd30062bd2b1d5fade0f41c1ec35cc333d3e7..89fce3b041235d9540e412a768c4e7a1b62489c3 100644 GIT binary patch delta 229 zcmdnO_?2;jL_G^L0|Ud`yN`l^ltF+`h-*CqgHpGs+GGih>5>|=BsFJC>a379TBm5a zQNwDhro(0fr!B^=Tg^PSTY7G{^4@3tNB!JepkBt3AirP+hi5m^fE>;OkH}&M2Hxu+ z%;=;sy8!L2+zn_hgQu&X%Q~loCIBT5OBetE delta 164 zcmV;V09*g{0ki>-7=H)`0000V^Z#K0004VQL_t(|+P%!r3P3;*$8nEgIk~XpAWD&g zl;Zg)MJYEYjP^h=^T&AlrOE z$;wH%Sj3-A;!Or|$H)J`+v7b0PfW# From 92c22ef76d3507ef6634339ad1f7e9acc8985208 Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Sat, 12 Aug 2017 07:38:28 -0700 Subject: [PATCH 2/3] Fix undeclared global variable 'player' warning --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 96ed0f4..b532f6a 100644 --- a/init.lua +++ b/init.lua @@ -124,7 +124,7 @@ if minetest.get_modpath("hudbars") ~= nil and stamina then player_stamina, player_stamina, false, "%s: %.1f/%.1f") hudbars = true - hb.hide_hudbar(player, "stamina") + hb.hide_hudbar(nil, "stamina") end minetest.register_on_joinplayer(function(player) From e48bcbd411474308f4a5a5a84445f51a1451e7d7 Mon Sep 17 00:00:00 2001 From: tacotexmex Date: Thu, 24 Aug 2017 08:01:33 +0200 Subject: [PATCH 3/3] Fix multiplayer bug, supposedly --- init.lua | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/init.lua b/init.lua index 96ed0f4..2e93711 100644 --- a/init.lua +++ b/init.lua @@ -19,10 +19,8 @@ if breath ~= false then breath = true end local sprint_timer_step = 0.5 local sprint_timer = 0 -local player_stamina = 20 local stamina_timer = 0 local breath_timer = 0 -local sprinting = false local hudbars = false local starve = false local monoids = false @@ -34,7 +32,7 @@ if minetest.get_modpath("player_monoids") ~= nil then monoids = true else monoid -- Functions local function start_sprint(player) - if not sprinting then + if player:get_attribute("sprinting") == "false" then if monoids then player_monoids.speed:add_change(player, speed, "hbsprint:speed") player_monoids.jump:add_change(player, jump, "hbsprint:jump") @@ -45,7 +43,7 @@ local function start_sprint(player) end local function stop_sprint(player) - if sprinting then + if player:get_attribute("sprinting") == "true" then if monoids then player_monoids.speed:del_change(player, "hbsprint:speed") player_monoids.jump:del_change(player, "hbsprint:jump") @@ -56,7 +54,7 @@ local function stop_sprint(player) end local function drain_stamina(player) - player_stamina = tonumber(player:get_attribute("stamina")) + local player_stamina = tonumber(player:get_attribute("stamina")) if player_stamina > 0 then player:set_attribute("stamina", player_stamina - stamina_drain) end @@ -67,7 +65,7 @@ local function drain_stamina(player) end local function replenish_stamina(player) - player_stamina = tonumber(player:get_attribute("stamina")) + local player_stamina = tonumber(player:get_attribute("stamina")) if player_stamina < 20 then player:set_attribute("stamina", player_stamina + stamina_drain) end @@ -121,7 +119,7 @@ if minetest.get_modpath("hudbars") ~= nil and stamina then 0xFFFFFF, "Stamina", { bar = "sprint_stamina_bar.png", icon = "sprint_stamina_icon.png", bgicon = "sprint_stamina_bgicon.png" }, - player_stamina, player_stamina, + 20, 20, false, "%s: %.1f/%.1f") hudbars = true hb.hide_hudbar(player, "stamina") @@ -158,6 +156,7 @@ minetest.register_globalstep(function(dtime) local pos = player:get_pos() local ground = minetest.get_node_or_nil({x=pos.x, y=pos.y-1, z=pos.z}) local walkable = false + local player_stamina = tonumber(player:get_attribute("stamina")) if starve then hunger = tonumber(hbhunger.hunger[name]) end @@ -166,7 +165,7 @@ minetest.register_globalstep(function(dtime) end if player_stamina > 0 and hunger > 9 and walkable then start_sprint(player) - sprinting = true + player:set_attribute("sprinting", "true") if stamina then drain_stamina(player) end if starve then drain_hunger(player, hunger, name) end if breath then @@ -178,11 +177,11 @@ minetest.register_globalstep(function(dtime) if particles then create_particles(player, name, pos, ground) end else stop_sprint(player) - sprinting = false + player:set_attribute("sprinting", "false") end else stop_sprint(player) - sprinting = false + player:set_attribute("sprinting", "false") if stamina_timer >= replenish then if stamina then replenish_stamina(player) end stamina_timer = 0