Fixes and added a proper README
This commit is contained in:
parent
eee219f537
commit
2094c62f35
4 changed files with 140 additions and 25 deletions
|
@ -14,7 +14,7 @@ namespace BuildingTools
|
|||
{
|
||||
if (blocks.Length == 0)
|
||||
{
|
||||
Logging.CommandLogWarning("No blocks selected. Use selectBlocks first.");
|
||||
Logging.CommandLogWarning("No blocks selected. Use a select command first (unless you specified an ID).");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,18 +32,23 @@ namespace BuildingTools
|
|||
GameClient.SetDebugInfo("BlockModInfo", GetBlockInfo);
|
||||
_commandUtils.RegisterBlockCommand("scaleBlocks",
|
||||
"Scales the selected blocks, relative to current size (current scale * new scale)." +
|
||||
" The block you're looking at (when selected based on that) stays where it is, everything else is moved next to it.",
|
||||
(scaleX, scaleY, scaleZ, blocks, refBlock) =>
|
||||
" The block you're looking at stays where it is, everything else is moved next to it.",
|
||||
(scaleX, scaleY, scaleZ, blocks, refBlock) => //TODO: Either remove refBlock or add commands for changing it
|
||||
{
|
||||
if (!GameState.IsBuildMode()) return; //Scaling & positioning is weird in simulation
|
||||
if (_blockSelections.CheckNoBlocks(blocks)) return;
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
float3 reference = refBlock.Position;
|
||||
float3? reference = Player.LocalPlayer.GetBlockLookedAt()?.Position;
|
||||
if (!reference.HasValue)
|
||||
{
|
||||
Logging.CommandLogError("Look at a block (not too far away) to be used as reference.");
|
||||
return;
|
||||
}
|
||||
float3 scale = new float3(scaleX, scaleY, scaleZ);
|
||||
foreach (var block in blocks)
|
||||
{
|
||||
block.Scale *= scale;
|
||||
block.Position = reference + (block.Position - reference) * scale;
|
||||
block.Position = (float3) (reference + (block.Position - reference) * scale);
|
||||
}
|
||||
|
||||
Logging.CommandLog("Blocks scaled.");
|
||||
|
@ -57,7 +62,7 @@ namespace BuildingTools
|
|||
foreach (var block in blocks)
|
||||
block.Scale *= scale;
|
||||
});
|
||||
_commandUtils.RegisterBlockCommand("moveBlocks", "Moves the blocks around.", (x, y, z, blocks, refBlock) =>
|
||||
_commandUtils.RegisterBlockCommand("moveBlocks", "Moves (teleports) the selected blocks around both in time stopped and running. The latter will be reset as expected.", (x, y, z, blocks, refBlock) =>
|
||||
{
|
||||
if (GameState.IsBuildMode())
|
||||
foreach (var block in blocks)
|
||||
|
@ -66,7 +71,7 @@ namespace BuildingTools
|
|||
foreach (var body in GetSimBodies(blocks))
|
||||
body.Position += new float3(x, y, z);
|
||||
});
|
||||
_commandUtils.RegisterBlockCommand("colorBlocks", "Colors the blocks you're looking at",
|
||||
_commandUtils.RegisterBlockCommand("colorBlocks", "Colors the selected blocks permanently both in time stopped and running. It won't be reset when stopping time.",
|
||||
(color, darkness, blocks, refBlock) =>
|
||||
{
|
||||
|
||||
|
@ -80,33 +85,53 @@ namespace BuildingTools
|
|||
});
|
||||
|
||||
CommandBuilder.Builder("selectBlocksLookedAt",
|
||||
"Selects blocks (1 or more) to change. Only works in build mode, however the blocks can be changed afterwards." +
|
||||
"Selects blocks (1 or more) to change. Only works in time stopped mode, however the blocks can be changed afterwards in both modes." +
|
||||
" Parameter: whether one (true) or all connected (false) blocks should be selected.")
|
||||
.Action<bool>(single =>
|
||||
{
|
||||
_blockSelections.refBlock = new Player(PlayerType.Local).GetBlockLookedAt();
|
||||
var refBlock = _blockSelections.refBlock;
|
||||
_blockSelections.blocks = single ? new[] {refBlock} : refBlock?.GetConnectedCubes() ?? new Block[0];
|
||||
if (!GameState.IsBuildMode())
|
||||
{
|
||||
Logging.CommandLogError("This command can only be used in time stopped mode.");
|
||||
return;
|
||||
}
|
||||
var refBlock = Player.LocalPlayer.GetBlockLookedAt();
|
||||
if (refBlock == null)
|
||||
{
|
||||
Logging.CommandLogError("Block not found. Make sure to be close enough to the block.");
|
||||
return;
|
||||
}
|
||||
_blockSelections.refBlock = refBlock;
|
||||
_blockSelections.blocks = single ? new[] {refBlock} : refBlock.GetConnectedCubes() ?? new Block[0];
|
||||
var blocks = _blockSelections.blocks;
|
||||
Logging.CommandLog(blocks == null ? "Selection cleared." : blocks.Length + " blocks selected.");
|
||||
Logging.CommandLog(blocks.Length + " blocks selected.");
|
||||
}).Build();
|
||||
CommandBuilder.Builder("selectBlocksWithID", "Selects blocks with a specific object ID.")
|
||||
.Action<char>(id =>
|
||||
_blockSelections.blocks = (_blockSelections.refBlock = ObjectIdentifier.GetByID(id).FirstOrDefault())
|
||||
?.GetConnectedCubes() ?? new Block[0]).Build();
|
||||
{
|
||||
_blockSelections.blocks =
|
||||
(_blockSelections.refBlock = ObjectIdentifier.GetByID(id).FirstOrDefault())
|
||||
?.GetConnectedCubes() ?? new Block[0];
|
||||
Logging.CommandLog(_blockSelections.blocks.Length + " blocks selected.");
|
||||
}).Build();
|
||||
CommandBuilder.Builder("selectSelectedBlocks", "Selects blocks that are box selected by the player.")
|
||||
.Action(() =>
|
||||
{
|
||||
_blockSelections.blocks = new Player(PlayerType.Local).GetSelectedBlocks();
|
||||
_blockSelections.blocks = Player.LocalPlayer.GetSelectedBlocks();
|
||||
_blockSelections.refBlock = _blockSelections.blocks.Length > 0 ? _blockSelections.blocks[0] : null;
|
||||
Logging.CommandLog(_blockSelections.blocks.Length + " blocks selected.");
|
||||
}).Build();
|
||||
|
||||
ConsoleCommands.RegisterWithChannel("selectSendSignal", ch => { }, ChannelType.Object,
|
||||
"Sends a signal for selecting a given object ID for a command block.");
|
||||
/*ConsoleCommands.RegisterWithChannel("selectSendSignal", ch => { }, ChannelType.Object,
|
||||
"Sends a signal for selecting a given object ID for a command block.");*/
|
||||
|
||||
_commandUtils.RegisterBlockCommand("pushBlocks", "Adds velocity to the selected blocks. Only works in simulation.",
|
||||
_commandUtils.RegisterBlockCommand("pushBlocks", "Adds velocity to the selected blocks. Only works in time running mode.",
|
||||
(x, y, z, blocks, refBlock) =>
|
||||
{
|
||||
if (!GameState.IsSimulationMode())
|
||||
{
|
||||
Logging.CommandLogError("This command can only be used in time running mode.");
|
||||
return;
|
||||
}
|
||||
foreach (var block in GetSimBodies(blocks))
|
||||
block.Velocity += new float3(x, y, z);
|
||||
});
|
||||
|
@ -114,18 +139,23 @@ namespace BuildingTools
|
|||
"Adds angular velocity to the selected blocks. Only works in simulation.",
|
||||
(x, y, z, blocks, refBlock) =>
|
||||
{
|
||||
if (!GameState.IsSimulationMode())
|
||||
{
|
||||
Logging.CommandLogError("This command can only be used in time running mode.");
|
||||
return;
|
||||
}
|
||||
foreach (var block in GetSimBodies(blocks))
|
||||
block.AngularVelocity += new float3(x, y, z);
|
||||
});
|
||||
CommandBuilder.Builder("pushPlayer", "Adds velocity to the player.")
|
||||
.Action<float, float, float>((x, y, z) =>
|
||||
{
|
||||
new Player(PlayerType.Local).Velocity += new float3(x, y, z);
|
||||
Player.LocalPlayer.Velocity += new float3(x, y, z);
|
||||
}).Build();
|
||||
CommandBuilder.Builder("pushRotatePlayer", "Adds angular velocity to the player.")
|
||||
.Action<float, float, float>((x, y, z) =>
|
||||
{
|
||||
new Player(PlayerType.Local).AngularVelocity += new float3(x, y, z);
|
||||
Player.LocalPlayer.AngularVelocity += new float3(x, y, z);
|
||||
}).Build();
|
||||
var noClip = new NoClipCommand();
|
||||
GameEngineManager.AddGameEngine(noClip);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using Gamecraft.Wires;
|
||||
using GamecraftModdingAPI;
|
||||
using GamecraftModdingAPI.Commands;
|
||||
using RobocraftX.CommandLine.Custom;
|
||||
using uREPL;
|
||||
|
||||
|
@ -17,11 +18,11 @@ namespace BuildingTools
|
|||
|
||||
private void RegisterBlockCommandInternal(string name, string desc, Action<string, Block[], Block> action)
|
||||
{
|
||||
RuntimeCommands.Register<string>(name, a1 =>
|
||||
CommandBuilder.Builder(name, desc).Action<string>(a1 =>
|
||||
{
|
||||
action(a1, _blockSelections.blocks, _blockSelections.refBlock);
|
||||
}, desc);
|
||||
ConsoleCommands.RegisterWithChannel<string>(name, (a1, ch) =>
|
||||
}).Build();
|
||||
ConsoleCommands.RegisterWithChannel<string>(name + "Chan", (a1, ch) =>
|
||||
{
|
||||
Console.WriteLine($"Command {name} with args {a1} and channel {ch} executing");
|
||||
var blks = _blockSelections.SelectBlocks(ch);
|
||||
|
@ -51,7 +52,7 @@ namespace BuildingTools
|
|||
{
|
||||
if (argsa[3].Length == 0)
|
||||
{
|
||||
Log.Error("Missing channel.");
|
||||
Log.Error("Missing object ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
86
README.md
86
README.md
|
@ -1,3 +1,87 @@
|
|||
# BuildingTools
|
||||
|
||||
Tools for building.
|
||||
Tools for building games, mainly focused on changing block properties.
|
||||
And no clip.
|
||||
|
||||
## Commands
|
||||
### Selection commands
|
||||
Before changing any block with this mod, you need to select it in most cases. This is different than Gamecraft's box selection.
|
||||
|
||||
You can use all the commands starting with `select`, they all have descriptions to help and should be self-explanatory otherwise.
|
||||
|
||||
You can also run the desired block command for a cluster with a given object ID by adding the identifier as the last parameter.
|
||||
In this case you don't need to select the blocks beforehand which can be useful in command computers.
|
||||
|
||||
Speaking of command computers, object signals can *also* be used, so if you have an object trigger set up and an object identifier enters that trigger, then all the blocks attached to it will be used as target blocks for the given block command that receives the signal.
|
||||
To use this, add "Chan" at the end of the command name (like `colorBlocksChan`).
|
||||
|
||||
### Block commands
|
||||
#### Color command
|
||||
|
||||
The `colorBlocks` command can color the selected blocks to the given color.
|
||||
It works in both time stopped and running modes, although the color *will not* reset on time stop.
|
||||
|
||||
The darkness parameter is what can be selected in the game using `Ctrl+<num>` by default.
|
||||
0 means default color, then lightest to darkest.
|
||||
|
||||
Usage (The object ID is optional):
|
||||
```
|
||||
colorBlocks "<color> <darkness> [objectID]"
|
||||
```
|
||||
**The usage for all other block commands are the following:**
|
||||
```
|
||||
<command> "<x> <y> <z> [objectID]"
|
||||
```
|
||||
|
||||
### Scale blocks
|
||||
The `scaleBlocks` command can be used to both scale *and* move the blocks so that the cluster stays together.
|
||||
In this case, the block you're looking at is used as reference and won't be moved.
|
||||
|
||||
The `scaleIndividually` command only scales the blocks but doesn't move them so you can see between them.
|
||||
|
||||
Both commands take a *relative* scale, so specifying "1 1 1" will not change anything and "2 2 2" will double the scale in all directions.
|
||||
|
||||
Note that block connections will not be updated until you reload the save.
|
||||
|
||||
### Move blocks
|
||||
The `moveBlocks` command will move the selected blocks by the specified amount. Use 0.2 for one block of change in position.
|
||||
|
||||
In time stopped mode, this will not update block connections, just like the scale commands.
|
||||
|
||||
In time running mode, this will move the whole chunks the selected blocks are a part of.
|
||||
|
||||
### Push blocks
|
||||
The `pushBlocks` and `pushRotateBlocks` command will apply a specified (regular or angular) force to the selected blocks' chunks.
|
||||
The directions are global, so a positive value for Y means push upwards.
|
||||
Only works in time running mode.
|
||||
|
||||
## Other commands
|
||||
### Push player
|
||||
The `pushPlayer` and `pushRotatePlayer` commands will apply a specified (regular or angular) force to the player in any mode.
|
||||
|
||||
### No clip
|
||||
The `noClip` command allows you to go through blocks. Run to toggle.
|
||||
It works in both time stopped and running modes.
|
||||
|
||||
### Examples
|
||||
* Select and move box selected blocks by 5 blocks in the +X direction:
|
||||
```
|
||||
selectSelectedBlocks
|
||||
moveBlocks "1 0 0"
|
||||
```
|
||||
* Select and push the block you're looking at and all connected blocks by 10 in the +Y direction:
|
||||
```
|
||||
selectBlocksLookedAt false
|
||||
<Start time>
|
||||
pushBlocks "0 10 0"
|
||||
```
|
||||
* Change the color of the cluster with ID E to blue:
|
||||
```
|
||||
colorBlocks "blue 0 E"
|
||||
```
|
||||
* Color all clusters with an object ID that enter an object trigger hooked up to a command computer with this command:
|
||||
|
||||
(Can be filtered using an object filter)
|
||||
```
|
||||
colorBlocksChan "blue 0"
|
||||
```
|
Loading…
Reference in a new issue