Fix crash when there is no more network for the remote.

This commit is contained in:
Mike Stump 2024-01-13 13:22:50 -08:00
parent c1b238c62e
commit 7a73b405f5

@ -140,9 +140,12 @@ minetest.register_tool("microexpansion:remote", {
end end
local net,cpos = me.get_connected_network(pos) local net,cpos = me.get_connected_network(pos)
local charge_to_take = 100
if net then
-- 25 to 1062 eu per operation, rich people pay for distance. -- 25 to 1062 eu per operation, rich people pay for distance.
local distance = vector.distance(net.controller_pos, user:get_pos()) local distance = vector.distance(net.controller_pos, user:get_pos())
local charge_to_take = math.pow(math.log(distance),2) * 10 local charge_to_take = math.pow(math.log(distance),2) * 10
end
if toolmeta.charge < charge_to_take then if toolmeta.charge < charge_to_take then
minetest.chat_send_player(user:get_player_name(), "No power left, recharge in technic battery.") minetest.chat_send_player(user:get_player_name(), "No power left, recharge in technic battery.")