mirror of
https://github.com/minetest-mods/technic.git
synced 2024-09-12 08:18:30 +02:00
Tools don't wear in creative mode v2
- Removed cans (will add again per request) - Added creative check to global namespace (checking only once as requested by VanessaE)
This commit is contained in:
parent
19f74d11ba
commit
b8c9028681
@ -3,6 +3,7 @@
|
|||||||
-- (c) 2012-2013 by RealBadAngel <mk@realbadangel.pl>
|
-- (c) 2012-2013 by RealBadAngel <mk@realbadangel.pl>
|
||||||
|
|
||||||
technic = rawget(_G, "technic") or {}
|
technic = rawget(_G, "technic") or {}
|
||||||
|
technic.creative_mode = minetest.setting_getbool("creative_mode")
|
||||||
|
|
||||||
technic.tube_inject_item = pipeworks.tube_inject_item or function (pos, start_pos, velocity, item)
|
technic.tube_inject_item = pipeworks.tube_inject_item or function (pos, start_pos, velocity, item)
|
||||||
local tubed = pipeworks.tube_item(vector.new(pos), item)
|
local tubed = pipeworks.tube_item(vector.new(pos), item)
|
||||||
|
@ -344,9 +344,10 @@ minetest.register_tool("technic:chainsaw", {
|
|||||||
-- Send current charge to digging function so that the
|
-- Send current charge to digging function so that the
|
||||||
-- chainsaw will stop after digging a number of nodes
|
-- chainsaw will stop after digging a number of nodes
|
||||||
meta.charge = chainsaw_dig(pointed_thing.under, meta.charge)
|
meta.charge = chainsaw_dig(pointed_thing.under, meta.charge)
|
||||||
|
if not technic.creative_mode then
|
||||||
technic.set_RE_wear(itemstack, meta.charge, chainsaw_max_charge)
|
technic.set_RE_wear(itemstack, meta.charge, chainsaw_max_charge)
|
||||||
itemstack:set_metadata(minetest.serialize(meta))
|
itemstack:set_metadata(minetest.serialize(meta))
|
||||||
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -40,10 +40,12 @@ local function check_for_flashlight(player)
|
|||||||
if hotbar[i]:get_name() == "technic:flashlight" then
|
if hotbar[i]:get_name() == "technic:flashlight" then
|
||||||
local meta = minetest.deserialize(hotbar[i]:get_metadata())
|
local meta = minetest.deserialize(hotbar[i]:get_metadata())
|
||||||
if meta and meta.charge and meta.charge >= 2 then
|
if meta and meta.charge and meta.charge >= 2 then
|
||||||
meta.charge = meta.charge - 2;
|
if not technic.creative_mode then
|
||||||
technic.set_RE_wear(hotbar[i], meta.charge, flashlight_max_charge)
|
meta.charge = meta.charge - 2;
|
||||||
hotbar[i]:set_metadata(minetest.serialize(meta))
|
technic.set_RE_wear(hotbar[i], meta.charge, flashlight_max_charge)
|
||||||
inv:set_stack("main", i, hotbar[i])
|
hotbar[i]:set_metadata(minetest.serialize(meta))
|
||||||
|
inv:set_stack("main", i, hotbar[i])
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -298,9 +298,11 @@ local function mining_drill_mk2_handler(itemstack, user, pointed_thing)
|
|||||||
if meta.charge >= charge_to_take then
|
if meta.charge >= charge_to_take then
|
||||||
local pos = minetest.get_pointed_thing_position(pointed_thing, above)
|
local pos = minetest.get_pointed_thing_position(pointed_thing, above)
|
||||||
drill_dig_it(pos, user, meta.mode)
|
drill_dig_it(pos, user, meta.mode)
|
||||||
meta.charge = meta.charge - charge_to_take
|
if not technic.creative_mode then
|
||||||
itemstack:set_metadata(minetest.serialize(meta))
|
meta.charge = meta.charge - charge_to_take
|
||||||
technic.set_RE_wear(itemstack, meta.charge, max_charge[2])
|
itemstack:set_metadata(minetest.serialize(meta))
|
||||||
|
technic.set_RE_wear(itemstack, meta.charge, max_charge[2])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
@ -319,9 +321,11 @@ local function mining_drill_mk3_handler(itemstack, user, pointed_thing)
|
|||||||
if meta.charge >= charge_to_take then
|
if meta.charge >= charge_to_take then
|
||||||
local pos = minetest.get_pointed_thing_position(pointed_thing, above)
|
local pos = minetest.get_pointed_thing_position(pointed_thing, above)
|
||||||
drill_dig_it(pos, user, meta.mode)
|
drill_dig_it(pos, user, meta.mode)
|
||||||
meta.charge = meta.charge - charge_to_take
|
if not technic.creative_mode then
|
||||||
itemstack:set_metadata(minetest.serialize(meta))
|
meta.charge = meta.charge - charge_to_take
|
||||||
technic.set_RE_wear(itemstack, meta.charge, max_charge[3])
|
itemstack:set_metadata(minetest.serialize(meta))
|
||||||
|
technic.set_RE_wear(itemstack, meta.charge, max_charge[3])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
@ -346,9 +350,11 @@ minetest.register_tool("technic:mining_drill", {
|
|||||||
if meta.charge >= charge_to_take then
|
if meta.charge >= charge_to_take then
|
||||||
local pos = minetest.get_pointed_thing_position(pointed_thing, above)
|
local pos = minetest.get_pointed_thing_position(pointed_thing, above)
|
||||||
drill_dig_it(pos, user, 1)
|
drill_dig_it(pos, user, 1)
|
||||||
meta.charge = meta.charge - charge_to_take
|
if not technic.creative_mode then
|
||||||
itemstack:set_metadata(minetest.serialize(meta))
|
meta.charge = meta.charge - charge_to_take
|
||||||
technic.set_RE_wear(itemstack, meta.charge, max_charge[1])
|
itemstack:set_metadata(minetest.serialize(meta))
|
||||||
|
technic.set_RE_wear(itemstack, meta.charge, max_charge[1])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
|
@ -164,10 +164,12 @@ for _, m in pairs(mining_lasers_list) do
|
|||||||
|
|
||||||
-- If there's enough charge left, fire the laser
|
-- If there's enough charge left, fire the laser
|
||||||
if meta.charge >= m[4] then
|
if meta.charge >= m[4] then
|
||||||
meta.charge = meta.charge - m[4]
|
|
||||||
laser_shoot(user, m[2], "technic_laser_beam_mk"..m[1]..".png", "technic_laser_mk"..m[1])
|
laser_shoot(user, m[2], "technic_laser_beam_mk"..m[1]..".png", "technic_laser_mk"..m[1])
|
||||||
technic.set_RE_wear(itemstack, meta.charge, m[3])
|
if not technic.creative_mode then
|
||||||
itemstack:set_metadata(minetest.serialize(meta))
|
meta.charge = meta.charge - m[4]
|
||||||
|
technic.set_RE_wear(itemstack, meta.charge, m[3])
|
||||||
|
itemstack:set_metadata(minetest.serialize(meta))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
|
@ -28,9 +28,11 @@ minetest.register_tool("technic:prospector", {
|
|||||||
minetest.chat_send_player(user:get_player_name(), "Right-click to set target block type")
|
minetest.chat_send_player(user:get_player_name(), "Right-click to set target block type")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
toolmeta.charge = toolmeta.charge - charge_to_take
|
if not technic.creative_mode then
|
||||||
toolstack:set_metadata(minetest.serialize(toolmeta))
|
toolmeta.charge = toolmeta.charge - charge_to_take
|
||||||
technic.set_RE_wear(toolstack, toolmeta.charge, technic.power_tools[toolstack:get_name()])
|
toolstack:set_metadata(minetest.serialize(toolmeta))
|
||||||
|
technic.set_RE_wear(toolstack, toolmeta.charge, technic.power_tools[toolstack:get_name()])
|
||||||
|
end
|
||||||
local start_pos = pointed_thing.under
|
local start_pos = pointed_thing.under
|
||||||
local forward = minetest.facedir_to_dir(minetest.dir_to_facedir(user:get_look_dir(), true))
|
local forward = minetest.facedir_to_dir(minetest.dir_to_facedir(user:get_look_dir(), true))
|
||||||
local right = forward.x ~= 0 and { x=0, y=1, z=0 } or (forward.y ~= 0 and { x=0, y=0, z=1 } or { x=1, y=0, z=0 })
|
local right = forward.x ~= 0 and { x=0, y=1, z=0 } or (forward.y ~= 0 and { x=0, y=0, z=1 } or { x=1, y=0, z=0 })
|
||||||
|
@ -63,7 +63,7 @@ local function screwdriver_handler(itemstack, user, pointed_thing, mode)
|
|||||||
node.param2 = preservePart + rotationPart
|
node.param2 = preservePart + rotationPart
|
||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
|
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not technic.creative_mode then
|
||||||
meta1.charge = meta1.charge - 100
|
meta1.charge = meta1.charge - 100
|
||||||
itemstack:set_metadata(minetest.serialize(meta1))
|
itemstack:set_metadata(minetest.serialize(meta1))
|
||||||
technic.set_RE_wear(itemstack, meta1.charge, sonic_screwdriver_max_charge)
|
technic.set_RE_wear(itemstack, meta1.charge, sonic_screwdriver_max_charge)
|
||||||
|
@ -22,13 +22,15 @@ minetest.register_tool("technic:treetap", {
|
|||||||
node.name = "moretrees:rubber_tree_trunk_empty"
|
node.name = "moretrees:rubber_tree_trunk_empty"
|
||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
minetest.handle_node_drops(pointed_thing.above, {"technic:raw_latex"}, user)
|
minetest.handle_node_drops(pointed_thing.above, {"technic:raw_latex"}, user)
|
||||||
local item_wear = tonumber(itemstack:get_wear())
|
if not technic.creative_mode then
|
||||||
item_wear = item_wear + 819
|
local item_wear = tonumber(itemstack:get_wear())
|
||||||
if item_wear > 65535 then
|
item_wear = item_wear + 819
|
||||||
itemstack:clear()
|
if item_wear > 65535 then
|
||||||
return itemstack
|
itemstack:clear()
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
itemstack:set_wear(item_wear)
|
||||||
end
|
end
|
||||||
itemstack:set_wear(item_wear)
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user