sniper_rifles: Prioritize on un-scoping when right-clicking (#661)

This commit is contained in:
ANAND 2020-09-22 21:22:11 +05:30 committed by GitHub
parent 7793e76890
commit 77c9f9d21b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,11 +54,13 @@ local function on_use(stack, user, pointed)
end end
local function on_rclick(item, placer, pointed_thing) local function on_rclick(item, placer, pointed_thing)
if pointed_thing.type == "object" then local name = placer:get_player_name()
return
-- Prioritize on "un-scoping", if player is using the scope
if not scoped[name] and pointed_thing.type == "node" then
return minetest.item_place(item, placer, pointed_thing)
end end
local name = placer:get_player_name()
if scoped[name] then if scoped[name] then
hide_scope(name) hide_scope(name)
else else
@ -114,6 +116,7 @@ function sniper_rifles.register_rifle(name, def)
-- Manually add extra fields to itemdef that shooter doesn't allow -- Manually add extra fields to itemdef that shooter doesn't allow
-- Also modify the _loaded variant -- Also modify the _loaded variant
local overrides = { local overrides = {
on_place = on_rclick,
on_secondary_use = on_rclick, on_secondary_use = on_rclick,
wield_scale = vector.new(2, 2, 1.5) wield_scale = vector.new(2, 2, 1.5)
} }