hud updates, need to fix some stuff for git
22
mods/hud/.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
mods/hud/.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
|
@ -1,10 +1,10 @@
|
||||
Minetest mod "Better HUD"
|
||||
=========================
|
||||
version: 1.2
|
||||
Version: 1.3
|
||||
|
||||
License of source code: WTFPL
|
||||
-----------------------------
|
||||
(c) Copyright BlockMen (2013)
|
||||
(c) Copyright BlockMen (2013-2014)
|
||||
|
||||
|
||||
License of textures:
|
||||
@ -46,21 +46,24 @@ This mod adds hunger to the game. You can disable this by setting "HUD_HUNGER_EN
|
||||
|
||||
Currently supported food:
|
||||
- Apples (default)
|
||||
- Bread (default)
|
||||
- Drawves (beer and such)
|
||||
- Mooretrees
|
||||
- Simple mobs
|
||||
- Animalmaterials (mobf modpack)
|
||||
- Fishing
|
||||
- Glooptest
|
||||
- Bread (default)
|
||||
- Bushes
|
||||
- Docfarming
|
||||
- Farming plus
|
||||
- Mtfoods
|
||||
- bushes_classic
|
||||
- mushroom
|
||||
- Dwarves (beer and such)
|
||||
- Docfarming
|
||||
- Fishing
|
||||
- Farming plus
|
||||
- Food
|
||||
- fruit
|
||||
- Glooptest
|
||||
- Mobfcooking
|
||||
- Mooretrees
|
||||
- Mtfoods
|
||||
- mushroom
|
||||
- mush45
|
||||
- Seaplants (sea)
|
||||
- Simple mobs
|
||||
|
||||
Example: 1 apple fills up the hunger bar by 1 bread, 1 bread (from farming) 2 breads in bar.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
0.2 Beta
|
||||
--------
|
||||
- added support of costum config files
|
||||
- added support of custom config files
|
||||
- you can eat max. 50% more than before (although it isnt shown in hunger bar)
|
||||
- you get healed with 8 breads and more (in hunger bar) now
|
||||
- a bread (from farming) == 2 breads in hunger bar
|
||||
@ -54,4 +54,12 @@
|
||||
- Support for bushes_classic foods (plantlife modpack) (by CiaranG)
|
||||
- Add support for mushroom mod food/poison (by CiaranG)
|
||||
- Add support for mods: fruit and mush45
|
||||
- New images for hotbar, smaller armor icons
|
||||
- New images for hotbar, smaller armor icons
|
||||
|
||||
1.3
|
||||
---
|
||||
- New way hunger is saved (all old files in world dirctory can get deleted [e.g. hud_BlockMen_hunger])
|
||||
- Fixed healing (not while drowning, fix after death)
|
||||
- Add support for mods: seaplants[sea] and mobfcooking (by Xanthin)
|
||||
- Tweaked hand image
|
||||
- Player can die caus of starving now
|
||||
|
@ -13,3 +13,5 @@ bushes_classic?
|
||||
mushroom?
|
||||
fruit?
|
||||
mush45?
|
||||
seaplants?
|
||||
mobfcooking?
|
||||
|
@ -1,23 +1,12 @@
|
||||
-- Keep these for backwards compatibility
|
||||
function hud.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
|
||||
hud.set_hunger(player)
|
||||
end
|
||||
|
||||
function hud.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
|
||||
|
||||
hud.get_hunger(player)
|
||||
end
|
||||
|
||||
-- Poison player
|
||||
local function poisenp(tick, time, time_left, player)
|
||||
time_left = time_left + tick
|
||||
if time_left < time then
|
||||
@ -31,12 +20,13 @@ end
|
||||
|
||||
function hud.item_eat(hunger_change, replace_with_item, poisen)
|
||||
return function(itemstack, user, pointed_thing)
|
||||
if itemstack:take_item() ~= nil then
|
||||
local h = tonumber(hud.hunger[user:get_player_name()])
|
||||
if itemstack:take_item() ~= nil and user ~= nil then
|
||||
local name = user:get_player_name()
|
||||
local h = tonumber(hud.hunger[name])
|
||||
h=h+hunger_change
|
||||
if h>30 then h=30 end
|
||||
hud.hunger[user:get_player_name()]=h
|
||||
hud.save_hunger(user)
|
||||
hud.hunger[name]=h
|
||||
hud.set_hunger(user)
|
||||
itemstack:add_item(replace_with_item) -- note: replace_with_item is optional
|
||||
--sound:eat
|
||||
if poisen then
|
||||
@ -54,8 +44,7 @@ local function overwrite(name, hunger_change, replace_with_item, poisen)
|
||||
minetest.registered_items[name] = tab
|
||||
end
|
||||
|
||||
--overwrite("mapgen:apple", 2)
|
||||
|
||||
overwrite("default:apple", 2)
|
||||
if minetest.get_modpath("farming") ~= nil then
|
||||
overwrite("farming:bread", 4)
|
||||
end
|
||||
@ -64,4 +53,165 @@ if minetest.get_modpath("mobs") ~= nil then
|
||||
overwrite("mobs:meat", 6)
|
||||
overwrite("mobs:meat_raw", 3)
|
||||
overwrite("mobs:rat_cooked", 5)
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("moretrees") ~= nil then
|
||||
overwrite("moretrees:coconut_milk", 1)
|
||||
overwrite("moretrees:raw_coconut", 2)
|
||||
overwrite("moretrees:acorn_muffin", 3)
|
||||
overwrite("moretrees:spruce_nuts", 1)
|
||||
overwrite("moretrees:pine_nuts", 1)
|
||||
overwrite("moretrees:fir_nuts", 1)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("dwarves") ~= nil then
|
||||
overwrite("dwarves:beer", 2)
|
||||
overwrite("dwarves:apple_cider", 1)
|
||||
overwrite("dwarves:midus", 2)
|
||||
overwrite("dwarves:tequila", 2)
|
||||
overwrite("dwarves:tequila_with_lime", 2)
|
||||
overwrite("dwarves:sake", 2)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("animalmaterials") ~= nil then
|
||||
overwrite("animalmaterials:milk", 2)
|
||||
overwrite("animalmaterials:meat_raw", 3)
|
||||
overwrite("animalmaterials:meat_pork", 3)
|
||||
overwrite("animalmaterials:meat_beef", 3)
|
||||
overwrite("animalmaterials:meat_chicken", 3)
|
||||
overwrite("animalmaterials:meat_lamb", 3)
|
||||
overwrite("animalmaterials:meat_venison", 3)
|
||||
overwrite("animalmaterials:meat_undead", 3, "", 3)
|
||||
overwrite("animalmaterials:meat_toxic", 3, "", 5)
|
||||
overwrite("animalmaterials:meat_ostrich", 3)
|
||||
overwrite("animalmaterials:fish_bluewhite", 2)
|
||||
overwrite("animalmaterials:fish_clownfish", 2)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("fishing") ~= nil then
|
||||
overwrite("fishing:fish_raw", 2)
|
||||
overwrite("fishing:fish", 4)
|
||||
overwrite("fishing:sushi", 6)
|
||||
overwrite("fishing:shark", 4)
|
||||
overwrite("fishing:shark_cooked", 8)
|
||||
overwrite("fishing:pike", 4)
|
||||
overwrite("fishing:pike_cooked", 8)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("glooptest") ~= nil then
|
||||
overwrite("glooptest:kalite_lump", 1)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("bushes") ~= nil then
|
||||
overwrite("bushes:sugar", 1)
|
||||
overwrite("bushes:strawberry", 2)
|
||||
overwrite("bushes:berry_pie_raw", 3)
|
||||
overwrite("bushes:berry_pie_cooked", 4)
|
||||
overwrite("bushes:basket_pies", 15)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("bushes_classic") then
|
||||
-- bushes_classic mod, as found in the plantlife modpack
|
||||
local berries = {
|
||||
"strawberry",
|
||||
"blackberry",
|
||||
"blueberry",
|
||||
"raspberry",
|
||||
"gooseberry",
|
||||
"mixed_berry"}
|
||||
for _, berry in ipairs(berries) do
|
||||
if berry ~= "mixed_berry" then
|
||||
overwrite("bushes:"..berry, 1)
|
||||
end
|
||||
overwrite("bushes:"..berry.."_pie_raw", 2)
|
||||
overwrite("bushes:"..berry.."_pie_cooked", 5)
|
||||
overwrite("bushes:basket_"..berry, 15)
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mushroom") ~= nil then
|
||||
overwrite("mushroom:brown", 1)
|
||||
overwrite("mushroom:red", 1, "", 3)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("docfarming") ~= nil then
|
||||
overwrite("docfarming:carrot", 2)
|
||||
overwrite("docfarming:cucumber", 2)
|
||||
overwrite("docfarming:corn", 2)
|
||||
overwrite("docfarming:potato", 4)
|
||||
overwrite("docfarming:bakedpotato", 5)
|
||||
overwrite("docfarming:raspberry", 3)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("farming_plus") ~= nil then
|
||||
overwrite("farming_plus:carrot_item", 3)
|
||||
overwrite("farming_plus:banana", 2)
|
||||
overwrite("farming_plus:orange_item", 2)
|
||||
overwrite("farming:pumpkin_bread", 4)
|
||||
overwrite("farming_plus:strawberry_item", 2)
|
||||
overwrite("farming_plus:tomato_item", 2)
|
||||
overwrite("farming_plus:potato_item", 4)
|
||||
overwrite("farming_plus:rhubarb_item", 2)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mtfoods") ~= nil then
|
||||
overwrite("mtfoods:dandelion_milk", 1)
|
||||
overwrite("mtfoods:sugar", 1)
|
||||
overwrite("mtfoods:short_bread", 4)
|
||||
overwrite("mtfoods:cream", 1)
|
||||
overwrite("mtfoods:chocolate", 2)
|
||||
overwrite("mtfoods:cupcake", 2)
|
||||
overwrite("mtfoods:strawberry_shortcake", 2)
|
||||
overwrite("mtfoods:cake", 3)
|
||||
overwrite("mtfoods:chocolate_cake", 3)
|
||||
overwrite("mtfoods:carrot_cake", 3)
|
||||
overwrite("mtfoods:pie_crust", 3)
|
||||
overwrite("mtfoods:apple_pie", 3)
|
||||
overwrite("mtfoods:rhubarb_pie", 2)
|
||||
overwrite("mtfoods:banana_pie", 3)
|
||||
overwrite("mtfoods:pumpkin_pie", 3)
|
||||
overwrite("mtfoods:cookies", 2)
|
||||
overwrite("mtfoods:mlt_burger", 5)
|
||||
overwrite("mtfoods:potato_slices", 2)
|
||||
overwrite("mtfoods:potato_chips", 3)
|
||||
--mtfoods:medicine
|
||||
overwrite("mtfoods:casserole", 3)
|
||||
overwrite("mtfoods:glass_flute", 2)
|
||||
overwrite("mtfoods:orange_juice", 2)
|
||||
overwrite("mtfoods:apple_juice", 2)
|
||||
overwrite("mtfoods:apple_cider", 2)
|
||||
overwrite("mtfoods:cider_rack", 2)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("fruit") ~= nil then
|
||||
overwrite("fruit:apple", 2)
|
||||
overwrite("fruit:pear", 2)
|
||||
overwrite("fruit:bananna", 3)
|
||||
overwrite("fruit:orange", 2)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mush45") ~= nil then
|
||||
overwrite("mush45:meal", 4)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("seaplants") ~= nil then
|
||||
overwrite("seaplants:kelpgreen", 1)
|
||||
overwrite("seaplants:kelpbrown", 1)
|
||||
overwrite("seaplants:seagrassgreen", 1)
|
||||
overwrite("seaplants:seagrassred", 1)
|
||||
overwrite("seaplants:seasaladmix", 6)
|
||||
overwrite("seaplants:kelpgreensalad", 1)
|
||||
overwrite("seaplants:kelpbrownsalad", 1)
|
||||
overwrite("seaplants:seagrassgreensalad", 1)
|
||||
overwrite("seaplants:seagrassgreensalad", 1)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mobfcooking") ~= nil then
|
||||
overwrite("mobfcooking:cooked_pork", 6)
|
||||
overwrite("mobfcooking:cooked_ostrich", 6)
|
||||
overwrite("mobfcooking:cooked_beef", 6)
|
||||
overwrite("mobfcooking:cooked_chicken", 6)
|
||||
overwrite("mobfcooking:cooked_lamb", 6)
|
||||
overwrite("mobfcooking:cooked_venison", 6)
|
||||
overwrite("mobfcooking:cooked_fish", 6)
|
||||
end
|
||||
|
@ -15,14 +15,8 @@ local air_hud = {}
|
||||
local armor_hud = {}
|
||||
local armor_hud_bg = {}
|
||||
|
||||
local SAVE_INTERVAL = 0.5*60--currently useless
|
||||
|
||||
--default settings
|
||||
HUD_ENABLE_HUNGER = minetest.setting_getbool("hud_hunger_enable")
|
||||
HUD_SHOW_ARMOR = false
|
||||
if minetest.get_modpath("3d_armor") ~= nil then HUD_SHOW_ARMOR = true end
|
||||
if HUD_ENABLE_HUNGER == nil then HUD_ENABLE_HUNGER = minetest.setting_getbool("enable_damage") end
|
||||
HUD_HUNGER_TICK = 300
|
||||
-- default settings
|
||||
-- statbar positions
|
||||
HUD_HEALTH_POS = {x=0.5,y=0.9}
|
||||
HUD_HEALTH_OFFSET = {x=-175, y=2}
|
||||
HUD_HUNGER_POS = {x=0.5,y=0.9}
|
||||
@ -32,7 +26,20 @@ HUD_AIR_OFFSET = {x=15,y=-15}
|
||||
HUD_ARMOR_POS = {x=0.5,y=0.9}
|
||||
HUD_ARMOR_OFFSET = {x=-175, y=-15}
|
||||
|
||||
--load costum settings
|
||||
HUD_TICK = 0.2
|
||||
HUD_HUNGER_TICK = 300
|
||||
|
||||
HUD_ENABLE_HUNGER = minetest.setting_getbool("hud_hunger_enable")
|
||||
if HUD_ENABLE_HUNGER == nil then
|
||||
HUD_ENABLE_HUNGER = minetest.setting_getbool("enable_damage")
|
||||
end
|
||||
|
||||
HUD_SHOW_ARMOR = false
|
||||
if minetest.get_modpath("3d_armor") ~= nil then
|
||||
HUD_SHOW_ARMOR = true
|
||||
end
|
||||
|
||||
--load custom settings
|
||||
local set = io.open(minetest.get_modpath("hud").."/hud.conf", "r")
|
||||
if set then
|
||||
dofile(minetest.get_modpath("hud").."/hud.conf")
|
||||
@ -43,17 +50,15 @@ else
|
||||
end
|
||||
end
|
||||
|
||||
--minetest.after(SAVE_INTERVAL, timer, SAVE_INTERVAL)
|
||||
|
||||
local function hide_builtin(player)
|
||||
player:hud_set_flags({crosshair = true, hotbar = true, healthbar = false, wielditem = true, breathbar = false})
|
||||
end
|
||||
|
||||
|
||||
local function costum_hud(player)
|
||||
local function custom_hud(player)
|
||||
local name = player:get_player_name()
|
||||
|
||||
--fancy hotbar
|
||||
-- fancy hotbar (only when no crafting mod present)
|
||||
if minetest.get_modpath("crafting") == nil then
|
||||
player:hud_set_hotbar_image("hud_hotbar.png")
|
||||
player:hud_set_hotbar_selected_image("hud_hotbar_selected.png")
|
||||
@ -71,13 +76,14 @@ local function costum_hud(player)
|
||||
alignment = {x=-1,y=-1},
|
||||
offset = HUD_HUNGER_OFFSET,
|
||||
})
|
||||
|
||||
local h = hud.hunger[name]
|
||||
if h == nil or h > 20 then h = 20 end
|
||||
hunger_hud[name] = player:hud_add({
|
||||
hud_elem_type = "statbar",
|
||||
position = HUD_HUNGER_POS,
|
||||
scale = {x=1, y=1},
|
||||
text = "hud_hunger_fg.png",
|
||||
number = 20,
|
||||
number = h,
|
||||
alignment = {x=-1,y=-1},
|
||||
offset = HUD_HUNGER_OFFSET,
|
||||
})
|
||||
@ -92,7 +98,6 @@ local function costum_hud(player)
|
||||
alignment = {x=-1,y=-1},
|
||||
offset = HUD_HEALTH_OFFSET,
|
||||
})
|
||||
|
||||
health_hud[name] = player:hud_add({
|
||||
hud_elem_type = "statbar",
|
||||
position = HUD_HEALTH_POS,
|
||||
@ -125,7 +130,6 @@ local function costum_hud(player)
|
||||
alignment = {x=-1,y=-1},
|
||||
offset = HUD_ARMOR_OFFSET,
|
||||
})
|
||||
|
||||
armor_hud[name] = player:hud_add({
|
||||
hud_elem_type = "statbar",
|
||||
position = HUD_ARMOR_POS,
|
||||
@ -137,7 +141,6 @@ local function costum_hud(player)
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--needs to be defined for older version of 3darmor
|
||||
@ -174,6 +177,7 @@ local function update_hud(player)
|
||||
if arm_out ~= arm then
|
||||
hud.armor_out[name] = arm
|
||||
player:hud_change(armor_hud[name], "number", arm)
|
||||
-- hide armor bar completely when there is none
|
||||
if (not armor.def[name].count or armor.def[name].count == 0) and arm == 0 then
|
||||
player:hud_change(armor_hud_bg[name], "number", 0)
|
||||
else
|
||||
@ -191,46 +195,73 @@ local function update_hud(player)
|
||||
end
|
||||
end
|
||||
|
||||
local function timer(interval, player)
|
||||
if interval > 0 then
|
||||
hud.save_hunger(player)
|
||||
minetest.after(interval, timer, interval, player)
|
||||
hud.get_hunger = function(player)
|
||||
local inv = player:get_inventory()
|
||||
if not inv then return nil end
|
||||
local hgp = inv:get_stack("hunger", 1):get_count()
|
||||
if hgp == 0 then
|
||||
hgp = 21
|
||||
inv:set_stack("hunger", 1, ItemStack({name=":", count=hgp}))
|
||||
else
|
||||
hgp = hgp
|
||||
end
|
||||
return hgp-1
|
||||
end
|
||||
|
||||
hud.set_hunger = function(player)
|
||||
local inv = player:get_inventory()
|
||||
local name = player:get_player_name()
|
||||
local value = hud.hunger[name]
|
||||
if not inv or not value then return nil end
|
||||
if value > 30 then value = 30 end
|
||||
if value < 0 then value = 0 end
|
||||
|
||||
inv:set_stack("hunger", 1, ItemStack({name=":", count=value+1}))
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local inv = player:get_inventory()
|
||||
inv:set_size("hunger",1)
|
||||
hud.health[name] = player:get_hp()
|
||||
local air = player:get_breath()
|
||||
hud.air[name] = air
|
||||
if HUD_ENABLE_HUNGER then hud.hunger[name] = hud.load_hunger(player) end
|
||||
if not hud.hunger[name] then
|
||||
hud.hunger[name] = 20
|
||||
if HUD_ENABLE_HUNGER then
|
||||
hud.hunger[name] = hud.get_hunger(player)
|
||||
hud.hunger_out[name] = hud.hunger[name]
|
||||
end
|
||||
hud.hunger_out[name] = hud.hunger[name]
|
||||
hud.armor[name] = 0
|
||||
hud.armor_out[name] = 0
|
||||
local air = player:get_breath()
|
||||
hud.air[name] = air
|
||||
minetest.after(0.5, function()
|
||||
hide_builtin(player)
|
||||
costum_hud(player)
|
||||
if HUD_ENABLE_HUNGER then hud.save_hunger(player) end
|
||||
custom_hud(player)
|
||||
if HUD_ENABLE_HUNGER then hud.set_hunger(player) end
|
||||
end)
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
-- reset player breath since the engine doesnt
|
||||
player:set_breath(11)
|
||||
-- reset hunger (and save)
|
||||
hud.hunger[player:get_player_name()] = 20
|
||||
minetest.after(0.5, function()
|
||||
if HUD_ENABLE_HUNGER then hud.save_hunger(player) end
|
||||
end)
|
||||
if HUD_ENABLE_HUNGER then
|
||||
minetest.after(0.5, hud.set_hunger, player)
|
||||
end
|
||||
end)
|
||||
|
||||
local main_timer = 0
|
||||
local timer = 0
|
||||
local timer2 = 0
|
||||
minetest.after(2.5, function()
|
||||
minetest.register_globalstep(function(dtime)
|
||||
main_timer = main_timer + dtime
|
||||
timer = timer + dtime
|
||||
timer2 = timer2 + dtime
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
if main_timer > HUD_TICK or timer > 4 or timer2 > HUD_HUNGER_TICK then
|
||||
if main_timer > HUD_TICK then main_timer = 0 end
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- only proceed if damage is enabled
|
||||
@ -239,19 +270,19 @@ minetest.after(2.5, function()
|
||||
local hp = player:get_hp()
|
||||
if HUD_ENABLE_HUNGER and timer > 4 then
|
||||
-- heal player by 1 hp if not dead and saturation is > 15 (of 30)
|
||||
if h > 15 and hp > 0 then
|
||||
if h > 15 and hp > 0 and hud.air[name] > 0 then
|
||||
player:set_hp(hp+1)
|
||||
-- or damage player by 1 hp if saturation is < 2 (of 30) and player would not die
|
||||
-- or damage player by 1 hp if saturation is < 2 (of 30)
|
||||
elseif h <= 1 and minetest.setting_getbool("enable_damage") then
|
||||
if hp-1 >= 1 then player:set_hp(hp-1) end
|
||||
if hp-1 >= 0 then player:set_hp(hp-1) end
|
||||
end
|
||||
end
|
||||
-- lower saturation by 1 point after xx seconds
|
||||
if HUD_ENABLE_HUNGER and timer2 > HUD_HUNGER_TICK then
|
||||
if h > 1 then
|
||||
if h > 0 then
|
||||
h = h-1
|
||||
hud.hunger[name] = h
|
||||
hud.save_hunger(player)
|
||||
hud.set_hunger(player)
|
||||
end
|
||||
end
|
||||
-- update current armor level
|
||||
@ -260,8 +291,9 @@ minetest.after(2.5, function()
|
||||
-- update all hud elements
|
||||
update_hud(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
if timer > 4 then timer = 0 end
|
||||
if timer2 > HUD_HUNGER_TICK then timer2 = 0 end
|
||||
end)
|
||||
|
Before Width: | Height: | Size: 512 B After Width: | Height: | Size: 374 B |
Before Width: | Height: | Size: 424 B After Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 507 B |
Before Width: | Height: | Size: 302 B After Width: | Height: | Size: 549 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 488 B |
Before Width: | Height: | Size: 417 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 522 B After Width: | Height: | Size: 2.9 KiB |
BIN
mods/hud/textures/hud_over.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
mods/hud/textures/hud_over2.png
Normal file
After Width: | Height: | Size: 8.8 KiB |
42
mods/throwing/quad_arrow.lua
Normal file
@ -0,0 +1,42 @@
|
||||
--quadarrow.lua
|
||||
|
||||
minetest.register_craftitem("throwing:quad_arrow", {
|
||||
description = "Arrow",
|
||||
inventory_image = "throwing_quad_arrow.png",
|
||||
})
|
||||
|
||||
minetest.register_node("throwing:quad_arrow_box", {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
-- Shaft
|
||||
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
|
||||
-- Spitze
|
||||
{-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
|
||||
{-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
|
||||
-- Federn
|
||||
{6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
|
||||
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
|
||||
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
|
||||
{6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
|
||||
|
||||
{7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
|
||||
{8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
|
||||
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
|
||||
{7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
|
||||
}
|
||||
},
|
||||
tiles = {"throwing_arrow.png", "throwing_arrow.png", "throwing_arrow_back.png", "throwing_arrow_front.png", "throwing_arrow_2.png", "throwing_arrow.png"},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
local THROWING_ARROW_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x=0.1, y=0.1},
|
||||
textures = {"throwing:arrow_box"},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
}
|