Initial commit.

master
aa6 2016-06-08 21:56:22 +03:00
parent bba00ffae7
commit 1a4aa93e7d
9 changed files with 124 additions and 0 deletions

14
README.md Normal file
View File

@ -0,0 +1,14 @@
# Wadsprint Dyspnea [![Version](/util/version.png)] [minetest_wadsprint_dyspnea]
Mod that adds hard breathing sound below the dyspnea threshold level.
**How to install:**
http://wiki.minetest.com/wiki/Installing_mods
**Dependencies:**
[minetest_wadsprint](https://github.com/aa6/minetest_wadsprint)
**Credits:**
Original breathing sound was taken from https://freesound.org/people/Robinhood76/sounds/95529/

1
VERSION Normal file
View File

@ -0,0 +1 @@
0.0.1

1
depends.txt Normal file
View File

@ -0,0 +1 @@
minetest_wadsprint

19
init.lua Normal file
View File

@ -0,0 +1,19 @@
local sound_handlers = {}
minetest_wadsprint.api.events:on("dyspnea",function(event)
if event.value == true then
sound_handlers[event.player.name] = minetest.sound_play(
{
loop = true,
name = "minetest_wadsprint_dyspnea_hardbreath",
},
{
object = event.player.obj,
}
)
else
if sound_handlers[event.player.name] ~= nil then
minetest.sound_stop(sound_handlers[event.player.name])
end
end
end)

Binary file not shown.

10
util/git_hook_pre_commit.bash Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
# chmod +x .git/hooks/pre-commit
# chmod +x util/git_hook_pre_commit.bash
source util/increment_version.bash
VERSION=`cat VERSION`
VERSION=`increment_version $VERSION`
echo -n $VERSION > VERSION
cat VERSION | convert -background none -density 196 -fill black -pointsize 21 -resample 72 -unsharp 0x.5 text:- -trim +repage -bordercolor white -border 3 util/version.png
git add VERSION
git add util/version.png

79
util/increment_version.bash Executable file
View File

@ -0,0 +1,79 @@
#!/bin/bash
# Accepts a version string and prints it incremented by one.
# Usage: increment_version <version> [<position>] [<leftmost>]
increment_version() {
local usage=" USAGE: $FUNCNAME [-l] [-t] <version> [<position>] [<leftmost>]
-l : remove leading zeros
-t : drop trailing zeros
<version> : The version string.
<position> : Optional. The position (starting with one) of the number
within <version> to increment. If the position does not
exist, it will be created. Defaults to last position.
<leftmost> : The leftmost position that can be incremented. If does not
exist, position will be created. This right-padding will
occur even to right of <position>, unless passed the -t flag."
# Get flags.
local flag_remove_leading_zeros=0
local flag_drop_trailing_zeros=0
while [ "${1:0:1}" == "-" ]; do
if [ "$1" == "--" ]; then shift; break
elif [ "$1" == "-l" ]; then flag_remove_leading_zeros=1
elif [ "$1" == "-t" ]; then flag_drop_trailing_zeros=1
else echo -e "Invalid flag: ${1}\n$usage"; return 1; fi
shift; done
# Get arguments.
if [ ${#@} -lt 1 ]; then echo "$usage"; return 1; fi
local v="${1}" # version string
local targetPos=${2-last} # target position
local minPos=${3-${2-0}} # minimum position
# Split version string into array using its periods.
local IFSbak; IFSbak=IFS; IFS='.' # IFS restored at end of func to
read -ra v <<< "$v" # avoid breaking other scripts.
# Determine target position.
if [ "${targetPos}" == "last" ]; then
if [ "${minPos}" == "last" ]; then minPos=0; fi
targetPos=$((${#v[@]}>${minPos}?${#v[@]}:$minPos)); fi
if [[ ! ${targetPos} -gt 0 ]]; then
echo -e "Invalid position: '$targetPos'\n$usage"; return 1; fi
(( targetPos-- )) || true # offset to match array index
# Make sure minPosition exists.
while [ ${#v[@]} -lt ${minPos} ]; do v+=("0"); done;
# Increment target position.
v[$targetPos]=`printf %0${#v[$targetPos]}d $((${v[$targetPos]}+1))`;
# Remove leading zeros, if -l flag passed.
if [ $flag_remove_leading_zeros == 1 ]; then
for (( pos=0; $pos<${#v[@]}; pos++ )); do
v[$pos]=$((${v[$pos]}*1)); done; fi
# If targetPosition was not at end of array, reset following positions to
# zero (or remove them if -t flag was passed).
if [[ ${flag_drop_trailing_zeros} -eq "1" ]]; then
for (( p=$((${#v[@]}-1)); $p>$targetPos; p-- )); do unset v[$p]; done
else for (( p=$((${#v[@]}-1)); $p>$targetPos; p-- )); do v[$p]=0; done; fi
echo "${v[*]}"
IFS=IFSbak
return 0
}
# EXAMPLE -------------> # RESULT
# increment_version 1 # 2
# increment_version 1 2 # 1.1
# increment_version 1 3 # 1.0.1
# increment_version 1.0.0 # 1.0.1
# increment_version 1.2.3.9 # 1.2.3.10
# increment_version 00.00.001 # 00.00.002
# increment_version -l 00.001 # 0.2
# increment_version 1.1.1.1 2 # 1.2.0.0
# increment_version -t 1.1.1 2 # 1.2
# increment_version v1.1.3 # v1.1.4
# increment_version 1.2.9 2 4 # 1.3.0.0
# increment_version -t 1.2.9 2 4 # 1.3
# increment_version 1.2.9 last 4 # 1.2.9.1

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
util/version.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB