put some rudementary night vision together
This commit is contained in:
parent
9836d631f9
commit
44536dd75d
|
@ -6,8 +6,9 @@ local is_weak = {}
|
|||
local is_water_breathing = {}
|
||||
local is_leaping = {}
|
||||
local is_swift = {}
|
||||
local is_cat = {}
|
||||
|
||||
|
||||
local timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
||||
-- Check for invisible players
|
||||
|
@ -155,6 +156,28 @@ minetest.register_globalstep(function(dtime)
|
|||
|
||||
end
|
||||
|
||||
-- Check for Night Vision equipped players
|
||||
for player, vals in pairs(is_cat) do
|
||||
|
||||
if is_cat[player] and player:get_properties() then
|
||||
|
||||
player = player or player:get_luaentity()
|
||||
|
||||
is_cat[player].timer = is_cat[player].timer + dtime
|
||||
|
||||
if player:get_pos() then mcl_potions._add_spawner(player, "#1010AA") end
|
||||
player:override_day_night_ratio(0.45)
|
||||
|
||||
if is_cat[player].timer >= is_cat[player].dur then
|
||||
is_cat[player] = nil
|
||||
end
|
||||
|
||||
elseif not player:get_properties() then
|
||||
is_cat[player] = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end )
|
||||
|
||||
-- reset player is_invisible/poison if they go offline
|
||||
|
@ -194,6 +217,10 @@ minetest.register_on_leaveplayer(function(player)
|
|||
is_swift[player] = nil
|
||||
end
|
||||
|
||||
if is_cat[player] then
|
||||
is_cat[player] = nil
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
function mcl_potions.make_invisible(player, toggle)
|
||||
|
@ -425,5 +452,18 @@ end
|
|||
|
||||
|
||||
function mcl_potions.night_vision_func(player, duration)
|
||||
player:override_day_night_ratio(0.45)
|
||||
|
||||
if not is_cat[player] then
|
||||
|
||||
is_cat[player] = {dur = duration, timer = 0}
|
||||
|
||||
else
|
||||
|
||||
local victim = is_cat[player]
|
||||
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
victim.timer = 0
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -152,20 +152,20 @@ minetest.register_craftitem("mcl_potions:harming_2", {
|
|||
minetest.register_craftitem("mcl_potions:night_vision", {
|
||||
description = S("Night Vision Potion"),
|
||||
_doc_items_longdesc = brewhelp,
|
||||
wield_image = potion_image("#009999"),
|
||||
inventory_image = potion_image("#009999"),
|
||||
wield_image = potion_image("#1010AA"),
|
||||
inventory_image = potion_image("#1010AA"),
|
||||
groups = { brewitem = 1, food=0},
|
||||
stack_max = 1,
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.night_vision_func(user, 180)
|
||||
mcl_potions._use_potion(itemstack, user, "#009999")
|
||||
mcl_potions._use_potion(itemstack, user, "#1010AA")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.night_vision_func(user, 180)
|
||||
mcl_potions._use_potion(itemstack, user, "#009999")
|
||||
mcl_potions._use_potion(itemstack, user, "#1010AA")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -173,20 +173,20 @@ minetest.register_craftitem("mcl_potions:night_vision", {
|
|||
minetest.register_craftitem("mcl_potions:night_vision_plus", {
|
||||
description = S("Night Vision Potion +"),
|
||||
_doc_items_longdesc = brewhelp,
|
||||
wield_image = potion_image("#000A0A"),
|
||||
inventory_image = potion_image("#000A0A"),
|
||||
wield_image = potion_image("#2020BA"),
|
||||
inventory_image = potion_image("#2020BA"),
|
||||
groups = { brewitem = 1, food=0},
|
||||
stack_max = 1,
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.night_vision_func(user, 480)
|
||||
mcl_potions._use_potion(itemstack, user, "#000A0A")
|
||||
mcl_potions._use_potion(itemstack, user, "#2020BA")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.night_vision_func(user, 480)
|
||||
mcl_potions._use_potion(itemstack, user, "#000A0A")
|
||||
mcl_potions._use_potion(itemstack, user, "#2020BA")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -197,10 +197,10 @@ register_splash("water_breathing_plus", "Splash Fire Resistance +", "#E0B050", {
|
|||
potion_fun = function(player, redx) mcl_potions.fire_resistance_func(player, 360*redx) end
|
||||
})
|
||||
|
||||
register_splash("night_vision", "Splash Night Vision", "#009999", {
|
||||
register_splash("night_vision", "Splash Night Vision", "#1010AA", {
|
||||
potion_fun = function(player, redx) mcl_potions.night_vision_func(player, 135*redx) end
|
||||
})
|
||||
|
||||
register_splash("night_vision_plus", "Splash Night Vision +", "#000A0A", {
|
||||
register_splash("night_vision_plus", "Splash Night Vision +", "#2020BA", {
|
||||
potion_fun = function(player, redx) mcl_potions.night_vision_func(player, 360*redx) end
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue