Improve door and fly controller

This commit is contained in:
Joachim Stolberg 2025-01-04 10:58:59 +01:00
parent 17d04dec6f
commit 46bb406cae
3 changed files with 19 additions and 15 deletions

View File

@ -863,19 +863,21 @@ function flylib.reset_move(pos)
if nvm.running then return false end if nvm.running then return false end
if meta:get_string("teleport_mode") == "enable" then return false end if meta:get_string("teleport_mode") == "enable" then return false end
if nvm.moveBA then -- A/B mode has no nvm.lastpos if meta:get_string("opmode") == "move xyz" then
if nvm.lpos2 and nvm.lpos2[1] then
local move = vector.subtract(nvm.lpos2[1], nvm.lpos1[1])
nvm.running, nvm.lastpos = move_nodes(pos, meta, nvm.lpos2, move, max_speed, height)
return nvm.running
end
else
if nvm.lpos1 and nvm.lpos1[1] then if nvm.lpos1 and nvm.lpos1[1] then
local move = vector.subtract(nvm.lpos1[1], (nvm.lastpos or nvm.lpos2)[1]) local move = vector.subtract(nvm.lpos1[1], (nvm.lastpos or nvm.lpos2)[1])
local lpos = nvm.lastpos or nvm.lpos1 local lpos = nvm.lastpos or nvm.lpos1
nvm.running, nvm.lastpos = move_nodes(pos, meta, lpos, move, max_speed, height) nvm.running, nvm.lastpos = move_nodes(pos, meta, lpos, move, max_speed, height)
return nvm.running return nvm.running
end end
else
if nvm.moveBA then
if nvm.lpos1 and nvm.lpos1[1] and nvm.lpos2 and nvm.lpos2[1] then
local move = vector.subtract(nvm.lpos1[1], nvm.lpos2[1])
nvm.running, _ = move_nodes(pos, meta, nvm.lpos2, move, max_speed, height)
return nvm.running
end
end
end end
return false return false
end end

View File

@ -93,11 +93,11 @@ local function formspec1(nvm, meta)
local play_sound = dump(nvm.play_sound or false) local play_sound = dump(nvm.play_sound or false)
return "size[8,7]".. return "size[8,7]"..
"tabheader[0,0;tab;"..S("Ctrl,Inv")..";1;;true]".. "tabheader[0,0;tab;"..S("Ctrl,Inv")..";1;;true]"..
"button[0.7,0.0;3,1;record;"..S("Record").."]".. "button_exit[0.7,0.0;3,1;record;"..S("Record").."]"..
"button[4.3,0.0;3,1;ready;"..S("Done").."]".. "button[4.3,0.0;3,1;ready;"..S("Done").."]"..
"button[0.7,0.9;3,1;reset;"..S("Reset").."]".. "button_exit[0.7,0.9;3,1;reset;"..S("Reset").."]"..
"button[4.3,0.9;3,1;exchange;"..S("Exchange").."]".. "button_exit[4.3,0.9;3,1;exchange;"..S("Exchange").."]"..
"button[0.7,1.8;3,1;show;"..S("Show positions").."]".. "button_exit[0.7,1.8;3,1;show;"..S("Show positions").."]"..
"checkbox[4.3,1.8;play_sound;"..S("with door sound")..";"..play_sound.."]".. "checkbox[4.3,1.8;play_sound;"..S("with door sound")..";"..play_sound.."]"..
"label[0.5,2.8;"..status.."]".. "label[0.5,2.8;"..status.."]"..
"list[current_player;main;0,3.3;8,4;]" "list[current_player;main;0,3.3;8,4;]"

View File

