Fix issue #193 (Move controller feature request)
This commit is contained in:
parent
d30f025225
commit
9cd9ab9f90
@ -151,7 +151,7 @@ local function trim(s)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function flylib.distance(v)
|
function flylib.distance(v)
|
||||||
return math.abs(v.x) + math.abs(v.y) + math.abs(v.z)
|
return math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z)
|
||||||
end
|
end
|
||||||
|
|
||||||
function flylib.to_vector(s, max_dist)
|
function flylib.to_vector(s, max_dist)
|
||||||
@ -160,7 +160,7 @@ function flylib.to_vector(s, max_dist)
|
|||||||
y = tonumber(y) or 0
|
y = tonumber(y) or 0
|
||||||
z = tonumber(z) or 0
|
z = tonumber(z) or 0
|
||||||
if x and y and z then
|
if x and y and z then
|
||||||
if not max_dist or (math.abs(x) + math.abs(y) + math.abs(z)) <= max_dist then
|
if not max_dist or flylib.distance({x = x, y = y, z = z}) <= max_dist then
|
||||||
return {x = x, y = y, z = z}
|
return {x = x, y = y, z = z}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -874,6 +874,26 @@ function flylib.move_to(pos, move)
|
|||||||
return nvm.running
|
return nvm.running
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- `pos` is the controller block position
|
||||||
|
-- `dest` is the destination position
|
||||||
|
-- `max_dist` is the maximum distance to the destination
|
||||||
|
function flylib.move_to_abs(pos, dest, max_dist)
|
||||||
|
local meta = M(pos)
|
||||||
|
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"
|
||||||
|
local pos1 = (nvm.lastpos or nvm.lpos1 or {})[1]
|
||||||
|
|
||||||
|
if nvm.running or not pos1 then return false end
|
||||||
|
local move = vector.subtract(dest, pos1)
|
||||||
|
if not max_dist or flylib.distance(move) <= max_dist then
|
||||||
|
nvm.running, nvm.lastpos = move_nodes(pos, meta, nvm.lastpos or nvm.lpos1, move, max_speed, height)
|
||||||
|
return nvm.running
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
function flylib.reset_move(pos)
|
function flylib.reset_move(pos)
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
|
@ -612,7 +612,7 @@ Da die bewegten Blöcke Spieler und Mobs mitnehmen können, die auf dem Block st
|
|||||||
Anleitung:
|
Anleitung:
|
||||||
|
|
||||||
- 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)
|
- 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)
|
- die "Flugstrecke" muss über eine x,y,z Angabe (relativ) eingegeben werden (die maximale Distanz beträgt 1000 m)
|
||||||
- mit den Menü-Tasten "Bewege A-B" sowie "Bewege B-A" kann die Bewegung getestet werden
|
- 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
|
- man kann auch durch Wände oder andere Blöcke fliegen
|
||||||
- auch die Zielposition für die Blöcke kann belegt sein. Die Blöcke werden in diesem Falle "unsichtbar" gespeichert. Dies ist für Schiebetüren und ähnliches gedacht
|
- auch die Zielposition für die Blöcke kann belegt sein. Die Blöcke werden in diesem Falle "unsichtbar" gespeichert. Dies ist für Schiebetüren und ähnliches gedacht
|
||||||
@ -627,11 +627,13 @@ Der Move Controller unterstützt folgende techage Kommandos:
|
|||||||
|
|
||||||
- `move2` Beim Kommando muss zusätzlich die Flugstrecke als x,y,z Vektor angegeben werden.
|
- `move2` Beim Kommando muss zusätzlich die Flugstrecke als x,y,z Vektor angegeben werden.
|
||||||
Beispiel Lua Controller: `$send_cmnd(MOVE_CTLR, "move2", "0,12,0")`
|
Beispiel Lua Controller: `$send_cmnd(MOVE_CTLR, "move2", "0,12,0")`
|
||||||
|
- `moveto` verschiebt Block an die angegebene Zielposition (die Zielposition bezieht sich auf den ersten markierten Block, die weiteren Blöcke werden relativ zu dieser Position verschoben)
|
||||||
- `reset` Block/Blöcke zurück in Startposition bewegen
|
- `reset` Block/Blöcke zurück in Startposition bewegen
|
||||||
|
|
||||||
**Wichtige Hinweise:**
|
**Wichtige Hinweise:**
|
||||||
|
|
||||||
- Sofern mehrere Blöcke bewegt werden sollen, muss der Block, der die Spieler/Mobs mitnehmen soll, beim Antrainieren als erstes angeklickt werden.
|
- Sofern mehrere Blöcke bewegt werden sollen, muss der Block, der die Spieler/Mobs mitnehmen soll, beim Antrainieren als erstes angeklickt werden.
|
||||||
|
- Wird das `moveto` Kommando genutzt, so gilt die angegebene Zielposition für den Block, der beim Antrainieren als erstes angeklickt wird.
|
||||||
- Hat der Block, der die Spieler/Mobs mitnehmen soll, eine reduzierte Höhe, so muss die Höhe im Controller über das Schraubenschlüsselmenü eingestellt werden (bspw. Höhe = 0.5). Ansonsten wird der Spieler/Mob nicht "gefunden" und damit nicht mitgenommen.
|
- Hat der Block, der die Spieler/Mobs mitnehmen soll, eine reduzierte Höhe, so muss die Höhe im Controller über das Schraubenschlüsselmenü eingestellt werden (bspw. Höhe = 0.5). Ansonsten wird der Spieler/Mob nicht "gefunden" und damit nicht mitgenommen.
|
||||||
|
|
||||||
[ta4_movecontroller|image]
|
[ta4_movecontroller|image]
|
||||||
|
@ -602,7 +602,7 @@ Since the moving blocks can take players and mobs standing on the block with the
|
|||||||
Instructions:
|
Instructions:
|
||||||
|
|
||||||
- Set the controller and train the blocks to be moved via the menu (up to 16 blocks can be trained)
|
- Set the controller and train the blocks to be moved via the menu (up to 16 blocks can be trained)
|
||||||
- the "flight route" must be entered via an x, y, z specification (relative) (the maximum distance (x+y+z) is 200 m)
|
- the "flight route" must be entered via an x, y, z specification (relative) (the maximum distance is 1000 m)
|
||||||
- The movement can be tested with the menu buttons "Move A-B" and "Move B-A"
|
- The movement can be tested with the menu buttons "Move A-B" and "Move B-A"
|
||||||
- you can also fly through walls or other blocks
|
- you can also fly through walls or other blocks
|
||||||
- The target position for the blocks can also be occupied. In this case, the blocks are saved "invisibly". This is intended for sliding doors and the like
|
- The target position for the blocks can also be occupied. In this case, the blocks are saved "invisibly". This is intended for sliding doors and the like
|
||||||
@ -615,13 +615,15 @@ The Move Controller supports the following techage commands:
|
|||||||
|
|
||||||
You can switch to the `move xyz` operating mode via the wrench menu. After switching, the following techage commands are supported:
|
You can switch to the `move xyz` operating mode via the wrench menu. After switching, the following techage commands are supported:
|
||||||
|
|
||||||
- `move2` With the command, the flight route must also be specified as an x,y,z vector.
|
- `move2` With this command, the flight route must also be specified as an x,y,z vector.
|
||||||
Example Lua Controller: `$send_cmnd(MOVE_CTLR, "move2", "0,12,0")`
|
Example Lua Controller: `$send_cmnd(MOVE_CTLR, "move2", "0,12,0")`
|
||||||
|
- `moveto` Move block to the given destination position (the destination position is valid for the first marked block, the other blocks are moved relative to this position)
|
||||||
- `reset` move block(s) back to start position
|
- `reset` move block(s) back to start position
|
||||||
|
|
||||||
**Important instructions:**
|
**Important instructions:**
|
||||||
|
|
||||||
- If several blocks are to be moved, the block that is to take the players/mobs must be clicked first when training.
|
- If several blocks are to be moved, the block that is to take the players/mobs must be clicked first when training.
|
||||||
|
- If the `moveto` command is used, the specified target position applies to the block that is clicked first during training.
|
||||||
- If the block that is supposed to take the players/mobs has a reduced height, the height must be set in the controller using the open-ended wrench menu (e.g. height = 0.5). Otherwise the player/mob will not be "found" and will not be taken away.
|
- If the block that is supposed to take the players/mobs has a reduced height, the height must be set in the controller using the open-ended wrench menu (e.g. height = 0.5). Otherwise the player/mob will not be "found" and will not be taken away.
|
||||||
|
|
||||||
[ta4_movecontroller|image]
|
[ta4_movecontroller|image]
|
||||||
|
@ -1512,8 +1512,9 @@ As payload data, these commands may require numeric values or a string value.
|
|||||||
| Move Contr. 1 | 11 | 1 | TA4 Move Controller command to move the block(s) from position A to B |
|
| Move Contr. 1 | 11 | 1 | TA4 Move Controller command to move the block(s) from position A to B |
|
||||||
| Move Contr. 2 | 11 | 2 | TA4 Move Controller command to move the block(s) from position B to A |
|
| Move Contr. 2 | 11 | 2 | TA4 Move Controller command to move the block(s) from position B to A |
|
||||||
| Move Contr. 3 | 11 | 3 | TA4 Move Controller command to move the block(s) to the opposite position |
|
| Move Contr. 3 | 11 | 3 | TA4 Move Controller command to move the block(s) to the opposite position |
|
||||||
| MC move xyz | 18 | x, y, z | TA4 Move Controller command to move the block(s) by the given<br>x/y/z-distance. Valid ranges for x, y, and z are -100 to 100 |
|
| Move Contr. `move xyz` | 18 | x, y, z | TA4 Move Controller command to move the block(s) by the given<br>x/y/z-distance. Valid ranges for x, y, and z are -100 to 100 |
|
||||||
| MC reset | 19 | - | Reset TA4 Move Controller (move block(s) to start position) |
|
| Move Contr. `moveto` | 24 | x, y, z | TA4 Move Controller command to move the block(s) to the given absolute x/y/z-position. |
|
||||||
|
| Move Contr. reset | 19 | - | Reset TA4 Move Controller (move block(s) to start position) |
|
||||||
| Turn Contr. 1 | 12 | 1 | TA4 Turn Controller command to turn the block(s) to the left |
|
| Turn Contr. 1 | 12 | 1 | TA4 Turn Controller command to turn the block(s) to the left |
|
||||||
| Turn Contr. 2 | 12 | 2 | TA4 Turn Controller command to turn the block(s) to the right |
|
| Turn Contr. 2 | 12 | 2 | TA4 Turn Controller command to turn the block(s) to the right |
|
||||||
| Turn Contr. 3 | 12 | 3 | TA4 Turn Controller command to turn the block(s) 180 degrees |
|
| Turn Contr. 3 | 12 | 3 | TA4 Turn Controller command to turn the block(s) 180 degrees |
|
||||||
@ -1525,6 +1526,7 @@ As payload data, these commands may require numeric values or a string value.
|
|||||||
| TA4 Pump Limit | 21 | limit | Configure a TA4 Pump with the number of liquid units that are allowed to be pumped ("flow limiter" mode)<br>`limit` = 0 turns off the "flow limiter" mode |
|
| TA4 Pump Limit | 21 | limit | Configure a TA4 Pump with the number of liquid units that are allowed to be pumped ("flow limiter" mode)<br>`limit` = 0 turns off the "flow limiter" mode |
|
||||||
| Color | 22 | color | Set the color of the TechAge Color Lamp and TechAge Color Lamp 2 (`color` = 0..255) |
|
| Color | 22 | color | Set the color of the TechAge Color Lamp and TechAge Color Lamp 2 (`color` = 0..255) |
|
||||||
| Multi Button | 23 | num, state | Turn button (TA4 2x Button, TA4 4x Button) on/off<br>`num` is the button number (1..4)<br>`state` is the state: 0 = "off", 1 = "on" |
|
| Multi Button | 23 | num, state | Turn button (TA4 2x Button, TA4 4x Button) on/off<br>`num` is the button number (1..4)<br>`state` is the state: 0 = "off", 1 = "on" |
|
||||||
|
| | 25 is next | | |
|
||||||
| Config TA4 Pusher | 65 | "\<item name>" | Configure the TA4 pusher.<br/>Example: `wool:blue` |
|
| Config TA4 Pusher | 65 | "\<item name>" | Configure the TA4 pusher.<br/>Example: `wool:blue` |
|
||||||
| Sensor Chest Text | 66 | "text string" | Text to be used for the Sensor Chest menu |
|
| Sensor Chest Text | 66 | "text string" | Text to be used for the Sensor Chest menu |
|
||||||
| Distri. Filter Config | 67 | "\<slot> \<item list>" | Configure a Distributor filter slot, like: "red default:dirt dye:blue" |
|
| Distri. Filter Config | 67 | "\<slot> \<item list>" | Configure a Distributor filter slot, like: "red default:dirt dye:blue" |
|
||||||
|
@ -425,6 +425,7 @@ Please note, that this is not a technical distinction, only a logical.
|
|||||||
| "b2a" | nil | TA4 Move Controller command to move the block(s) from position B to A |
|
| "b2a" | nil | TA4 Move Controller command to move the block(s) from position B to A |
|
||||||
| "move" | nil | TA4 Move Controller command to move the block(s) to the opposite position |
|
| "move" | nil | TA4 Move Controller command to move the block(s) to the opposite position |
|
||||||
| "move2" | x,y,z | TA4 Move Controller command to move the block(s) by the given<br /> x/y/z-distance. Valid ranges for x, y, and z are -100 to 100.<br />Example: `$send_cmnd("1674", "move2", "0,4,0")` |
|
| "move2" | x,y,z | TA4 Move Controller command to move the block(s) by the given<br /> x/y/z-distance. Valid ranges for x, y, and z are -100 to 100.<br />Example: `$send_cmnd("1674", "move2", "0,4,0")` |
|
||||||
|
| "moveto" | x,y,z | TA4 Move Controller command to move the block(s) to the given<br /> absolute x/y/z-position. |
|
||||||
| "reset" | nil | Reset TA4 Move Controller (move block(s) to start position) |
|
| "reset" | nil | Reset TA4 Move Controller (move block(s) to start position) |
|
||||||
| "left" | nil | TA4 Turn Controller command to turn the block(s) to the left |
|
| "left" | nil | TA4 Turn Controller command to turn the block(s) to the left |
|
||||||
| "right" | nil | TA4 Turn Controller command to turn the block(s) to the right |
|
| "right" | nil | TA4 Turn Controller command to turn the block(s) to the right |
|
||||||
|
@ -22,7 +22,7 @@ local MP = minetest.get_modpath("techage")
|
|||||||
local mark = dofile(MP .. "/basis/mark_lib.lua")
|
local mark = dofile(MP .. "/basis/mark_lib.lua")
|
||||||
local fly = techage.flylib
|
local fly = techage.flylib
|
||||||
|
|
||||||
local MAX_DIST = 200
|
local MAX_DIST = 1000
|
||||||
local MAX_BLOCKS = 16
|
local MAX_BLOCKS = 16
|
||||||
|
|
||||||
local WRENCH_MENU = {
|
local WRENCH_MENU = {
|
||||||
@ -231,6 +231,12 @@ techage.register_node({"techage:ta4_movecontroller"}, {
|
|||||||
return fly.move_to(pos, line)
|
return fly.move_to(pos, line)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
elseif move_xyz and topic == "moveto" then
|
||||||
|
local destpos = fly.to_vector(payload)
|
||||||
|
if destpos then
|
||||||
|
return fly.move_to_abs(pos, destpos, MAX_DIST)
|
||||||
|
end
|
||||||
|
return false
|
||||||
elseif topic == "reset" then
|
elseif topic == "reset" then
|
||||||
return fly.reset_move(pos)
|
return fly.reset_move(pos)
|
||||||
end
|
end
|
||||||
@ -250,11 +256,18 @@ techage.register_node({"techage:ta4_movecontroller"}, {
|
|||||||
end
|
end
|
||||||
elseif move_xyz and topic == 18 then -- move xyz
|
elseif move_xyz and topic == 18 then -- move xyz
|
||||||
local line = {
|
local line = {
|
||||||
x = techage.in_range(techage.beduino_signed_var(payload[1]), -100, 100),
|
x = techage.in_range(techage.beduino_signed_var(payload[1]), -1000, 1000),
|
||||||
y = techage.in_range(techage.beduino_signed_var(payload[2]), -100, 100),
|
y = techage.in_range(techage.beduino_signed_var(payload[2]), -1000, 1000),
|
||||||
z = techage.in_range(techage.beduino_signed_var(payload[3]), -100, 100),
|
z = techage.in_range(techage.beduino_signed_var(payload[3]), -1000, 1000),
|
||||||
}
|
}
|
||||||
return fly.move_to(pos, line) and 0 or 3
|
return fly.move_to(pos, line) and 0 or 3
|
||||||
|
elseif move_xyz and topic == 24 then -- moveto xyz
|
||||||
|
local dest = {
|
||||||
|
x = techage.in_range(techage.beduino_signed_var(payload[1]), -32768, 32767),
|
||||||
|
y = techage.in_range(techage.beduino_signed_var(payload[2]), -32768, 32767),
|
||||||
|
z = techage.in_range(techage.beduino_signed_var(payload[3]), -32768, 32767),
|
||||||
|
}
|
||||||
|
return fly.move_to_abs(pos, dest, MAX_DIST) and 0 or 3
|
||||||
elseif move_xyz and topic == 19 then -- reset
|
elseif move_xyz and topic == 19 then -- reset
|
||||||
return fly.reset_move(pos) and 0 or 3
|
return fly.reset_move(pos) and 0 or 3
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user