Multi-Colour Light
Pedro Gimeno이(가) 6 년 전에 이 페이지를 수정함

Multi-Colour Light block

This block can be controlled and read via a digiline. The channel can only be configured once; to change it, the node must be dug and placed again. Anyone can set it, not just the placer. The channel will be a string, even when digits are entered. An empty channel name is not allowed.

The digiline signal must be a string with one of these formats:

  • "on" - light on
  • "off" - light off
  • "#rgb" - change colour (3 hex digits)
  • "#rrggbb" - colour (6 hex digits)
  • "on#rgb"
  • "off#rgb"
  • "on#rrggbb"
  • "off#rrggbb" - change both light on/off status and colour

Despite accepting any hex colours, due to Minetest limitations only 125 are possible, which are all possible combinations of values 00, 40, 80, C0 and FF in each of R, G and B (values 00-33 count as 00, values 34-66 count as 40, values 67-99 count as 80, values 9A-CC count as C0, and values CD-FF count as FF)

After being configured, it will send on the selected channel the string "L <playername>" when the node is punched (L for left-clicked) and the string "R <playername>" when the node is right-clicked (with the actual player's name, of course).

Crafting

The recipe:

    empty        digiline wire    empty
    clay block   mese fragment    clay block
    red dye      green dye        blue dye

Crafting recipe for Digiplay Multi-Colour Light

Conductivity

The block is not conductive (it does not propagate mesecon or digiline signals).

Example: Tic-Tac-Toe

Here's an example to illustrate the power of this block. It implements Tic-tac-toe for two players.

Materials required

  • 9 Digiplay multicolour light (MCL) blocks.
  • 4 mesecon wires.
  • 4 digiline wires.
  • 1 digiline LCD display.
  • 1 mesecons button.
  • 1 sign (optional).
  • Some other blocks for framing the set (optional, but you will need one more mesecon wire if you don't place a solid block behind the button).

Setup

Lay the MCL blocks in a 3x3 grid, then the rest of components as in the image. Place a diggable block where the LCD will be, so that you can remove it easily later (there will be a digiline wire in that place):

Tic-tac-toe layout

Set the channel of the display to "display" (without the quotes), and the channels of the MCL blocks to the numbers 1 to 9 (left to right, top to bottom).

Place the LuaController next to the middle MCL block. Remove the block behind the LCD and place a digiline wire there, and another one behind that. Then one digiline wire to each side of the LuaController. Finally, wire the remaining pin to the RESET button with a mesecon wire. The result should look like this:

Tic-tac-toe wiring

Program

The LuaController program is obviously the one that does the heavy lifting. Grab it from here:

LuaController program

How to play

Right-clicking one of the MCLs starts a game. The screen will display "Waiting for second player"; the next player to right-click will be player two (it may be the same). No other players can then click until the game is reset. Reset is done by activating the reset button, but it can only be pressed at least 30 seconds after the last move, or after the game is finished.

When one player wins, the winner is announced and the winning line flashes. Draw is announced when all cells are on without anyone winning.