Initial commit

This commit is contained in:
BlockMen 2013-06-28 22:58:06 +02:00
commit d3e8f7134a
14 changed files with 479 additions and 0 deletions

22
.gitattributes vendored Normal file

@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

215
.gitignore vendored Normal file

@ -0,0 +1,215 @@
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg

37
README.txt Normal file

@ -0,0 +1,37 @@
Minetest mod "Better HUD"
=========================
version: 0.1 Beta
License of source code: WTFPL
-----------------------------
- "Disable Drowning" [no_drowning], PilzAdam
everything else:
(c) Copyright BlockMen (2013)
License of textures:
--------------------
hud_heart_fg.png - celeron55 (CC BY-SA 3.0), modified by BlockMen
hud_heart_bg.png - celeron55 (CC BY-SA 3.0), modified by BlockMen
hud_hunger_fg.png - PilzAdam(WTFPL), modified by BlockMen
hud_hunger_bg.png - PilzAdam(WTFPL), modified by BlockMen
wieldhand.png (from character.png) - Jordach (CC BY-SA 3.0), modified by BlockMen
everything else is WTFPL:
(c) Copyright BlockMen (2013)
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://sam.zoy.org/wtfpl/COPYING for more details.
Using the mod:
--------------
This mod changes the HUD of Minetest. It adds a costum crosshair, a improved health bar.
Also it adds hunger to the game and and hunger bar to the HUD.
Furthermore it disables the current way of drowning (credits go to PilzAdam) and it will have an LUA-based drowing next versions.

1
depends.txt Normal file

@ -0,0 +1 @@
default

34
hunger.lua Normal file

@ -0,0 +1,34 @@
function hud.item_eat(hunger_change, replace_with_item)
return function(itemstack, user, pointed_thing)
if itemstack:take_item() ~= nil then
local h = tonumber(hud.hunger[user:get_player_name()])
h=h+hunger_change
if h>20 then h=20 end
hud.hunger[user:get_player_name()]=h
itemstack:add_item(replace_with_item) -- note: replace_with_item is optional
--sound:eat
end
return itemstack
end
end
local function overwrite(name, hunger_change, as_node)
local tab = minetest.registered_items[name]
if tab == nil then return end
local tab2 = {}
for i,v in pairs(tab) do
tab2[i] = v
end
tab2.on_use = hud.item_eat(hunger_change)
if as_node then
minetest.register_node(":"..name, tab2)
else
minetest.register_craftitem(":"..name, tab2)
end
end
overwrite("default:apple", 2, true)
if minetest.get_modpath("farming") ~= nil then
overwrite("farming:bread", 6, false)
end

155
init.lua Normal file

