Fixed hungry mod and updated some textures

master
bas080 2013-07-24 21:48:52 +02:00
parent 517758f27e
commit c89b7e29c3
8 changed files with 36 additions and 40 deletions

View File

@ -551,8 +551,9 @@ mesecon_lamp_box = {
minetest.register_node("default:torch", {
drawtype = "nodebox",
tiles = {"default_torch.png", "default_torch_side.png"},
inventory_image = "default_torch.png",
description = "Electrical lamp",
tiles = {"default_torch.png"},
inventory_image = "default_torch_inventory.png",
wield_light = 5,
paramtype = "light",
paramtype2 = "wallmounted",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 B

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 181 B

View File

@ -1,51 +1,46 @@
--Simplest hunger mod ever by bas080
local enabled = minetest.setting_getbool("enable_damage")
if enabled then
local timer = 0
local hunger = {}
hunger.enabled = minetest.setting_getbool("enable_damage")
if hunger.enabled then
local distance_interval = 15 --set distance check interval in seconds
local hunger_per_meter = 1/500 --1 hp per 500 meter walk
local hunger_per_cubic = 1/100 --1 hp per 100 blocks dig
local hunger = 0
local player = nil
local pos_one
minetest.register_on_joinplayer(function(joiner)
minetest.after(0.5, function(param)
player = joiner
pos_one = player:getpos()
local player = joiner
local name = player:get_player_name()
minetest.after(5, function()
hunger[name] = 0
local pos_one = player:getpos()
hunger.update(player, pos_one)
end)
end)
hunger.update = function(player, pos_one)
if player == nil or pos_one == nil then return end
local pos_two = player:getpos()
if pos_two == nil then return end
local name = player:get_player_name()
minetest.after(distance_interval, function()
hunger.update(player,pos_two)
end)
print(hunger[name])
hunger[name] = hunger[name] + (math.hypot(pos_one.x-pos_two.x, pos_one.y-pos_two.y)+math.abs(pos_one.y-pos_two.y))*hunger_per_meter
if hunger[name] >=0.5 then
player:set_hp(player:get_hp()-hunger[name])
hunger[name] = 0
minetest.sound_play({ name="hunger_stomach" }, {
gain = 1.0;
max_hear_distance = 16;
});
end
end
minetest.register_on_dignode(function(pos, oldnode, player)
hunger = hunger + hunger_per_cubic
if hunger >= 0.5 then
hunger = 0
player:set_hp(player:get_hp()-hunger)
end
end)
minetest.register_globalstep(function(dtime)
if player ~= nil then
timer = timer + dtime
if timer >= distance_interval then
timer = 0
local pos_two = player:getpos()
hunger = hunger + (math.hypot(pos_one.x-pos_two.x, pos_one.y-pos_two.y)+math.abs(pos_one.y-pos_two.y))*hunger_per_meter
pos_one = pos_two
if hunger >=0.5 then
timer = 0
player:set_hp(player:get_hp()-hunger)
hunger=0
minetest.sound_play({ name="hunger_stomach" }, {
gain = 1.0;
max_hear_distance = 16;
});
end
end
local name = player:get_player_name()
hunger[name] = hunger[name] + hunger_per_cubic
if hunger[name] >= 0.5 then
player:set_hp(player:get_hp()-hunger[name])
hunger[name] = 0
end
end)
end