Indent with tabs other than spaces

This commit is contained in:
sys4-fr 2016-07-14 14:02:30 +02:00
parent 9f70fa12f1
commit 0a9905448f

216
init.lua
View File

@ -25,126 +25,122 @@ end
-- Poison player
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)
else
--reset hud image
end
if player:get_hp()-1 > 0 then
player:set_hp(player:get_hp()-1)
end
end
time_left = time_left + tick
if time_left < time then
minetest.after(tick, poisenp, tick, time, time_left, player)
else
--reset hud image
end
if player:get_hp()-1 > 0 then
player:set_hp(player:get_hp()-1)
end
end
function diet.item_eat(max, replace_with_item, poisen, heal)
return function(itemstack, user, pointed_thing)
-- Process player data
local name = user:get_player_name()
local player = diet.__player(name)
local item = itemstack:get_name()
return function(itemstack, user, pointed_thing)
-- Get type
local ftype = ""
if (minetest.registered_items[item] and minetest.registered_items[item].groups) then
local groups = minetest.registered_items[item].groups
if groups.food_type_meal then
ftype = "meal"
elseif groups.food_type_snack then
ftype = "snack"
elseif groups.food_type_dessert then
ftype = "dessert"
elseif groups.food_type_drink then
ftype = "drink"
end
end
-- Process player data
local name = user:get_player_name()
local player = diet.__player(name)
local item = itemstack:get_name()
-- Calculate points
local points = max
if (#player.eaten>0) then
local same_food = 0
local same_type = 0
for _,v in pairs(player.eaten) do
if v[1] == item then
same_food = same_food + 1
end
if v[2] == ftype then
same_type = same_type + 1
end
end
local mult = same_food/10
points = points * 1-mult
-- Get type
local ftype = ""
if (minetest.registered_items[item] and minetest.registered_items[item].groups) then
local groups = minetest.registered_items[item].groups
if groups.food_type_meal then
ftype = "meal"
elseif groups.food_type_snack then
ftype = "snack"
elseif groups.food_type_dessert then
ftype = "dessert"
elseif groups.food_type_drink then
ftype = "drink"
end
end
-- Calculate points
local points = max
if (#player.eaten>0) then
local same_food = 0
local same_type = 0
for _,v in pairs(player.eaten) do
if v[1] == item then
same_food = same_food + 1
end
if v[2] == ftype then
same_type = same_type + 1
end
end
local mult = same_food/10
points = points * 1-mult
if (mult > 0.9) then
local desc = item
if (minetest.registered_items[item] and minetest.registered_items[item].description) then
desc = minetest.registered_items[item].description
end
minetest.chat_send_player(name,"Your stomach hates "..desc)
elseif (mult > 0.4) then
minetest.chat_send_player(name,"Your stomach could do with a change.")
end
if points > max then
error("[DIET] This shouldn't happen! points > max")
return
end
end
if (mult > 0.9) then
local desc = item
if (minetest.registered_items[item] and minetest.registered_items[item].description) then
desc = minetest.registered_items[item].description
end
minetest.chat_send_player(name,"Your stomach hates "..desc)
elseif (mult > 0.4) then
minetest.chat_send_player(name,"Your stomach could do with a change.")
end
if points > max then
error("[DIET] This shouldn't happen! points > max")
return
end
end
-- Increase health
if minetest.get_modpath("hbhunger") and hbhunger then
minetest.sound_play({name = "hbhunger_eat_generic", gain = 1}, {pos=user:getpos(), max_hear_distance = 16})
-- Increase health
if minetest.get_modpath("hbhunger") and hbhunger then
minetest.sound_play({name = "hbhunger_eat_generic", gain = 1}, {pos=user:getpos(), max_hear_distance = 16})
-- saturation
local h = tonumber(hbhunger.hunger[name])
h = h + points
-- saturation
local h = tonumber(hbhunger.hunger[name])
h = h + points
if h > 30 then h = 30 end
hbhunger.hunger[name] = h
hbhunger.set_hunger(user)
if h > 30 then h = 30 end
hbhunger.hunger[name] = h
hbhunger.set_hunger(user)
-- healing
local hp = user:get_hp()
if hp < 20 and heal then
hp = hp + heal
if hp > 20 then hp = 20 end
user:set_hp(hp)
end
-- healing
local hp = user:get_hp()
if hp < 20 and heal then
hp = hp + heal
if hp > 20 then hp = 20 end
user:set_hp(hp)
end
-- Poison
if poisen then
--set hud-img
poisenp(1.0, poisen, 0, user)
end
-- Poison
if poisen then
--set hud-img
poisenp(1.0, poisen, 0, user)
end
elseif minetest.get_modpath("hunger") and hunger then
local h = tonumber(hunger.players[name].lvl)
h = h + points
hunger.update_hunger(user, h)
elseif minetest.get_modpath("hunger") and hunger then
local h = tonumber(hunger.players[name].lvl)
h = h + points
hunger.update_hunger(user, h)
else
local hp = user:get_hp()
if (hp+points > 20) then
hp = 20
else
hp = hp + points
end
user:set_hp(hp)
end
else
local hp = user:get_hp()
if (hp+points > 20) then
hp = 20
else
hp = hp + points
end
user:set_hp(hp)
end
-- Register
diet.__register_eat(player,item,ftype)
diet.save()
-- Remove item
itemstack:add_item(replace_with_item)
itemstack:take_item()
return itemstack
end
end
-- Register
diet.__register_eat(player,item,ftype)
diet.save()
-- Remove item
itemstack:add_item(replace_with_item)
itemstack:take_item()
return itemstack
end
end
function diet.__player(name)
if name == "" then
@ -265,7 +261,7 @@ end
if minetest.get_modpath("bushes_classic") then
-- bushes_classic mod, as found in the plantlife modpack
local berries = {
"strawberry",
"strawberry",
"blackberry",
"blueberry",
"raspberry",
@ -439,7 +435,7 @@ if minetest.get_modpath("kpgmobs") ~= nil then
overwrite("kpgmobs:meat", 6)
overwrite("kpgmobs:rat_cooked", 5)
overwrite("kpgmobs:med_cooked", 4)
if minetest.get_modpath("bucket") then
if minetest.get_modpath("bucket") then
overwrite("kpgmobs:bucket_milk", 4, "bucket:bucket_empty")
end
end