@ -0,0 +1,155 @@
hud = {}
local health_hud = {}
hud.hunger = {}
local hunger_hud = {}
hud.air = {}
local air_hud = {}
local SAVE_INTERVAL = 0.5*60--currently useless
local ENABLE_HUNGER = minetest.setting_getbool("enable_damage") -- set to false if no hunger wanted
local NO_HUNGER_TIME = 300 --=5min (so 1h playing == hunger)
--minetest.after(SAVE_INTERVAL, timer, SAVE_INTERVAL)
local function hide_builtin(player)
player:hud_set_flags({crosshair = false, hotbar = true, healthbar = false, wielditem = true, breathbar = false})
end
local function costum_hud(player)
--crosshair
player:hud_add({
hud_elem_type = "image",
text = "hud_cross.png",
position = {x=0.5, y=0.5},
scale = {x=1, y=1},
})
if minetest.setting_getbool("enable_damage") then
--hunger
player:hud_add({
hud_elem_type = "statbar",
position = {x=0.5,y=1},
scale = {x=1, y=1},
text = "hud_hunger_bg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = {x=15,y=-60},
})
hunger_hud[player:get_player_name()] = player:hud_add({
hud_elem_type = "statbar",
position = {x=0.5,y=1},
scale = {x=1, y=1},
text = "hud_hunger_fg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = {x=15,y=-60},
})
--health
player:hud_add({
hud_elem_type = "statbar",
position = {x=0.5,y=1},
scale = {x=1, y=1},
text = "hud_heart_bg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = {x=-175,y=-60},
})
health_hud[player:get_player_name()] = player:hud_add({
hud_elem_type = "statbar",
position = {x=0.5,y=1},
scale = {x=1, y=1},
text = "hud_heart_fg.png",
number = player:get_hp(),
alignment = {x=-1,y=-1},
offset = {x=-175,y=-60},
})
end
end
local function update_hud(player)
--health
player:hud_change(health_hud[player:get_player_name()], "number", player:get_hp())
--hunger
player:hud_change(hunger_hud[player:get_player_name()], "number", hud.hunger[player:get_player_name()])
end
local function save_hunger(player)
local file = io.open(minetest.get_worldpath().."/hud_"..player:get_player_name().."_hunger", "w+")
if file then
file:write(hud.hunger[player:get_player_name()])
file:close()
end
end
local function timer(interval, player)
if interval > 0 then
save_hunger(player)
minetest.after(interval, timer, interval, player)
end
end
local function load_hunger(player)
local file = io.open(minetest.get_worldpath().."/hud_"..player:get_player_name().."_hunger", "r")
if file then
hud.hunger[player:get_player_name()] = file:read("*all")
file:close()
return hud.hunger[player:get_player_name()]
else
return
end
end
minetest.register_on_joinplayer(function(player)
hud.hunger[player:get_player_name()] = load_hunger(player)
if hud.hunger[player:get_player_name()] == nil then
hud.hunger[player:get_player_name()] = 20
end
minetest.after(0.5, function()
save_hunger(player)
hide_builtin(player)
costum_hud(player)
end)
end)
local timer = 0
local timer2 = 0
minetest.after(2.5, function()
if minetest.setting_getbool("enable_damage") then
minetest.register_globalstep(function(dtime)
timer = timer + dtime
timer2 = timer2 + dtime
for _,player in ipairs(minetest.get_connected_players()) do
local h = tonumber(hud.hunger[player:get_player_name()])
if ENABLE_HUNGER and timer > 4 then
if h>=18 then
player:set_hp(player:get_hp()+1)
elseif h==1 and minetest.setting_getbool("enable_damage") then
if player:get_hp()-1 >= 1 then player:set_hp(player:get_hp()-1) end
end
end
if ENABLE_HUNGER and timer2>NO_HUNGER_TIME then
--local h = tonumber(hunger[player:get_player_name()])
if h>1 then
h=h-1
hud.hunger[player:get_player_name()]=h
save_hunger(player)
end
end
update_hud(player)
end
if timer>4 then timer=0 end
if timer2>NO_HUNGER_TIME then timer2=0 end
end)
end
end)
if ENABLE_HUNGER then dofile(minetest.get_modpath("hud").."/hunger.lua") end
dofile(minetest.get_modpath("hud").."/no_drowning.lua")

15
no_drowning.lua Normal file

@ -0,0 +1,15 @@
local function drwn_overwrite(name)
local table = minetest.registered_nodes[name]
local table2 = {}
for i,v in pairs(table) do
table2[i] = v
end
table2.drowning = false
table2.hud_drowning = true
minetest.register_node(":"..name, table2)
end
drwn_overwrite("default:water_source")
drwn_overwrite("default:water_flowing")
drwn_overwrite("default:lava_source")
drwn_overwrite("default:lava_flowing")

BIN
textures/hud_cross.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

BIN
textures/hud_heart_bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

BIN
textures/hud_heart_fg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

BIN
textures/hud_hunger_bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

BIN
textures/hud_hunger_fg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

BIN
textures/hud_inv_border.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

BIN
textures/wieldhand.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B