Improve recording for move/fly/turn controllers

This commit is contained in:
Joachim Stolberg 2024-07-13 11:41:13 +02:00
parent 895b7895e6
commit a1485b6eab
4 changed files with 43 additions and 5 deletions

View File

@ -87,6 +87,14 @@ function marker.stop(name)
MaxNumber[name] = nil
end
minetest.register_on_leaveplayer(function(ObjectRef, timed_out)
if ObjectRef and ObjectRef:is_player() then
local name = ObjectRef:get_player_name()
marker.unmark_all(name)
end
end)
minetest.register_entity(":techage:block_marker", {
initial_properties = {
visual = "cube",

View File

@ -79,6 +79,16 @@ local function formspec(nvm, meta)
"label[0.3,6.3;" .. status .. "]"
end
local function reset_state(pos)
local meta = M(pos)
local nvm = techage.get_nvm(pos)
nvm.lpos1 = {}
nvm.lpos2 = {}
nvm.running = nil
nvm.moveBA = false
meta:set_string("status", "")
meta:set_string("formspec", formspec(nvm, meta))
end
minetest.register_node("techage:ta5_flycontroller", {
description = S("TA5 Fly Controller"),
@ -258,8 +268,7 @@ techage.register_node({"techage:ta5_flycontroller"}, {
return 2, ""
end,
on_node_load = function(pos, node)
local nvm = techage.get_nvm(pos)
nvm.running = false
reset_state(pos)
end,
})

View File

@ -85,6 +85,17 @@ local function formspec(nvm, meta)
"label[0.3,4.3;" .. status .. "]"
end
local function reset_state(pos)
local meta = M(pos)
local nvm = techage.get_nvm(pos)
nvm.lpos1 = {}
nvm.lpos2 = {}
nvm.running = nil
nvm.lastpos = nil
meta:set_string("status", "")
meta:set_string("formspec", formspec(nvm, meta))
end
minetest.register_node("techage:ta4_movecontroller", {
description = S("TA4 Move Controller"),
tiles = {
@ -261,9 +272,8 @@ techage.register_node({"techage:ta4_movecontroller"}, {
return 2, ""
end,
on_node_load = function(pos, node)
local nvm = techage.get_nvm(pos)
M(pos):set_string("teleport_mode", "") -- delete not working op mode
nvm.running = false
M(pos):set_string("teleport_mode", "") -- delete not working (legacy) op mode
reset_state(pos)
end,
})

View File

@ -38,6 +38,14 @@ local function formspec(nvm, meta)
"label[0.3,2.5;" .. status .. "]"
end
local function reset_state(pos)
local meta = M(pos)
local nvm = techage.get_nvm(pos)
nvm.lpos1 = {}
nvm.lpos2 = {}
meta:set_string("status", "")
meta:set_string("formspec", formspec(nvm, meta))
end
minetest.register_node("techage:ta4_turncontroller", {
description = S("TA4 Turn Controller"),
@ -193,6 +201,9 @@ techage.register_node({"techage:ta4_turncontroller"}, {
return 2
end
end,
on_node_load = function(pos, node)
reset_state(pos)
end,
})
minetest.register_craft({