Redstone Output Port

From WebDisplays
Revision as of 16:49, 14 February 2018 by Montoyo (talk | contribs) (How to use)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Redstone Output Port is an upgrade which allows web pages to change the redstone state of blocks around the screen.

Recipe

Upgrade redout.png

The item on the left is a Blank Upgrade.

How to use

Like any other upgrades, install it by right-clicking on a screen with the upgrade in your main hand. You will need the "Link & upgrade" permission to do that.

Please note that the emitting status of each blocks is conserved even when the screen is destroyed. You can know if a screen block is in the emitting state by using the IsEmitting and GetEmissionArray queries. You can also reset the emission state of the whole screen by using ClearRedstone. The F3 key may also be used to get this information for debugging purposes. The emitting status is then displayed when hovering the block on the right side.

Limits

Every player has its own instance of web browser, as described here. When any redstone-output-related query is executed, each client (player) receives it, but only the screen owner will forward the query to the server. Thus, using redstone output queries on non-owner web browsers is useless. This shouldn't be a problem in the following scenario:

  • You have a web page that runs a redstone output query when a button is clicked
  • A player clicks on the button
  • Every (near enough) player receives the click information, executing the redstone output query
  • For each non-owner players, the query does nothing
  • For the owner, on the other hand, the query is forwarded to the server
  • The server receives the query from the owner (and only him), and enables or disables the redstone emitting status for the specified block

However, if the owner is disconnected or if the owner is too far away, this will of course not work. The IsOwner query can be used to know if the web page is running on the owner's web browser.

JavaScript

The upgrade name returned by GetUpgrades is webdisplays:redoutput. For more information on how to use these queries, check out Screen#JavaScript.

Queries

This upgrade adds the following queries:

Query name Arguments Return value Comment
ClearRedstone None {"status":string} Sets all blocks in the passive state
SetRedstoneAt int, int, int {"status":string} Enable/disable the emitting state for the block at x, y depending on the value of the 3rd parameter (1 or 0). Rotation is not handled
IsEmitting int, int {"emitting":bool} Returns true if the block at x, y is emitting
GetEmissionArray None {"emission":[int]} Array of ones and zeroes. The emission state of the block at (x, y) is at index y * width + x

The status returned by each queries is either "ok" or "notOwner".