Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
blocks:advanced_scripting:example1 [2019-02-12 21:43]
admin
blocks:advanced_scripting:example1 [2019-03-06 15:51] (current)
admin Foxed typo in initComms
Line 62: Line 62:
   }   }
  
-  /** Hook up event handler to receive data form reader. Get comms going.+  /** What needs to be one when we connect (or re-connect) to the reader device.
   */   */
   doWhenConnected() {   doWhenConnected() {
Line 73: Line 73:
   */   */
   initComms() {   initComms() {
-    if (this.networkPort.connected) {}+    if (this.networkPort.connected) {
       this.networkPort.sendText('\x02M+', '\r\n');       this.networkPort.sendText('\x02M+', '\r\n');
       this.networkPort.sendText('\x02MMT0100', '\r\n');       this.networkPort.sendText('\x02MMT0100', '\r\n');
Line 126: Line 126:
   * The script must be saved in a file named LeuzeScript.ts in the script/user directory of the Blocks root.    * The script must be saved in a file named LeuzeScript.ts in the script/user directory of the Blocks root. 
   * It compiles to a file named LeuzeScript.js, in that same directory. This is handled automatically by the [[blocks:drivers:tools|editor]] used to create and edit scripts.   * It compiles to a file named LeuzeScript.js, in that same directory. This is handled automatically by the [[blocks:drivers:tools|editor]] used to create and edit scripts.
 +  * The script doesn't expose any externally visible properties or functions, as all it's intended to do is handled internally.
   * The class name must match the filename (minus the .ts/.js file extension).   * The class name must match the filename (minus the .ts/.js file extension).
   * Several //console.log// calls were added during the development to inspect the behavior along the way. Those were commented out once the script was working properly.    * Several //console.log// calls were added during the development to inspect the behavior along the way. Those were commented out once the script was working properly.