Difference between revisions of "Redstone Output Port"
(→Queries) |
|||
Line 39: | Line 39: | ||
|- | |- | ||
|SetRedstoneAt||int, int, int||<code>{"status":string}</code>||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 | |SetRedstoneAt||int, int, int||<code>{"status":string}</code>||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||<code>{"emitting":bool}</code>||Returns true if the block at x, y is emitting | ||
+ | |- | ||
+ | |GetEmissionArray||None||<code>{"emission":[int]}</code>||Array of ones and zeroes. The emission state of the block at (x, y) is at index <code>y * width + x</code> | ||
|} | |} | ||
The status returned by each queries is either "ok" or "notOwner". | The status returned by each queries is either "ok" or "notOwner". |
Revision as of 01:17, 15 February 2018
The Redstone Output Port is an upgrade which allows web pages to change the redstone state of blocks around the screen.
Recipe
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. Thus, a good programmer should use the ClearRedstone
query when the page loads to make sure that all blocks are in the passive state. You can know if a screen block is in the emitting state by using the Minecraft F3 key. 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".