Invert the meaning of screwdriver Sneak for doors
parent
5f37eaa95e
commit
b5aa07dbe3
|
@ -103,6 +103,10 @@ Action groups:
|
||||||
* `flora`: This is a plant that spreads on Dirt with Grass
|
* `flora`: This is a plant that spreads on Dirt with Grass
|
||||||
* `soil`: Usable by hoe
|
* `soil`: Usable by hoe
|
||||||
* `not_in_craft_guide`: Item won't appear in craft guide
|
* `not_in_craft_guide`: Item won't appear in craft guide
|
||||||
|
* `rotation_takes_precedence=1`: Group for nodes. Normally, if rotation tool (e.g. screwdriver) is "placed"
|
||||||
|
on this node, the `on_rightclick` action takes precedence, and the rotation action is used when Sneak
|
||||||
|
key is held. But if this group is set, it's the other way around: The rotation action is executed
|
||||||
|
by default and if Sneak is pressed, `on_rightclick` is executed instead
|
||||||
|
|
||||||
Legacy groups:
|
Legacy groups:
|
||||||
* `flammable`: Considered flammable (Note: This game has no fire)
|
* `flammable`: Considered flammable (Note: This game has no fire)
|
||||||
|
|
|
@ -891,6 +891,7 @@ function doors.register_door( name, def )
|
||||||
def.drop = name
|
def.drop = name
|
||||||
def.groups.not_in_creative_inventory = 1
|
def.groups.not_in_creative_inventory = 1
|
||||||
def.groups.door = 1
|
def.groups.door = 1
|
||||||
|
def.groups.rotation_takes_precedence = 1
|
||||||
|
|
||||||
-- define the crafting recipe
|
-- define the crafting recipe
|
||||||
|
|
||||||
|
@ -1063,6 +1064,7 @@ function doors.register_trapdoor( name, def )
|
||||||
def.groups = {}
|
def.groups = {}
|
||||||
end
|
end
|
||||||
def.groups.trapdoor = 1
|
def.groups.trapdoor = 1
|
||||||
|
def.groups.rotation_takes_precedence = 1
|
||||||
|
|
||||||
-- define the opening/closing sounds
|
-- define the opening/closing sounds
|
||||||
|
|
||||||
|
|
|
@ -104,8 +104,22 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses)
|
||||||
if not ndef then
|
if not ndef then
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Execute `on_rightclick` of node if present and player did not press Sneak,
|
||||||
|
-- otherwise, the rotation action is executed.
|
||||||
|
-- If `rotation_takes_precedence=1` group is present, this behavior is flipped:
|
||||||
|
-- `on_rightclick` executed if sneak pressed, rotation action executed if sneak
|
||||||
|
-- not pressed.
|
||||||
|
local prec = minetest.get_item_group(node.name, "rotation_takes_precedence") == 1
|
||||||
|
local sneak = false
|
||||||
|
if user then
|
||||||
|
sneak = user:get_player_control().sneak
|
||||||
|
if prec then
|
||||||
|
sneak = not sneak
|
||||||
|
end
|
||||||
|
end
|
||||||
if mode == screwdriver.ROTATE_AXIS and ndef and ndef.on_rightclick and
|
if mode == screwdriver.ROTATE_AXIS and ndef and ndef.on_rightclick and
|
||||||
((not user) or (user and not user:get_player_control().sneak)) then
|
((not user) or (not sneak)) then
|
||||||
return ndef.on_rightclick(pos, node, user, itemstack,
|
return ndef.on_rightclick(pos, node, user, itemstack,
|
||||||
pointed_thing) or itemstack
|
pointed_thing) or itemstack
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue