forked from VoxeLibre/VoxeLibre
Migrated beacons to the new API
Also added more effects to them
This commit is contained in:
parent
e36b7f413b
commit
55ce6f0f4b
|
@ -4,8 +4,12 @@ there are strings in meta, which are being used to see which effect will be give
|
||||||
Valid strings:
|
Valid strings:
|
||||||
swiftness
|
swiftness
|
||||||
leaping
|
leaping
|
||||||
strenght
|
strength
|
||||||
regeneration
|
regeneration
|
||||||
|
haste
|
||||||
|
resistance
|
||||||
|
slow_falling
|
||||||
|
absorption
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
mcl_beacons = {
|
mcl_beacons = {
|
||||||
|
@ -122,10 +126,17 @@ local formspec_string=
|
||||||
"image[1,4.5;1,1;custom_beacom_symbol_2.png]"..
|
"image[1,4.5;1,1;custom_beacom_symbol_2.png]"..
|
||||||
"image[1,6;1,1;custom_beacom_symbol_1.png]"..
|
"image[1,6;1,1;custom_beacom_symbol_1.png]"..
|
||||||
|
|
||||||
"image_button[5.2,1.5;1,1;mcl_potions_effect_swift.png;swiftness;]"..
|
"image_button[5.2,1.5;1,1;mcl_potions_effect_swiftness.png;swiftness;]"..
|
||||||
|
"image_button[8.5,1.5;1,1;mcl_potions_effect_haste.png;haste;]"..
|
||||||
|
|
||||||
"image_button[5.2,3;1,1;mcl_potions_effect_leaping.png;leaping;]"..
|
"image_button[5.2,3;1,1;mcl_potions_effect_leaping.png;leaping;]"..
|
||||||
"image_button[5.2,4.5;1,1;mcl_potions_effect_strong.png;strenght;]"..
|
"image_button[8.5,3;1,1;mcl_potions_effect_resistance.png;resistance;]"..
|
||||||
"image_button[5.2,6;1,1;mcl_potions_effect_regenerating.png;regeneration;]"..
|
|
||||||
|
"image_button[5.2,4.5;1,1;mcl_potions_effect_strength.png;strength;]"..
|
||||||
|
"image_button[8.5,4.5;1,1;mcl_potions_effect_absorption.png;absorption;]"..
|
||||||
|
|
||||||
|
"image_button[5.2,6;1,1;mcl_potions_effect_regeneration.png;regeneration;]"..
|
||||||
|
"image_button[8.5,6;1,1;mcl_potions_effect_slow_falling.png;slow_falling;]"..
|
||||||
|
|
||||||
"item_image[1,7;1,1;mcl_core:diamond]"..
|
"item_image[1,7;1,1;mcl_core:diamond]"..
|
||||||
"item_image[2.2,7;1,1;mcl_core:emerald]"..
|
"item_image[2.2,7;1,1;mcl_core:emerald]"..
|
||||||
|
@ -197,15 +208,7 @@ end
|
||||||
local function effect_player(effect,pos,power_level, effect_level,player)
|
local function effect_player(effect,pos,power_level, effect_level,player)
|
||||||
local distance = vector.distance(player:get_pos(), pos)
|
local distance = vector.distance(player:get_pos(), pos)
|
||||||
if distance > (power_level+1)*10 then return end
|
if distance > (power_level+1)*10 then return end
|
||||||
if effect == "swiftness" then
|
mcl_potions.give_effect_by_level(effect, player, effect_level, 16)
|
||||||
mcl_potions.swiftness_func(player,effect_level,16)
|
|
||||||
elseif effect == "leaping" then
|
|
||||||
mcl_potions.leaping_func(player, effect_level, 16)
|
|
||||||
elseif effect == "strenght" then
|
|
||||||
mcl_potions.strength_func(player, effect_level, 16)
|
|
||||||
elseif effect == "regeneration" then
|
|
||||||
mcl_potions.regeneration_func(player, effect_level, 16)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function apply_effects_to_all_players(pos)
|
local function apply_effects_to_all_players(pos)
|
||||||
|
@ -254,7 +257,8 @@ minetest.register_node("mcl_beacons:beacon", {
|
||||||
remove_beacon_beam(pos)
|
remove_beacon_beam(pos)
|
||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
if fields.swiftness or fields.regeneration or fields.leaping or fields.strenght then
|
if fields.swiftness or fields.regeneration or fields.leaping or fields.strenght
|
||||||
|
or fields.haste or fields.resistance or fields.absorption or fields.slow_falling then
|
||||||
local sender_name = sender:get_player_name()
|
local sender_name = sender:get_player_name()
|
||||||
local power_level = beacon_blockcheck(pos)
|
local power_level = beacon_blockcheck(pos)
|
||||||
if minetest.is_protected(pos, sender_name) then
|
if minetest.is_protected(pos, sender_name) then
|
||||||
|
@ -293,6 +297,14 @@ minetest.register_node("mcl_beacons:beacon", {
|
||||||
end
|
end
|
||||||
minetest.get_meta(pos):set_string("effect","swiftness")
|
minetest.get_meta(pos):set_string("effect","swiftness")
|
||||||
successful = true
|
successful = true
|
||||||
|
elseif fields.haste then
|
||||||
|
if power_level == 4 then
|
||||||
|
minetest.get_meta(pos):set_int("effect_level",2)
|
||||||
|
else
|
||||||
|
minetest.get_meta(pos):set_int("effect_level",1)
|
||||||
|
end
|
||||||
|
minetest.get_meta(pos):set_string("effect","haste")
|
||||||
|
successful = true
|
||||||
elseif fields.leaping and power_level >= 2 then
|
elseif fields.leaping and power_level >= 2 then
|
||||||
if power_level == 4 then
|
if power_level == 4 then
|
||||||
minetest.get_meta(pos):set_int("effect_level",2)
|
minetest.get_meta(pos):set_int("effect_level",2)
|
||||||
|
@ -301,18 +313,38 @@ minetest.register_node("mcl_beacons:beacon", {
|
||||||
end
|
end
|
||||||
minetest.get_meta(pos):set_string("effect","leaping")
|
minetest.get_meta(pos):set_string("effect","leaping")
|
||||||
successful = true
|
successful = true
|
||||||
|
elseif fields.resistance and power_level >= 2 then
|
||||||
|
if power_level == 4 then
|
||||||
|
minetest.get_meta(pos):set_int("effect_level",2)
|
||||||
|
else
|
||||||
|
minetest.get_meta(pos):set_int("effect_level",1)
|
||||||
|
end
|
||||||
|
minetest.get_meta(pos):set_string("effect","resistance")
|
||||||
|
successful = true
|
||||||
elseif fields.strenght and power_level >= 3 then
|
elseif fields.strenght and power_level >= 3 then
|
||||||
if power_level == 4 then
|
if power_level == 4 then
|
||||||
minetest.get_meta(pos):set_int("effect_level",2)
|
minetest.get_meta(pos):set_int("effect_level",2)
|
||||||
else
|
else
|
||||||
minetest.get_meta(pos):set_int("effect_level",1)
|
minetest.get_meta(pos):set_int("effect_level",1)
|
||||||
end
|
end
|
||||||
minetest.get_meta(pos):set_string("effect","strenght")
|
minetest.get_meta(pos):set_string("effect","strength")
|
||||||
|
successful = true
|
||||||
|
elseif fields.absorption and power_level >= 3 then
|
||||||
|
if power_level == 4 then
|
||||||
|
minetest.get_meta(pos):set_int("effect_level",2)
|
||||||
|
else
|
||||||
|
minetest.get_meta(pos):set_int("effect_level",1)
|
||||||
|
end
|
||||||
|
minetest.get_meta(pos):set_string("effect","absorption")
|
||||||
successful = true
|
successful = true
|
||||||
elseif fields.regeneration and power_level == 4 then
|
elseif fields.regeneration and power_level == 4 then
|
||||||
minetest.get_meta(pos):set_int("effect_level",2)
|
minetest.get_meta(pos):set_int("effect_level",2)
|
||||||
minetest.get_meta(pos):set_string("effect","regeneration")
|
minetest.get_meta(pos):set_string("effect","regeneration")
|
||||||
successful = true
|
successful = true
|
||||||
|
elseif fields.slow_falling and power_level == 4 then
|
||||||
|
minetest.get_meta(pos):set_int("effect_level",2)
|
||||||
|
minetest.get_meta(pos):set_string("effect","slow_falling")
|
||||||
|
successful = true
|
||||||
end
|
end
|
||||||
if successful then
|
if successful then
|
||||||
if power_level == 4 then
|
if power_level == 4 then
|
||||||
|
|
Loading…
Reference in New Issue