Command
The things a player can send. Pointing has two:
point moves your cursor and click drops a dot. Each is a
directory holding a param schema, a writes
manifest, and a handler.
point
Moves the sending player's cursor to a pointed-at position. Its params are the
target x and y; the handler writes them onto the player.
[
{
"gamehoster-command-schema-name": "x",
"gamehoster-command-schema-type": "number"
},
{
"gamehoster-command-schema-name": "y",
"gamehoster-command-schema-type": "number"
}
]
{
"writes": ["player.x", "player.y"]
}
// Move the sending player's cursor to the pointed position. `x` and `y` are
// `shared` fields, so this handler runs on both sides: on the owner's front end
// (prediction) and on the server (authority). Gamehoster.Context.playerId is the sender.
const me = Gamehoster.Context.playerId
Gamehoster.Player.State.Set(me, "x", Gamehoster.Command.Get("x"))
Gamehoster.Player.State.Set(me, "y", Gamehoster.Command.Get("y"))
click
Drops a permanent dot at the sending player's current cursor, in their colour. It takes no params, and writes nothing to the player; it only spawns an entity.
[]
{
"writes": []
}
// Drop a permanent dot at the sending player's cursor, in their colour. Spawn is
// authoritative, so this effectively only lands on the server: the front end
// sees the dot when the confirmed state arrives. Context.playerId is the sender.
const me = Gamehoster.Context.playerId
Gamehoster.Entity.Spawn("dot", {
x: Gamehoster.Player.State.Get(me, "x"),
y: Gamehoster.Player.State.Get(me, "y"),
color: Gamehoster.Player.State.Get(me, "color")
})