Allow to turn the pusher with the new screwdriver

This commit is contained in:
Joachim Stolberg 2022-01-05 21:41:30 +01:00
parent d7f0dbc50d
commit ca8929fa9d
8 changed files with 41 additions and 22 deletions

View File

@ -229,6 +229,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState
on_metadata_inventory_move = tNode.on_metadata_inventory_move,
on_metadata_inventory_put = tNode.on_metadata_inventory_put,
on_metadata_inventory_take = tNode.on_metadata_inventory_take,
ta_rotate_node = tNode.ta_rotate_node,
paramtype = tNode.paramtype,
paramtype2 = "facedir",
@ -269,6 +270,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState
on_metadata_inventory_move = tNode.on_metadata_inventory_move,
on_metadata_inventory_put = tNode.on_metadata_inventory_put,
on_metadata_inventory_take = tNode.on_metadata_inventory_take,
ta_rotate_node = tNode.ta_rotate_node,
paramtype = tNode.paramtype,
paramtype2 = "facedir",

View File

@ -197,7 +197,7 @@ local tiles = {}
-- '{power}' will be replaced by the power PNG
tiles.pas = {
"techage_filling_ta#.png^techage_frame_ta#_top.png^techage_appl_arrow.png",
"techage_filling_ta#.png^techage_frame_ta#.png",
"techage_filling_ta#.png^techage_frame_ta#_bottom.png^techage_appl_arrow.png",
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png",
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png",
"techage_appl_pusher.png^[transformR180]^techage_frame_ta#.png",
@ -206,7 +206,7 @@ tiles.pas = {
tiles.act = {
-- up, down, right, left, back, front
"techage_filling_ta#.png^techage_frame_ta#_top.png^techage_appl_arrow.png",
"techage_filling_ta#.png^techage_frame_ta#.png",
"techage_filling_ta#.png^techage_frame_ta#_bottom.png^techage_appl_arrow.png",
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png",
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png",
{
@ -277,7 +277,14 @@ local node_name_ta2, node_name_ta3, node_name_ta4 =
M(pos):set_string("formspec", ta4_formspec(CRD(pos).State, pos, nvm))
end
end,
ta_rotate_node = function(pos, node, new_param2)
Tube:after_dig_node(pos)
minetest.swap_node(pos, {name = node.name, param2 = new_param2})
Tube:after_place_node(pos)
local meta = M(pos)
meta:set_int("pull_dir", techage.side_to_outdir("L", new_param2))
meta:set_int("push_dir", techage.side_to_outdir("R", new_param2))
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take,
on_rightclick = on_rightclick,

View File

@ -28,6 +28,7 @@ local NodeDef = techage.NodeDef
local Tube = techage.Tube
local is_cart_available = minecart.is_nodecart_available
local techage_counting_hit = techage.counting_hit
local tubelib2_side_to_dir = tubelib2.side_to_dir
-------------------------------------------------------------------
-- Database
@ -125,11 +126,7 @@ end
local SideToDir = {B=1, R=2, F=3, L=4, D=5, U=6}
local function side_to_dir(side, param2)
local dir = SideToDir[side]
if dir < 5 then
dir = (((dir - 1) + (param2 % 4)) % 4) + 1
end
return dir
return tubelib2_side_to_dir(side, param2)
end
techage.side_to_outdir = side_to_dir

View File

@ -24,8 +24,8 @@ elseif minetest.global_exists("ironage") then
elseif minetest.global_exists("techpack") then
minetest.log("error", "[techage] Techage can't be used together with the modpack techpack!")
return
elseif minetest.global_exists("tubelib2") and tubelib2.version < 1.9 then
minetest.log("error", "[techage] Techage requires tubelib2 version 1.9 or newer!")
elseif minetest.global_exists("tubelib2") and tubelib2.version < 2.2 then
minetest.log("error", "[techage] Techage requires tubelib2 version 2.2 or newer!")
return
elseif minetest.global_exists("minecart") and minecart.version < 1.08 then
minetest.log("error", "[techage] Techage requires minecart version 1.08 or newer!")

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

View File

@ -41,14 +41,13 @@ local function base_checks(user, pointed_thing)
return false
end
if ndef.on_rotate == screwdriver.disallow then
if ndef.on_rotate == screwdriver.disallow and not ndef.ta_rotate_node then
return false
end
local yaw = user:get_look_horizontal()
local dir = minetest.yaw_to_dir(yaw)
local facedir = minetest.dir_to_facedir(dir)
print("base_checks", facedir, ndef.paramtype2)
return true, pos, player_name, facedir, node, ndef
end
@ -59,22 +58,36 @@ local function store_node_param2(user, node)
minetest.chat_send_player(user:get_player_name(), S("Block alignment stored!"))
end
local function turn_node_param2(pos, node, user)
local function turn_node_param2(pos, node, ndef, user)
local param2 = user:get_meta():get_string("techage_screwdriver_param2")
minetest.swap_node(pos, {name = node.name, param2 = param2})
if ndef.ta_rotate_node then
ndef.ta_rotate_node(pos, node, param2)
else
minetest.swap_node(pos, {name = node.name, param2 = param2})
minetest.check_for_falling(pos)
end
end
local function turn_left(pos, node)
local function turn_left(pos, node, ndef)
local param2 = techage.param2_turn_left(node.param2)
minetest.swap_node(pos, {name = node.name, param2 = param2})
if ndef.ta_rotate_node then
ndef.ta_rotate_node(pos, node, param2)
else
minetest.swap_node(pos, {name = node.name, param2 = param2})
minetest.check_for_falling(pos)
end
end
local function turn_up(pos, node, facedir)
local function turn_up(pos, node, ndef, facedir)
local param2 = techage.param2_turn_up(facedir, node.param2)
minetest.swap_node(pos, {name = node.name, param2 = param2})
if ndef.ta_rotate_node then
ndef.ta_rotate_node(pos, node, param2)
else
minetest.swap_node(pos, {name = node.name, param2 = param2})
minetest.check_for_falling(pos)
end
end
-- on_use == on_left_click == turn left
local function on_use(itemstack, user, pointed_thing)
local res, pos, player_name, facedir, node, ndef = base_checks(user, pointed_thing)
@ -83,7 +96,7 @@ local function on_use(itemstack, user, pointed_thing)
if user:get_player_control().sneak then
store_node_param2(user, node)
else
turn_left(pos, node)
turn_left(pos, node, ndef)
end
else
return screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_FACE, USES)
@ -103,9 +116,9 @@ local function on_place(itemstack, user, pointed_thing)
if ndef.paramtype2 == "facedir" then
if ndef.on_rotate ~= screwdriver.rotate_simple then
if user:get_player_control().sneak then
turn_node_param2(pos, node, user)
turn_node_param2(pos, node, ndef, user)
else
turn_up(pos, node, facedir)
turn_up(pos, node, ndef, facedir)
end
else
return itemstack