minertools: changed flashlight control to item 'use' function.
Flashlight on/off switching moved to 'use' (left click) key. Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
This commit is contained in:
parent
fb277e512a
commit
886cbcefa7
@ -411,25 +411,20 @@ function minertools.computer_ms_revert_range_change(label, player_name,
|
||||
end
|
||||
|
||||
-- flashlight, should be used with wielded_light mod for effect
|
||||
function minertools.flashlight_switch(label, player_name, light_flag)
|
||||
function minertools.flashlight_use(label, player_name,
|
||||
item_name, light_flag)
|
||||
play_click(player_name)
|
||||
local new_light_on = not light_flag
|
||||
local ltsw = "OFF"
|
||||
if new_light_on then ltsw = "ON" end
|
||||
local lightsw = "OFF"
|
||||
local lightlvl = 0
|
||||
if new_light_on then
|
||||
lightsw = "ON"
|
||||
lightlvl = default.LIGHT_MAX
|
||||
end
|
||||
minetest.override_item(item_name, { light_source = lightlvl })
|
||||
minetest.chat_send_player(player_name,
|
||||
msg_yellow .. "[" .. label .. "]" .. msg_white ..
|
||||
" Switching flashlight to " .. msg_zero ..
|
||||
ltsw .. msg_white)
|
||||
return new_light_on
|
||||
end
|
||||
function minertools.computer_fl_revert_switch(label, player_name,
|
||||
light_flag)
|
||||
local new_light_on = not light_flag
|
||||
local ltsw = "OFF"
|
||||
if new_light_on then ltsw = "ON" end
|
||||
minetest.chat_send_player(player_name,
|
||||
msg_yellow .. "[" .. label .. "]" .. msg_white ..
|
||||
" Changing back flashlight to " .. msg_zero .. ltsw ..
|
||||
msg_white .. " and saving")
|
||||
lightsw .. msg_white)
|
||||
return new_light_on
|
||||
end
|
||||
|
@ -85,6 +85,10 @@ function umg.use(itemstack, user, pointed_thing)
|
||||
minertools.mineralscanner_use("UMG:MineralScanner", player_name,
|
||||
player_pos, scan_range,
|
||||
scan_ore_stones)
|
||||
elseif mode == MODE_LIGHT then
|
||||
light_on = minertools.flashlight_use("UMG:Flashlight",
|
||||
player_name, "minertools:ultimate_mining_gizmo",
|
||||
light_on)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
@ -103,13 +107,6 @@ function umg.change_mode(itemstack, user_placer, pointed_thing)
|
||||
scan_range = minertools.computer_ms_revert_range_change(
|
||||
"UMG:MineralScanner", player_name,
|
||||
scan_range_min, scan_range_max, scan_range)
|
||||
elseif mode == MODE_LIGHT then
|
||||
light_on = minertools.computer_fl_revert_switch(
|
||||
"UMG:Flashlight", player_name, light_on)
|
||||
local lightlvl = 0
|
||||
if light_on then lightlvl = default.LIGHT_MAX end
|
||||
minetest.override_item("minertools:ultimate_mining_gizmo",
|
||||
{ light_source = lightlvl })
|
||||
end
|
||||
-- mode change
|
||||
mode = (mode % #mode_name) + 1
|
||||
@ -136,13 +133,6 @@ function umg.change_mode(itemstack, user_placer, pointed_thing)
|
||||
scan_range = minertools.mineralscanner_switch_range(
|
||||
"UMG:MineralScanner", player_name,
|
||||
scan_range_min, scan_range_max, scan_range)
|
||||
elseif mode == MODE_LIGHT then
|
||||
light_on = minertools.flashlight_switch(
|
||||
"UMG:Flashlight", player_name, light_on)
|
||||
local lightlvl = 0
|
||||
if light_on then lightlvl = default.LIGHT_MAX end
|
||||
minetest.override_item("minertools:ultimate_mining_gizmo",
|
||||
{ light_source = lightlvl })
|
||||
end
|
||||
end
|
||||
last_rclick_ts = rclick_ts
|
||||
|
Loading…
x
Reference in New Issue
Block a user