Add "Teleport mode" to ta4 move and ta5 fly controller
This commit is contained in:
parent
b2ad9f3058
commit
a932296420
@ -86,9 +86,12 @@ Available worlds will be converted to 'lsqlite3', but there is no way back, so:
|
||||
|
||||
**Never disable 'lsqlite3' for a world that has already been used!**
|
||||
|
||||
|
||||
### History
|
||||
|
||||
**2023-04-10 V1.13**
|
||||
|
||||
- Add "Teleport mode" to ta4 move and ta5 fly controller
|
||||
|
||||
**2023-04-01 V1.12**
|
||||
|
||||
- Improve Transformer:
|
||||
|
@ -56,10 +56,12 @@ local function set_node(item, playername)
|
||||
return
|
||||
elseif ndef2.buildable_to then
|
||||
local meta = M(dest_pos)
|
||||
minetest.set_node(dest_pos, {name=name, param2=param2})
|
||||
meta:from_table(item.metadata or {})
|
||||
meta:set_string("ta_move_block", "")
|
||||
meta:set_int("ta_door_locked", 1)
|
||||
if name ~= "techage:moveblock" then
|
||||
minetest.set_node(dest_pos, {name=name, param2=param2})
|
||||
meta:from_table(item.metadata or {})
|
||||
meta:set_string("ta_move_block", "")
|
||||
meta:set_int("ta_door_locked", 1)
|
||||
end
|
||||
return
|
||||
end
|
||||
local meta = M(dest_pos)
|
||||
@ -68,7 +70,9 @@ local function set_node(item, playername)
|
||||
return
|
||||
end
|
||||
elseif ndef1 then
|
||||
minetest.add_item(dest_pos, ItemStack(name))
|
||||
if name ~= "techage:moveblock" then
|
||||
minetest.add_item(dest_pos, ItemStack(name))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -606,6 +610,10 @@ local function move_node(pos, meta, pos1, lmove, max_speed, height)
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Default Move Mode
|
||||
--
|
||||
|
||||
-- Move the nodes from nvm.lpos1 to nvm.lpos2
|
||||
-- * nvm.lpos1 is a list of nodes
|
||||
-- * lmove is the movement as a list of `moves`
|
||||
@ -695,6 +703,86 @@ local function move_nodes(pos, meta, lpos1, move, max_speed, height)
|
||||
return true, lpos2
|
||||
end
|
||||
|
||||
--
|
||||
-- Teleport Mode
|
||||
--
|
||||
local function is_player_available(lpos1)
|
||||
if #lpos1 == 1 then
|
||||
for _, obj in pairs(minetest.get_objects_inside_radius(lpos1[1], 0.9)) do
|
||||
if obj:is_player() then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function teleport(base_pos, pos1, pos2, meta, owner, lmove, max_speed)
|
||||
if not minetest.is_protected(pos1, owner) and not minetest.is_protected(pos2, owner) then
|
||||
local node1 = techage.get_node_lvm(pos1)
|
||||
local node2 = techage.get_node_lvm(pos2)
|
||||
if techage.is_air_like(node1.name) and techage.is_air_like(node2.name) then
|
||||
minetest.swap_node(pos1, {name = "techage:moveblock", param2 = 0})
|
||||
if move_node(base_pos, meta, pos1, lmove, max_speed, 0) == false then
|
||||
meta:set_string("status", S("No valid start position"))
|
||||
return false
|
||||
end
|
||||
else
|
||||
if not techage.is_air_like(node1.name) then
|
||||
meta:set_string("status", S("No valid start position"))
|
||||
else
|
||||
meta:set_string("status", S("No valid destination position"))
|
||||
end
|
||||
return false
|
||||
end
|
||||
else
|
||||
if minetest.is_protected(pos1, owner) then
|
||||
meta:set_string("status", S("Start position is protected"))
|
||||
else
|
||||
meta:set_string("status", S("Destination position is protected"))
|
||||
end
|
||||
return false
|
||||
end
|
||||
meta:set_string("status", S("Running"))
|
||||
return true
|
||||
end
|
||||
|
||||
-- Move the player from nvm.lpos1 to nvm.lpos2
|
||||
-- * nvm.lpos1 is a list of length one(!) with the not to be moved block below the player
|
||||
-- * lmove is the movement as a list of `moves`
|
||||
-- * pos, meta, and nvm are controller block related
|
||||
local function multi_teleport_player(base_pos, meta, nvm, lmove, max_speed, move2to1)
|
||||
local owner = meta:get_string("owner")
|
||||
techage.counting_add(owner, #lmove, #nvm.lpos1 * #lmove)
|
||||
|
||||
local pos1 = vector.add(nvm.lpos1[1], {x=0, y=1, z=0})
|
||||
local pos2 = vector.add(nvm.lpos2[1], {x=0, y=1, z=0})
|
||||
|
||||
if move2to1 then
|
||||
pos1, pos2 = pos2, pos1
|
||||
end
|
||||
|
||||
return teleport(base_pos, pos1, pos2, meta, owner, lmove, max_speed)
|
||||
end
|
||||
|
||||
-- Move the player from lpos1 to lpos2.
|
||||
-- * lpos1 is a list of length one(!) with the not to be moved block below the player
|
||||
-- * lpos2 = lpos1 + move
|
||||
-- * pos and meta are controller block related
|
||||
local function teleport_player(base_pos, meta, lpos1, move, max_speed)
|
||||
local owner = meta:get_string("owner")
|
||||
lpos1 = lpos1 or {}
|
||||
techage.counting_add(owner, #lpos1)
|
||||
|
||||
local pos1 = vector.add(lpos1[1], {x=0, y=1, z=0})
|
||||
local pos2 = vector.add(pos1, move)
|
||||
|
||||
return teleport(base_pos, pos1, pos2, meta, owner, {move}, max_speed), nil
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------
|
||||
-- API
|
||||
--------------------------------------------------------------------------------------
|
||||
|
||||
-- move2to1 is the direction and is true for 'from pos2 to pos1'
|
||||
-- Move path and other data is stored as meta data of pos
|
||||
function flylib.move_to_other_pos(pos, move2to1)
|
||||
@ -703,6 +791,7 @@ function flylib.move_to_other_pos(pos, move2to1)
|
||||
local lmove, err = flylib.to_path(meta:get_string("path")) or {}
|
||||
local max_speed = meta:contains("max_speed") and meta:get_int("max_speed") or MAX_SPEED
|
||||
local height = meta:contains("height") and meta:get_float("height") or 1
|
||||
local teleport_mode = meta:get_string("teleport_mode") == "enable"
|
||||
|
||||
if err or nvm.running then return false end
|
||||
|
||||
@ -716,8 +805,13 @@ function flylib.move_to_other_pos(pos, move2to1)
|
||||
end
|
||||
-- calc destination positions
|
||||
nvm.lpos2 = lvect_add_vec(nvm.lpos1, offs)
|
||||
local lpos = move2to1 and nvm.lpos2 or nvm.lpos1
|
||||
|
||||
nvm.running = multi_move_nodes(pos, meta, nvm, lmove, max_speed, height, move2to1)
|
||||
if teleport_mode and is_player_available(lpos) then
|
||||
nvm.running = multi_teleport_player(pos, meta, nvm, lmove, max_speed, move2to1)
|
||||
elseif not teleport_mode then
|
||||
nvm.running = multi_move_nodes(pos, meta, nvm, lmove, max_speed, height, move2to1)
|
||||
end
|
||||
nvm.moveBA = nvm.running and not move2to1
|
||||
return nvm.running
|
||||
end
|
||||
@ -728,10 +822,15 @@ function flylib.move_to(pos, move)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local height = techage.in_range(meta:contains("height") and meta:get_float("height") or 1, 0, 1)
|
||||
local max_speed = meta:contains("max_speed") and meta:get_int("max_speed") or MAX_SPEED
|
||||
local teleport_mode = meta:get_string("teleport_mode") == "enable"
|
||||
|
||||
if nvm.running then return false end
|
||||
|
||||
nvm.running, nvm.lastpos = move_nodes(pos, meta, nvm.lastpos or nvm.lpos1, move, max_speed, height)
|
||||
if teleport_mode and is_player_available(nvm.lpos1) then
|
||||
nvm.running, nvm.lastpos = teleport_player(pos, meta, nvm.lastpos or nvm.lpos1, move, max_speed)
|
||||
elseif not teleport_mode then
|
||||
nvm.running, nvm.lastpos = move_nodes(pos, meta, nvm.lastpos or nvm.lpos1, move, max_speed, height)
|
||||
end
|
||||
return nvm.running
|
||||
end
|
||||
|
||||
@ -742,6 +841,7 @@ function flylib.reset_move(pos)
|
||||
local max_speed = meta:contains("max_speed") and meta:get_int("max_speed") or MAX_SPEED
|
||||
|
||||
if nvm.running then return false end
|
||||
if meta:get_string("teleport_mode") == "enable" then return false end
|
||||
|
||||
if nvm.lpos1 and nvm.lpos1[1] then
|
||||
local move = vector.subtract(nvm.lpos1[1], (nvm.lastpos or nvm.lpos1)[1])
|
||||
|
@ -1721,7 +1721,7 @@ techage.manual_DE.aText = {
|
||||
"\n"..
|
||||
"Anleitung:\n"..
|
||||
"\n"..
|
||||
" - Controller setzen und die Blöcke\\, die bewegt werden sollen\\, über das Menü an-trainieren (Es können bis zu 16 Blöcke an-trainiert werden)\n"..
|
||||
" - Controller setzen und die Blöcke\\, die bewegt werden sollen\\, über das Menü (Taste \"Aufzeichnen\") an-trainieren (Es können bis zu 16 Blöcke an-trainiert werden)\n"..
|
||||
" - die \"Flugstrecke\" muss über eine x\\,y\\,z Angabe (relativ) eingegeben werden (die maximale Distanz (x+y+z) beträgt 200 m)\n"..
|
||||
" - mit den Menü-Tasten \"Bewege A-B\" sowie \"Bewege B-A\" kann die Bewegung getestet werden\n"..
|
||||
" - man kann auch durch Wände oder andere Blöcke fliegen\n"..
|
||||
@ -1738,6 +1738,10 @@ techage.manual_DE.aText = {
|
||||
" - 'move2' Beim Kommando muss zusätzlich die Flugstrecke als x\\,y\\,z Vektor angegeben werden.\nBeispiel Lua Controller: '$send_cmnd(MOVE_CTLR\\, \"move2\"\\, \"0\\,12\\,0\")'\n"..
|
||||
" - 'reset' Block/Blöcke zurück in Startposition bewegen\n"..
|
||||
"\n"..
|
||||
"*Teleport Mode*\n"..
|
||||
"\n"..
|
||||
"Wird der 'Teleport Mode' aktiviert\\, kann ein Spieler auch ohne Blöcke bewegt werden. Dazu muss die Startposition über die Taste \"Aufzeichnen\" konfiguriert werden. Es kann hier nur eine Position konfiguriert werden. Das Spieler der bewegt werden soll\\, muss dazu auf dieser Position stehen.\n"..
|
||||
"\n"..
|
||||
"*Wichtige Hinweise:*\n"..
|
||||
"\n"..
|
||||
" - Sofern mehrere Blöcke bewegt werden sollen\\, muss der Block\\, der die Spieler/Mobs mitnehmen soll\\, beim Antrainieren als erstes angeklickt werden.\n"..
|
||||
|
@ -1745,6 +1745,10 @@ techage.manual_EN.aText = {
|
||||
" - 'move2' With the command\\, the flight route must also be specified as an x\\,y\\,z vector.\nExample Lua Controller: '$send_cmnd(MOVE_CTLR\\, \"move2\"\\, \"0\\,12\\,0\")'\n"..
|
||||
" - 'reset' move block(s) back to start position\n"..
|
||||
"\n"..
|
||||
"*Teleport mode*\n"..
|
||||
"\n"..
|
||||
"If the 'Teleport Mode' is enabled\\, a player can also be moved without blocks. To do this\\, the start position must be configured using the \"Record\" button. Only one position can be configured here. The player to be moved must be in that position.\n"..
|
||||
"\n"..
|
||||
"*Important instructions:*\n"..
|
||||
"\n"..
|
||||
" - If several blocks are to be moved\\, the block that is to take the players/mobs must be clicked first when training.\n"..
|
||||
|
@ -137,14 +137,6 @@ techage.furnace.register_recipe({
|
||||
time = 4,
|
||||
})
|
||||
|
||||
techage.furnace.register_recipe({
|
||||
output = "techage:moveblock",
|
||||
recipe = {
|
||||
"techage:sieved_basalt_gravel",
|
||||
},
|
||||
time = 4,
|
||||
})
|
||||
|
||||
techage.furnace.register_recipe({
|
||||
output = "basic_materials:concrete_block 4",
|
||||
recipe = {
|
||||
|
2
init.lua
2
init.lua
@ -13,7 +13,7 @@
|
||||
techage = {}
|
||||
|
||||
-- Version for compatibility checks, see readme.md/history
|
||||
techage.version = 1.12
|
||||
techage.version = 1.13
|
||||
|
||||
if minetest.global_exists("tubelib") then
|
||||
minetest.log("error", "[techage] Techage can't be used together with the mod tubelib!")
|
||||
|
@ -484,6 +484,7 @@ Destination position is protected=Zielposition ist geschützt
|
||||
Error: Max. length of the flight route exceeded by @1 blocks !!=Fehler: max. Länge der Flugstrecke um @1 Blöcke überschritten !!
|
||||
No valid destination position=Keine gültige Zielposition
|
||||
No valid node at the start position=Kein gültiger Block an der Startposition
|
||||
No valid start position=Keine gültige Startposition
|
||||
Running=In Betrieb
|
||||
Start position is protected=Startposition ist geschützt
|
||||
Stopped=Gestoppt
|
||||
@ -519,9 +520,11 @@ Maximum speed for moving blocks=Maximale Geschwindigkeit für bewegliche Blöcke
|
||||
Move=Bewege
|
||||
Move A-B=Bewege A-B
|
||||
Move B-A=Bewege B-A
|
||||
Move a player without moving blocks=Bewege einen Spieler ohne Blöcke
|
||||
Move block height=Move Block Höhe
|
||||
Object offset=Objekt Offset
|
||||
Stored=Gespeichert
|
||||
Teleport mode=Teleport Mode
|
||||
Value in the range of 0.0 to 1.0=Wert im Bereich von 0.0 bis 1.0
|
||||
Y-offset for non-player objects like vehicles (-0.5 to 0.5)=Y-Offset für Nicht-Spieler Objekte wie Fahrzeuge (-0.5 bis 0.5)
|
||||
|
||||
|
@ -484,6 +484,7 @@ Destination position is protected=
|
||||
Error: Max. length of the flight route exceeded by @1 blocks !!=
|
||||
No valid destination position=
|
||||
No valid node at the start position=
|
||||
No valid start position=
|
||||
Running=
|
||||
Start position is protected=
|
||||
Stopped=
|
||||
@ -519,9 +520,11 @@ Maximum speed for moving blocks=
|
||||
Move=
|
||||
Move A-B=
|
||||
Move B-A=
|
||||
Move a player without moving blocks=
|
||||
Move block height=
|
||||
Object offset=
|
||||
Stored=
|
||||
Teleport mode=
|
||||
Value in the range of 0.0 to 1.0=
|
||||
Y-offset for non-player objects like vehicles (-0.5 to 0.5)=
|
||||
|
||||
|
@ -95,7 +95,7 @@ minetest.register_node("techage:ta3_mesecons_converter", {
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
mesecon.on_placenode(pos, minetest.get_node(pos))
|
||||
end,
|
||||
|
||||
|
||||
on_receive_fields = on_receive_fields,
|
||||
on_timer = on_timer,
|
||||
techage_set_numbers = techage_set_numbers,
|
||||
|
@ -578,7 +578,7 @@ Da die bewegten Blöcke Spieler und Mobs mitnehmen können, die auf dem Block st
|
||||
|
||||
Anleitung:
|
||||
|
||||
- Controller setzen und die Blöcke, die bewegt werden sollen, über das Menü an-trainieren (Es können bis zu 16 Blöcke an-trainiert werden)
|
||||
- Controller setzen und die Blöcke, die bewegt werden sollen, über das Menü (Taste "Aufzeichnen") an-trainieren (Es können bis zu 16 Blöcke an-trainiert werden)
|
||||
- die "Flugstrecke" muss über eine x,y,z Angabe (relativ) eingegeben werden (die maximale Distanz (x+y+z) beträgt 200 m)
|
||||
- mit den Menü-Tasten "Bewege A-B" sowie "Bewege B-A" kann die Bewegung getestet werden
|
||||
- man kann auch durch Wände oder andere Blöcke fliegen
|
||||
@ -596,6 +596,10 @@ Der Move Controller unterstützt folgende techage Kommandos:
|
||||
Beispiel Lua Controller: `$send_cmnd(MOVE_CTLR, "move2", "0,12,0")`
|
||||
- `reset` Block/Blöcke zurück in Startposition bewegen
|
||||
|
||||
**Teleport Mode**
|
||||
|
||||
Wird der `Teleport Mode` aktiviert (auf `enable` gesetzt), kann ein Spieler auch ohne Blöcke bewegt werden. Dazu muss die Startposition über die Taste "Aufzeichnen" konfiguriert werden. Es kann hier nur eine Position konfiguriert werden. Das Spieler, der bewegt werden soll, muss dazu auf dieser Position stehen.
|
||||
|
||||
**Wichtige Hinweise:**
|
||||
|
||||
- Sofern mehrere Blöcke bewegt werden sollen, muss der Block, der die Spieler/Mobs mitnehmen soll, beim Antrainieren als erstes angeklickt werden.
|
||||
|
@ -585,6 +585,10 @@ You can switch to the `move xyz` operating mode via the wrench menu. After switc
|
||||
Example Lua Controller: `$send_cmnd(MOVE_CTLR, "move2", "0,12,0")`
|
||||
- `reset` move block(s) back to start position
|
||||
|
||||
**Teleport mode**
|
||||
|
||||
If the 'Teleport Mode' is enabled, a player can also be moved without blocks. To do this, the start position must be configured using the "Record" button. Only one position can be configured here. The player to be moved must be in that position.
|
||||
|
||||
**Important instructions:**
|
||||
|
||||
- If several blocks are to be moved, the block that is to take the players/mobs must be clicked first when training.
|
||||
|
@ -49,6 +49,14 @@ local WRENCH_MENU = {
|
||||
tooltip = S("Y-offset for non-player objects like vehicles (-0.5 to 0.5)"),
|
||||
default = "0.0",
|
||||
},
|
||||
{
|
||||
type = "dropdown",
|
||||
choices = "disable,enable",
|
||||
name = "teleport_mode",
|
||||
label = S("Teleport mode"),
|
||||
tooltip = S("Move a player without moving blocks"),
|
||||
default = "disable",
|
||||
},
|
||||
}
|
||||
|
||||
local function formspec(nvm, meta)
|
||||
|
@ -56,6 +56,14 @@ local WRENCH_MENU = {
|
||||
tooltip = S("Switch to the remote controlled 'move xyz' mode"),
|
||||
default = "A-B / B-A",
|
||||
},
|
||||
{
|
||||
type = "dropdown",
|
||||
choices = "disable,enable",
|
||||
name = "teleport_mode",
|
||||
label = S("Teleport mode"),
|
||||
tooltip = S("Move a player without moving blocks"),
|
||||
default = "disable",
|
||||
},
|
||||
}
|
||||
|
||||
local function formspec(nvm, meta)
|
||||
@ -310,7 +318,7 @@ minetest.register_node("techage:moveblock", {
|
||||
walkable = false,
|
||||
pointable = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 3, oddly_breakable_by_hand = 3},
|
||||
groups = {cracky = 3, oddly_breakable_by_hand = 3, not_in_creative_inventory = 1},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user