Removed hunger, kept fancy hud, tweaked papyrus growth

This commit is contained in:
DanDuncombe 2013-11-16 18:23:37 +00:00
parent ca40d2536b
commit b9efdfb266
17 changed files with 29 additions and 442 deletions

View File

@ -87,7 +87,7 @@ end
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:papyrus"}, nodenames = {"default:papyrus"},
neighbors = {"default:dirt", "default:dirt_with_grass"}, neighbors = {"default:dirt", "default:dirt_with_grass"},
interval = 50, interval = 100,
chance = 20, chance = 20,
action = function(pos, node) action = function(pos, node)
pos.y = pos.y-1 pos.y = pos.y-1
@ -110,3 +110,30 @@ minetest.register_abm({
end end
end, end,
}) })
--Cactus Growth
minetest.register_abm({
nodenames = {"default:cactus"},
neighbors = {"default:sand", "default:desert_sand"},
interval = 100,
chance = 20,
action = function(pos, node)
pos.y = pos.y-1
local name = minetest.get_node(pos).name
if name == "default:sand" or name == "default:desert_sand" then
pos.y = pos.y+1
local height = 0
while minetest.get_node(pos).name == "default:cactus" and height < 4 do
height = height+1
pos.y = pos.y+1
end
if height < 4 then
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="default:cactus"})
end
end
end
end,
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 B

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

After

Width:  |  Height:  |  Size: 369 B

View File

@ -1,63 +0,0 @@
Minetest mod "Better HUD"
=========================
version: 1.1
License of source code: WTFPL
-----------------------------
(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
hud_air_fg.png - kaeza (WTFPL), modified by BlockMen
hud_armor_fg.png - Stu (CC BY-SA 3.0), modified by BlockMen
hud_armor_bg.png - Stu (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 improves the apperance of the health and breath bar and adds a more fancy hotbar. Furthermore it adds a
costum crosshair, an armor bar (only for 3darmor mod) and a hunger bar. It includes also a mechanic for hunger.
You can create a "hud.conf" to costumize the positions of health, hunger, armor and breath bar. Take a look at "hud.conf.example" to get more infos.
!!NOTICE: Keep in mind if running a server with this mod, that the costum position should be displayed correct on every screen size!!
Hunger:
This mod adds hunger to the game. You can disable this by setting "HUD_HUNGER_ENABLE = false" in "hud.conf", or "hud_hunger_enable = false" in minetest.conf. In case of conflict hud.conf configuration is dominant.
Currently supported food:
- Apples (default)
- Bread (default)
- Drawves (beer and such)
- Mooretrees
- Simple mobs
- Animalmaterials (mobf modpack)
- Fishing
- Glooptest
- Bushes
- Docfarming
- Farming plus
- Mtfoods
Example: 1 apple fills up the hunger bar by 1 bread, 1 bread (from farming) 2 breads in bar.
Altough it show 20 hunger points (10 breads) in hunger bar you can fill it up to 30 points. (5 breads not shown then)

View File

@ -1,31 +0,0 @@
minetest.after(0, function()
if not armor.def then
minetest.after(2,minetest.chat_send_all,"#Better HUD: Please update your version of 3darmor")
HUD_SHOW_ARMOR = false
end
end)
function hud.get_armor(player)
if not player or not armor.def then
return
end
local name = player:get_player_name()
hud.set_armor(player, armor.def[name].state, armor.def[name].count)
end
function hud.set_armor(player, ges_state, items)
if not player then return end
local max_items = 4
if items == 5 then max_items = items end
local max = max_items*65535
local lvl = max - ges_state
lvl = lvl/max
if ges_state == 0 and items == 0 then
lvl = 0
end
hud.armor[player:get_player_name()] = lvl*(items*(20/max_items))
end

View File

@ -1,47 +0,0 @@
0.2 Beta
--------
- added support of costum 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
0.2.1 Beta
----------
- tweaked override of food
- added support for food of dwares, moretrees and simple mobs
0.2.2 Beta
----------
- added support for food of animalmaterials (mobf modpack),fishing
0.2.3 Beta
----------
- added support for food of glooptest and bushes (commit by CheeseKeg)
0.3 Beta
----------
- added fancy borders of hud inventory bar (only for screenheight <= 800)
0.4 Beta
----------
- enabled drowning
0.5 Beta
----------
- removed the fancy borders of hud inventory bar and moved to new native support
- moved crosshair to native support too
1.0
---
- hunger is reset after death
- health and hunger bar is shown correct on all screen resolutions now
- switched to changed native hotbar image support
- fixed revival of player when drown
- hunger bar is not shown anymore if hunger is disabled
- hunger can be disabled by minetest.conf ("hud_hunger_enable = false")
1.1
---
- added support for stu's 3darmor mod
- restructured and cleaned up code
- added support for poisen food (damages player, but does not kill)

View File

@ -1,33 +0,0 @@
--##Better HUD example config file##
------------------------------------
-- This example moves the health bar in the top left corner and the hunger bar in the top right corner
--
-- general settings
--
HUD_ENABLE_HUNGER = true --enables/disables hunger
HUD_HUNGER_TICK = 300 --sets time for loosing 1/2 bread (of 10) (in seconds)
--!NOTICE!--
-- >>if damage is disabled neither health bar nor hunger bar or breath bar is shown
--
-- health bar
--
HUD_HEALTH_POS = {x=0,y=0} --min 0, max 1
HUD_HEALTH_OFFSET = {x=5,y=30} --offset in pixel
--
-- hunger bar
--
HUD_HUNGER_POS = {x=1,y=0} --min 0, max 1
HUD_HUNGER_OFFSET = {x=-175,y=30} --offset in pixel
--
-- breath bar
--
HUD_AIR_POS = {x=0.5,y=1} --min 0, max 1
HUD_AIR_OFFSET = {x=15,y=-75} --offset in pixel

View File

@ -1,73 +0,0 @@
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
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
end
local function poisenp(tick, time, time_left, player)
time_left = time_left + tick
if time_left < time then
minetest.after(tick, poisenp, tick, time, time_left, player)
end
if player:get_hp()-1 > 0 then
player:set_hp(player:get_hp()-1)
end
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()])
h=h+hunger_change
if h>30 then h=30 end
hud.hunger[user:get_player_name()]=h
hud.save_hunger(user)
itemstack:add_item(replace_with_item) -- note: replace_with_item is optional
--sound:eat
if poisen then
poisenp(1.0, poisen, 0, user)
end
end
return itemstack
end
end
local function overwrite(name, hunger_change, replace_with_item, poisen)
local tab = minetest.registered_items[name]
if tab == nil then return end
tab.on_use = hud.item_eat(hunger_change, replace_with_item, poisen)
minetest.registered_items[name] = tab
end
minetest.after(0.5, function()--ensure all other mods get loaded
if minetest.get_modpath("farming") ~= nil then
overwrite("farming:cake", 16)
end
if minetest.get_modpath("bushes") ~= nil then
for _, row in ipairs(bushes_classic.bushes) do
local name = row[1]
overwrite("bushes:sugar", 1)
overwrite("bushes:"..name, 1)
overwrite("bushes:"..name.."_pie_raw", 4)
overwrite("bushes:"..name.."_pie_cooked", 6)
overwrite("bushes:"..name.."_pie_slice", 1)
overwrite("bushes:basket_"..name, 18)
end
end
end)

