diff --git a/README.md b/README.md index 62ecd16..c5e18aa 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Minetest mod for sprinting with W, A and D buttons. 1. Press A and D simultaneously to trigger the `ready_to_sprint` state. 2. Then press W to start sprinting. 3. Release A and D (keep W pressed) and continue sprinting until the stamina runs out. +4. Drink a coffee to faster regenerate the stamina. **How to download** @@ -31,6 +32,7 @@ All mod dependencies are optional. - [hud?](https://github.com/BlockMen/hud_hunger) - [hudbars?](http://repo.or.cz/minetest_hudbars.git) - [player_monoids?](https://github.com/minetest-mods/player_monoids) +- [farming?](https://notabug.org/tenplus1/farming) **Dependents** @@ -52,4 +54,4 @@ https://github.com/aa6/minetest_wadsprint/commits/master **Credits** -Thanks to [GunshipPenguin](https://github.com/GunshipPenguin) and his [sprint mod](https://github.com/GunshipPenguin/sprint) for showing a good example of how sprint mod for minetest can be done. \ No newline at end of file +Thanks to [GunshipPenguin](https://github.com/GunshipPenguin) and his [sprint mod](https://github.com/GunshipPenguin/sprint) for showing a good example of how sprint mod for minetest can be done. diff --git a/depends.txt b/depends.txt index a21864a..ba14501 100644 --- a/depends.txt +++ b/depends.txt @@ -1,3 +1,4 @@ hud? hudbars? -player_monoids? \ No newline at end of file +player_monoids? +farming? diff --git a/init.coffee.lua b/init.coffee.lua new file mode 100644 index 0000000..c0b17a5 --- /dev/null +++ b/init.coffee.lua @@ -0,0 +1,14 @@ +if minetest.registered_nodes["farming:coffee_cup"] then + minetest.override_item("farming:coffee_cup", { + on_use = function(itemstack, user, pointed_thing) + if user == nil then return end -- better save then sorry + minetest_wadsprint.api.addstamina(user:get_player_name(), 0.25) + itemstack:take_item() + local leftover = user:get_inventory():add_item("main", "vessels:drinking_glass") + if not leftover:is_empty() then -- no free spot in players inventory + minetest.item_drop(leftover, user, user:get_pos()) + end + return itemstack + end + }) +end diff --git a/init.lua b/init.lua index 5f54a54..835ba40 100755 --- a/init.lua +++ b/init.lua @@ -34,6 +34,7 @@ dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.legacy.lua") dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.config.lua") dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.hudbars.lua") dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.set_sprinting_physics.lua") +dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.coffee.lua") ---------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------ Mod initialization -- ---------------------------------------------------------------------------------------------------- @@ -76,4 +77,4 @@ minetest.register_globalstep(function(seconds_since_last_global_step) -- Called end end -end) \ No newline at end of file +end)