Feature: no stamina? drink a coffee! (#5) Farming mod support.

* Create init.coffee.lua
* Update init.lua
* Update depends.txt
* Update README.md
master
rusty-snake 2020-09-01 16:05:07 +00:00 committed by GitHub
parent 23f713d59e
commit dcae463550
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 3 deletions

View File

@ -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.
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.

View File

@ -1,3 +1,4 @@
hud?
hudbars?
player_monoids?
player_monoids?
farming?

14
init.coffee.lua Normal file
View File

@ -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

View File

@ -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)
end)