View File

@ -1,44 +1,9 @@
hud = {} hud = {}
local health_hud = {}
hud.hunger = {}
local hunger_hud = {}
local air_hud = {}
hud.armor = {}
local armor_hud = {}
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
HUD_HEALTH_POS = {x=0.5,y=0.9}
HUD_HEALTH_OFFSET = {x=-175, y=-1}
HUD_HUNGER_POS = {x=0.5,y=0.9}
HUD_HUNGER_OFFSET = {x=15, y=-1}
HUD_AIR_POS = {x=0.5,y=0.9}
HUD_AIR_OFFSET = {x=15,y=-17}
HUD_ARMOR_POS = {x=0.5,y=0.9}
HUD_ARMOR_OFFSET = {x=-175, y=-15}
--load costum settings
local set = io.open(minetest.get_modpath("hud").."/hud.conf", "r")
if set then
dofile(minetest.get_modpath("hud").."/hud.conf")
set:close()
else
if not HUD_ENABLE_HUNGER then
HUD_AIR_OFFSET = {x=15,y=0}
end
end
--minetest.after(SAVE_INTERVAL, timer, SAVE_INTERVAL) --minetest.after(SAVE_INTERVAL, timer, SAVE_INTERVAL)
local function hide_builtin(player) local function hide_builtin(player)
player:hud_set_flags({crosshair = true, hotbar = true, healthbar = false, wielditem = true, breathbar = false}) player:hud_set_flags({crosshair = true, hotbar = true, healthbar = true, wielditem = true, breathbar = true})
end end
@ -47,169 +12,11 @@ local function costum_hud(player)
--fancy hotbar --fancy hotbar
player:hud_set_hotbar_image("hud_hotbar.png") player:hud_set_hotbar_image("hud_hotbar.png")
player:hud_set_hotbar_selected_image("hud_hotbar_selected.png") player:hud_set_hotbar_selected_image("hud_hotbar_selected.png")
if minetest.setting_getbool("enable_damage") then
--hunger
if HUD_ENABLE_HUNGER then
player:hud_add({
hud_elem_type = "statbar",
position = HUD_HUNGER_POS,
scale = {x=1, y=1},
text = "hud_hunger_bg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HUNGER_OFFSET,
})
hunger_hud[player:get_player_name()] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_HUNGER_POS,
scale = {x=1, y=1},
text = "hud_hunger_fg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HUNGER_OFFSET,
})
end
--health
player:hud_add({
hud_elem_type = "statbar",
position = HUD_HEALTH_POS,
scale = {x=1, y=1},
text = "hud_heart_bg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HEALTH_OFFSET,
})
health_hud[player:get_player_name()] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_HEALTH_POS,
scale = {x=1, y=1},
text = "hud_heart_fg.png",
number = player:get_hp(),
alignment = {x=-1,y=-1},
offset = HUD_HEALTH_OFFSET,
})
--air
air_hud[player:get_player_name()] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_AIR_POS,
scale = {x=1, y=1},
text = "hud_air_fg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_AIR_OFFSET,
})
--armor
if HUD_SHOW_ARMOR then
player:hud_add({
hud_elem_type = "statbar",
position = HUD_ARMOR_POS,
scale = {x=1, y=1},
text = "hud_armor_bg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_ARMOR_OFFSET,
})
armor_hud[player:get_player_name()] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_ARMOR_POS,
scale = {x=1, y=1},
text = "hud_armor_fg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_ARMOR_OFFSET,
})
end
end
end
--needs to be set always(for 3darmor)
function hud.set_armor()
end
if HUD_ENABLE_HUNGER then dofile(minetest.get_modpath("hud").."/hunger.lua") end
if HUD_SHOW_ARMOR then dofile(minetest.get_modpath("hud").."/armor.lua") end
local function update_hud(player)
--air
local air = player:get_breath()*2
if player:get_breath() > 10 then air = 0 end
player:hud_change(air_hud[player:get_player_name()], "number", air)
--health
player:hud_change(health_hud[player:get_player_name()], "number", player:get_hp())
--armor
local arm = tonumber(hud.armor[player:get_player_name()])
if not arm then arm = 0 end
player:hud_change(armor_hud[player:get_player_name()], "number", arm)
--hunger
local h = tonumber(hud.hunger[player:get_player_name()])
if h>20 then h=20 end
player:hud_change(hunger_hud[player:get_player_name()], "number", h)
end
local function timer(interval, player)
if interval > 0 then
hud.save_hunger(player)
minetest.after(interval, timer, interval, player)
end
end end
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
hud.armor[player:get_player_name()] = 0
if HUD_ENABLE_HUNGER then hud.hunger[player:get_player_name()] = hud.load_hunger(player) end
if not hud.hunger[player:get_player_name()] then
hud.hunger[player:get_player_name()] = 20
end
minetest.after(0.5, function() minetest.after(0.5, function()
hide_builtin(player) hide_builtin(player)
costum_hud(player) costum_hud(player)
if HUD_ENABLE_HUNGER then hud.save_hunger(player) end
end)
end)
minetest.register_on_respawnplayer(function(player)
hud.hunger[player:get_player_name()] = 20
minetest.after(0.5, function()
if HUD_ENABLE_HUNGER then hud.save_hunger(player) end
end)
end)
local timer = 0
local timer2 = 0
minetest.after(2.5, function()
minetest.register_globalstep(function(dtime)
timer = timer + dtime
timer2 = timer2 + dtime
for _,player in ipairs(minetest.get_connected_players()) do
if minetest.setting_getbool("enable_damage") then
local h = tonumber(hud.hunger[player:get_player_name()])
if HUD_ENABLE_HUNGER and timer > 4 then
if h>=16 and player:get_hp() > 0 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 HUD_ENABLE_HUNGER and timer2>HUD_HUNGER_TICK then
if h>1 then
h=h-1
hud.hunger[player:get_player_name()]=h
hud.save_hunger(player)
end
end
if HUD_SHOW_ARMOR then hud.get_armor(player) end
update_hud(player)
end
end
if timer>4 then timer=0 end
if timer2>HUD_HUNGER_TICK then timer2=0 end
end) end)
end) end)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 730 B

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 671 B