Zig: Simulated players
Functions
sim.list
| Zig |
|---|
| pub fn list(allocator: Allocator) core.Error![][]u8
|
The names of the simulated players alive now, owned by the caller; core.freeList releases them. A bot that outlived the session that spawned it is found again by name.
- Parameters:
- Return type:
core.Error![][]u8
- Slots:
sim_list
sim.SimPlayer
| Zig |
|---|
| pub const SimPlayer = struct {
name: []const u8,
// ...
};
|
One simulated player, named. The name is borrowed and must outlive the value.
sim.SimPlayer.spawn
| Zig |
|---|
| pub fn spawn(name: []const u8, dim: i32, x: f64, y: f64, z: f64) core.Error!SimPlayer
|
Builds a simulated player. It fails when the name is taken by a real player.
- Parameters:
- name :
[]const u8
- dim :
i32
- x :
f64
- y :
f64
- z :
f64
- Return type:
core.Error!SimPlayer
- Slots:
sim_spawn
sim.SimPlayer.byName
| Zig |
|---|
| pub fn byName(name: []const u8) SimPlayer
|
Attaches by name to a simulated player that already exists. It does not check whether one does; isSimulated does.
- Parameters:
- Return type:
SimPlayer
sim.SimPlayer.player
| Zig |
|---|
| pub fn player(self: SimPlayer) props.Player
|
Uses it as an ordinary player, giving the full player API.
- Return type:
props.Player
sim.SimPlayer.isSimulated
| Zig |
|---|
| pub fn isSimulated(self: SimPlayer) core.Error!bool
|
Whether this name currently points at a live simulated player.
- Return type:
core.Error!bool
- Slots:
sim_is
sim.SimPlayer.act
| Zig |
|---|
| pub fn act(self: SimPlayer, verb: []const u8, args_snbt: []const u8) core.Error!void
|
Runs one verb. The argument is SNBT, and "{}" is passed when there is none.
- Parameters:
- verb :
[]const u8
- args_snbt :
[]const u8
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.despawn
| Zig |
|---|
| pub fn despawn(self: SimPlayer) core.Error!void
|
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.stop
| Zig |
|---|
| pub fn stop(self: SimPlayer) core.Error!void
|
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.jump
| Zig |
|---|
| pub fn jump(self: SimPlayer) core.Error!void
|
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.attack
| Zig |
|---|
| pub fn attack(self: SimPlayer) core.Error!void
|
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.interact
| Zig |
|---|
| pub fn interact(self: SimPlayer) core.Error!void
|
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.useItem
| Zig |
|---|
| pub fn useItem(self: SimPlayer) core.Error!void
|
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.dropSelected
| Zig |
|---|
| pub fn dropSelected(self: SimPlayer) core.Error!void
|
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.respawn
| Zig |
|---|
| pub fn respawn(self: SimPlayer) core.Error!void
|
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.stopDestroying
| Zig |
|---|
| pub fn stopDestroying(self: SimPlayer) core.Error!void
|
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.moveTo
| Zig |
|---|
| pub fn moveTo(self: SimPlayer, x: f64, y: f64, z: f64, speed: f64, face_target: bool) core.Error!void
|
Walks straight there. face_target decides whether it faces the target while walking.
- Parameters:
- x :
f64
- y :
f64
- z :
f64
- speed :
f64
- face_target :
bool
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.navigateTo
| Zig |
|---|
| pub fn navigateTo(self: SimPlayer, x: f64, y: f64, z: f64, speed: f64) core.Error!void
|
Paths there. Unlike moveTo it goes around obstacles.
- Parameters:
- x :
f64
- y :
f64
- z :
f64
- speed :
f64
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.lookAt
| Zig |
|---|
| pub fn lookAt(self: SimPlayer, x: f64, y: f64, z: f64) core.Error!void
|
- Parameters:
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.destroyBlock
| Zig |
|---|
| pub fn destroyBlock(self: SimPlayer, x: i32, y: i32, z: i32, face: i32) core.Error!void
|
Mines one block. face is the face, 1 meaning up.
- Parameters:
- x :
i32
- y :
i32
- z :
i32
- face :
i32
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.interactBlock
| Zig |
|---|
| pub fn interactBlock(self: SimPlayer, x: i32, y: i32, z: i32, face: i32) core.Error!void
|
- Parameters:
- x :
i32
- y :
i32
- z :
i32
- face :
i32
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.destroyLookAt
| Zig |
|---|
| pub fn destroyLookAt(self: SimPlayer, hand: f64) core.Error!void
|
Mines the block in the line of sight. hand is the reach, in blocks.
- Parameters:
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.setSneaking
| Zig |
|---|
| pub fn setSneaking(self: SimPlayer, on: bool) core.Error!void
|
- Parameters:
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.setFlying
| Zig |
|---|
| pub fn setFlying(self: SimPlayer, on: bool) core.Error!void
|
- Parameters:
- Return type:
core.Error!void
- Slots:
sim_do
sim.SimPlayer.chat
| Zig |
|---|
| pub fn chat(self: SimPlayer, message: []const u8) core.Error!void
|
- Parameters:
- Return type:
core.Error!void
- Slots:
sim_do