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
|
end
|
||||||
|
|
||||||
-- flashlight, should be used with wielded_light mod for effect
|
-- 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)
|
play_click(player_name)
|
||||||
local new_light_on = not light_flag
|
local new_light_on = not light_flag
|
||||||
local ltsw = "OFF"
|
local lightsw = "OFF"
|
||||||
if new_light_on then ltsw = "ON" end
|
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,
|
minetest.chat_send_player(player_name,
|
||||||
msg_yellow .. "[" .. label .. "]" .. msg_white ..
|
msg_yellow .. "[" .. label .. "]" .. msg_white ..
|
||||||
" Switching flashlight to " .. msg_zero ..
|
" Switching flashlight to " .. msg_zero ..
|
||||||
ltsw .. msg_white)
|
lightsw .. 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")
|
|
||||||
return new_light_on
|
return new_light_on
|
||||||
end
|
end
|
||||||
|
@ -85,6 +85,10 @@ function umg.use(itemstack, user, pointed_thing)
|
|||||||
minertools.mineralscanner_use("UMG:MineralScanner", player_name,
|
minertools.mineralscanner_use("UMG:MineralScanner", player_name,
|
||||||
player_pos, scan_range,
|
player_pos, scan_range,
|
||||||
scan_ore_stones)
|
scan_ore_stones)
|
||||||
|
elseif mode == MODE_LIGHT then
|
||||||
|
light_on = minertools.flashlight_use("UMG:Flashlight",
|
||||||
|
player_name, "minertools:ultimate_mining_gizmo",
|
||||||
|
light_on)
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -103,13 +107,6 @@ function umg.change_mode(itemstack, user_placer, pointed_thing)
|
|||||||
scan_range = minertools.computer_ms_revert_range_change(
|
scan_range = minertools.computer_ms_revert_range_change(
|
||||||
"UMG:MineralScanner", player_name,
|
"UMG:MineralScanner", player_name,
|
||||||
scan_range_min, scan_range_max, scan_range)
|
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
|
end
|
||||||
-- mode change
|
-- mode change
|
||||||
mode = (mode % #mode_name) + 1
|
mode = (mode % #mode_name) + 1
|
||||||
@ -136,13 +133,6 @@ function umg.change_mode(itemstack, user_placer, pointed_thing)
|
|||||||
scan_range = minertools.mineralscanner_switch_range(
|
scan_range = minertools.mineralscanner_switch_range(
|
||||||
"UMG:MineralScanner", player_name,
|
"UMG:MineralScanner", player_name,
|
||||||
scan_range_min, scan_range_max, scan_range)
|
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
|
||||||
end
|
end
|
||||||
last_rclick_ts = rclick_ts
|
last_rclick_ts = rclick_ts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user