The Message
module allows to present messages to the players. It has following use cases:
- present same message to everyone, for example:
Message.print("X has killed Y")
- present player-specific message, for example:
Message.print("You got killed!", { player: killedPlayer })
- present messages for developer only, for example:
Message.print(`${blobA.category} vs ${blobB.category}`, { dev: true })
It’s worth noting that the last case may be used to develop and debug complex game logic in place of the JS’s standard console.log
function which is not available in Heyplay. The player
option still applies so that the game author may also target messages to specific player(s) that he controls. Here’s an example:
Message.print(
`position: ${blob.position.toString()}\n` +
`velocity: ${blob.velocity.toString()}\n`,
{ dev = true })