Difference between revisions of "Redstone Output Port"

From WebDisplays
Jump to: navigation, search
(Limits)
(How to use)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
The Redstone Output Port is an [[Screen#Upgrade|upgrade]] which allows web pages to change the redstone state of blocks around the screen.
 
The Redstone Output Port is an [[Screen#Upgrade|upgrade]] which allows web pages to change the redstone state of blocks around the screen.
 +
 +
{{#widget:AdSense}}
  
 
==Recipe==
 
==Recipe==
Line 9: Line 11:
 
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.
 
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 <code>ClearRedstone</code> 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.
+
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 <code>IsEmitting</code> and <code>GetEmissionArray</code> queries. You can also reset the emission state of the whole screen by using <code>ClearRedstone</code>. 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===
 
===Limits===
Line 36: Line 38:
 
|ClearRedstone||None||<code>{"status":string}</code>||Sets all blocks in the passive state
 
|ClearRedstone||None||<code>{"status":string}</code>||Sets all blocks in the passive state
 
|-
 
|-
|SetRedstoneAt||int, int, bool||<code>{"status":string}</code>||Enable/disable the emitting state for the block at x, y. Rotation is not handled</code>
+
|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".

Latest revision as of 01:19, 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

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".