Fix issue #193 (Move controller feature request)

This commit is contained in:
Joachim Stolberg 2025-01-12 16:02:03 +01:00
parent d30f025225
commit 9cd9ab9f90
6 changed files with 70 additions and 30 deletions

View File

@ -151,7 +151,7 @@ local function trim(s)
end
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
function flylib.to_vector(s, max_dist)
@ -160,7 +160,7 @@ function flylib.to_vector(s, max_dist)
y = tonumber(y) or 0
z = tonumber(z) or 0
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}
end
end
@ -874,6 +874,26 @@ function flylib.move_to(pos, move)
return nvm.running
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)
local meta = M(pos)
local nvm = techage.get_nvm(pos)

View File

@ -612,7 +612,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ü (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
- 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
@ -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.
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
**Wichtige Hinweise:**
- 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.
[ta4_movecontroller|image]

View File

@ -154,7 +154,7 @@ In order for the heat storage system to work, all blocks (also the concrete shel
### TA4 Heat Exchanger
The heat exchanger consists of 3 parts that must be placed on top of each other, with the arrow of the first block pointing towards the turbine. The pipes must be built with the yellow TA4 pipes.
The heat exchanger must be connected to the power grid. The energy storage device is recharged via the heat exchanger, provided that sufficient electricity is available.
The heat exchanger must be connected to the power grid. The energy storage device is recharged via the heat exchanger, provided that sufficient electricity is available.
[ta4_heatexchanger|image]
@ -171,7 +171,7 @@ The turbine is part of the energy storage. It must be placed next to the generat
The generator is used to generate electricity. Therefore, the generator must also be connected to the power grid.
The generator is part of the energy storage. It is used to generate electricity and thus releases the energy from the energy storage unit. Therefore, the generator must also be connected to the power grid.
Important: Both, heat exchanger and generator must be connected to the same power grid!
Important: Both, heat exchanger and generator must be connected to the same power grid!
[ta4_generator|image]
@ -222,9 +222,9 @@ A power output countdown can also be entered via the wrench menu. When this coun
### TA4 Laser
The TA4 laser is used for wireless power transmission. Two blocks are required for this: TA4 Laser Beam Emitter and TA4 Laser Beam Receiver. There must be an air gap between the two blocks so that the laser beam can be built up from the emitter to the receiver. First the emitter must be placed. This immediately switches on the laser beam and shows possible positions of the receiver. Possible positions for the receiver are also output via a chat message.
The TA4 laser is used for wireless power transmission. Two blocks are required for this: TA4 Laser Beam Emitter and TA4 Laser Beam Receiver. There must be an air gap between the two blocks so that the laser beam can be built up from the emitter to the receiver. First the emitter must be placed. This immediately switches on the laser beam and shows possible positions of the receiver. Possible positions for the receiver are also output via a chat message.
With the laser, distances of up to 96 blocks can be bridged. Once the connection has been established (no current has to flow), this is indicated via the info text of the emitter and also of the receiver.
With the laser, distances of up to 96 blocks can be bridged. Once the connection has been established (no current has to flow), this is indicated via the info text of the emitter and also of the receiver.
The laser blocks themselves do not require any electricity.
@ -267,7 +267,7 @@ It must be supplied with hydrogen from the left by a pump. The power connection
The fuel cell can deliver up to 34 ku of electricity and needs a hydrogen item every 4 s.
Usually the fuel cell works as a category 2 generator (like other storage systems).
Usually the fuel cell works as a category 2 generator (like other storage systems).
In this case, no other category 2 blocks such as the battery block can be charged. However, the fuel cell can also be used as a category 1 generator via the check box.
[ta4_fuelcell|image]
@ -477,14 +477,14 @@ Only the appearance of the TA4 button/switch has changed. The functionality is t
### TA4 2x Button
This block has two buttons that can be individually configured using the wrench menu. The labeling and the target block address can be configured for each button. In addition, the command that is to be sent can be configured for each button.
This block has two buttons that can be individually configured using the wrench menu. The labeling and the target block address can be configured for each button. In addition, the command that is to be sent can be configured for each button.
[ta4_button_2x|image]
### TA4 4x Button
This block has four buttons that can be individually configured using the wrench menu. The labeling and the target block address can be configured for each button. In addition, the command that is to be sent can be configured for each button.
This block has four buttons that can be individually configured using the wrench menu. The labeling and the target block address can be configured for each button. In addition, the command that is to be sent can be configured for each button.
[ta4_button_4x|image]
@ -602,7 +602,7 @@ Since the moving blocks can take players and mobs standing on the block with the
Instructions:
- 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"
- 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
@ -613,15 +613,17 @@ The Move Controller supports the following techage commands:
- `b2a` Move block from B to A.
- `move` Move block to the other side
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.
Example Lua Controller: `$send_cmnd(MOVE_CTLR, "move2", "0,12,0")`
- `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")`
- `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
**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 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.
[ta4_movecontroller|image]
@ -639,7 +641,7 @@ The turn controller supports the following techage commands:
- `left` Turn left
- `right` Turn right
- `uturn` Turn 180 degrees
- `uturn` Turn 180 degrees
[ta4_turncontroller|image]
@ -827,7 +829,7 @@ Up to 10 recipes can be saved in the recipe block. These recipes can then be cal
Example: `$send_cmnd(1234, "input", 1)`
[ta4_recipeblock|image]
[ta4_recipeblock|image]
### TA4 Autocrafter
@ -845,7 +847,7 @@ All technical names of a recipe must be specified here, separated by commas. See
The `flush` command moves all items from the input inventory to the output inventory. The command returns `true` if the input inventory was completely emptied. If `false` was returned (output inventory full), the command must be repeated at a later time.
[ta4_autocrafter|image]
[ta4_autocrafter|image]
### TA4 Tank
@ -859,7 +861,7 @@ A TA4 tank can hold 2000 units or 200 barrels of liquid.
See TA3 pump.
The TA4 pump pumps 8 units of liquid every two seconds.
The TA4 pump pumps 8 units of liquid every two seconds.
In the "Flow limiter" mode, the number of units pumped by the pump can be limited. The flow limiter mode can be activated via the open-end wrench menu by configuring the number of units in the menu. Once the configured number of units have been pumped, the pump will turn off. When the pump is turned on again, it will pump the configured number of units again and then turn off.
@ -879,13 +881,13 @@ The heater requires 14 ku of electricity.
### TA4 Water Pump (deprecated)
This block can no longer be crafted and will be replaced by the TA4 water inlet block.
This block can no longer be crafted and will be replaced by the TA4 water inlet block.
### TA4 Water Inlet
Some recipes require water. The water must be pumped from the sea with a pump (water at y = 1). A "pool" made up of a few water blocks is not sufficient for this!
Some recipes require water. The water must be pumped from the sea with a pump (water at y = 1). A "pool" made up of a few water blocks is not sufficient for this!
To do this, the water inlet block must be placed in the water and connected to the pump via pipes. If the block is placed in the water, it must be ensured that there is water under the block (water must be at least 2 blocks deep).
To do this, the water inlet block must be placed in the water and connected to the pump via pipes. If the block is placed in the water, it must be ensured that there is water under the block (water must be at least 2 blocks deep).
[ta4_waterinlet|image]
@ -1026,15 +1028,15 @@ The processing power is up to 8 times four items every 4 seconds.
### TA4 Recycler
The recycler is a machine that processes all Techage recipes backwards, i.e. it can dismantle machines and blocks back into their components.
The recycler is a machine that processes all Techage recipes backwards, i.e. it can dismantle machines and blocks back into their components.
The machine can disassemble pretty much any Techage and Hyperloop blocks. But not all recipe items/materials can be recycled:
- Wood turns into sticks
- Stone turns into sand or gravel
- Semiconductors / chips cannot be recycled
- Semiconductors / chips cannot be recycled
- Tools cannot be recycled
The processing power is one item every 8 s. The block requires 16 ku of electricity for this.
[ta4_recycler|image]
[ta4_recycler|image]

View File

@ -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. 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 |
| 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 |
| MC reset | 19 | - | Reset TA4 Move Controller (move block(s) to start position) |
| 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 |
| 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. 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 |
@ -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 |
| 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" |
| | 25 is next | | |
| 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 |
| Distri. Filter Config | 67 | "\<slot> \<item list>" | Configure a Distributor filter slot, like: "red default:dirt dye:blue" |

View File

@ -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 |
| "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")` |
| "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) |
| "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 |

View File

@ -22,7 +22,7 @@ local MP = minetest.get_modpath("techage")
local mark = dofile(MP .. "/basis/mark_lib.lua")
local fly = techage.flylib
local MAX_DIST = 200
local MAX_DIST = 1000
local MAX_BLOCKS = 16
local WRENCH_MENU = {
@ -231,6 +231,12 @@ techage.register_node({"techage:ta4_movecontroller"}, {
return fly.move_to(pos, line)
end
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
return fly.reset_move(pos)
end
@ -250,11 +256,18 @@ techage.register_node({"techage:ta4_movecontroller"}, {
end
elseif move_xyz and topic == 18 then -- move xyz
local line = {
x = techage.in_range(techage.beduino_signed_var(payload[1]), -100, 100),
y = techage.in_range(techage.beduino_signed_var(payload[2]), -100, 100),
z = techage.in_range(techage.beduino_signed_var(payload[3]), -100, 100),
x = techage.in_range(techage.beduino_signed_var(payload[1]), -1000, 1000),
y = techage.in_range(techage.beduino_signed_var(payload[2]), -1000, 1000),
z = techage.in_range(techage.beduino_signed_var(payload[3]), -1000, 1000),
}
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
return fly.reset_move(pos) and 0 or 3
else