@ -66,13 +66,13 @@ local function formspec(nvm, meta)
buttons = "field[0.4,2.3;3.8,1;path;" .. S("Move distance") .. ";" .. path .. "]" .. buttons = "field[0.4,2.3;3.8,1;path;" .. S("Move distance") .. ";" .. path .. "]" ..
"button_exit[4.1,2.0;3.8,1;move2;" .. S("Move") .. "]" .. "button_exit[4.1,2.0;3.8,1;move2;" .. S("Move") .. "]" ..
"button_exit[0.1,3.0;3.8,1;reset;" .. S("Reset") .. "]" .. "button_exit[0.1,3.0;3.8,1;reset;" .. S("Reset") .. "]" ..
"button[4.1,3.0;3.8,1;show;" .. S("Show positions") .. "]" "button_exit[4.1,3.0;3.8,1;show;" .. S("Show positions") .. "]"
else else
buttons = "field[0.4,2.3;3.8,1;path;" .. S("Move distance (A to B)") .. ";" .. path .. "]" .. buttons = "field[0.4,2.3;3.8,1;path;" .. S("Move distance (A to B)") .. ";" .. path .. "]" ..
"button_exit[0.1,3.0;3.8,1;moveAB;" .. S("Move A-B") .. "]" .. "button_exit[0.1,3.0;3.8,1;moveAB;" .. S("Move A-B") .. "]" ..
"button_exit[4.1,3.0;3.8,1;moveBA;" .. S("Move B-A") .. "]" .. "button_exit[4.1,3.0;3.8,1;moveBA;" .. S("Move B-A") .. "]" ..
"button[4.1,2.0;3.8,1;store;" .. S("Store") .. "]" .. "button[4.1,2.0;3.8,1;store;" .. S("Store") .. "]" ..
"button[0.1,4.0;3.8,1;show;" .. S("Show positions") .. "]" .. "button_exit[0.1,4.0;3.8,1;show;" .. S("Show positions") .. "]" ..
"button_exit[4.1,4.0;3.8,1;reset;" .. S("Reset") .. "]" "button_exit[4.1,4.0;3.8,1;reset;" .. S("Reset") .. "]"
end end
return "size[8,5.5]" .. return "size[8,5.5]" ..
@ -82,7 +82,7 @@ local function formspec(nvm, meta)
"box[0,-0.1;7.2,0.5;#c6e8ff]" .. "box[0,-0.1;7.2,0.5;#c6e8ff]" ..
"label[0.2,-0.1;" .. minetest.colorize( "#000000", S("TA4 Move Controller")) .. "]" .. "label[0.2,-0.1;" .. minetest.colorize( "#000000", S("TA4 Move Controller")) .. "]" ..
techage.wrench_image(7.4, -0.05) .. techage.wrench_image(7.4, -0.05) ..
"button[0.1,0.7;3.8,1;record;" .. S("Record") .. "]" .. "button_exit[0.1,0.7;3.8,1;record;" .. S("Record") .. "]" ..
"button[4.1,0.7;3.8,1;done;" .. S("Done") .. "]" .. "button[4.1,0.7;3.8,1;done;" .. S("Done") .. "]" ..
buttons .. buttons ..
"label[0.3,5.0;" .. status .. "]" "label[0.3,5.0;" .. status .. "]"
@ -117,6 +117,7 @@ minetest.register_node("techage:ta4_movecontroller", {
nvm.lpos1 = {} nvm.lpos1 = {}
nvm.lpos2 = {} nvm.lpos2 = {}
nvm.moveBA = false nvm.moveBA = false
nvm.recording = true
nvm.running = nil nvm.running = nil
nvm.lastpos = nil nvm.lastpos = nil
meta:set_string("status", S("Recording...")) meta:set_string("status", S("Recording..."))
@ -125,7 +126,8 @@ minetest.register_node("techage:ta4_movecontroller", {
mark.unmark_all(name) mark.unmark_all(name)
mark.start(name, MAX_BLOCKS) mark.start(name, MAX_BLOCKS)
meta:set_string("formspec", formspec(nvm, meta)) meta:set_string("formspec", formspec(nvm, meta))
elseif fields.done then elseif fields.done and nvm.recording then
nvm.recording = false
local name = player:get_player_name() local name = player:get_player_name()
local pos_list = mark.get_poslist(name) local pos_list = mark.get_poslist(name)
if fly.to_vector(fields.path or "", MAX_DIST) then if fly.to_vector(fields.path or "", MAX_DIST) then