Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
street [2026/11/12 19:16] – [Sample Scripts] Copied the example code from street.js Bobblestreet [2026/11/20 05:33] (current) – [Sample Scripts] format sample script Bobble
Line 66: Line 66:
 ==== Events ==== ==== Events ====
  
-The street will send events when things happen, you can use the ''Street.on()'' function to subscribe to and event in your code and react to it in some way. For example, if a chat event has been recived you could script something to appear if it has the word "egg" in the message!+The street will send events when things happen, you can use the ''Street.on()'' function to subscribe to an event in your code and react to it in some way. For example, if a chat event has been recived you could script something to appear if it has the word "egg" in the message!
  
 | **Event** | **Fires when** | **Callback receives** | | **Event** | **Fires when** | **Callback receives** |
Line 91: Line 91:
 <code> <code>
 # Alert HELLO when a player is within the range of the door. # Alert HELLO when a player is within the range of the door.
-Street.on( "tick", () => +Street.on( "tick", () => { 
-{ +    if( Street.isPlayerNear( "door", 50 ) ) { 
-    if( Street.isPlayerNear( "door", 50 ) ) { Street.sendEvent( "open_door" ); } +        Street.sendEvent( "open_door" ); 
-} );+    } 
 +});
  
-Street.on( "event", (name, data, from) => { if( name === "open_door" ) { alert('HELLO'); } } );+Street.on( "event", (name, data, from) => { 
 +    if( name === "open_door" ) { 
 +        alert('HELLO');  
 +    } 
 +}); 
 +</code> 
 + 
 +<code> 
 +# A custom chat command that replies with the player's street name. 
 +document.addEventListener("DOMContentLoaded", function(event) { 
 +    Street.registerCommand("hello", helloPlayer, '/hello - welcomes the player'); 
 +}); 
 + 
 +function helloPlayer() { 
 +    const player = Street.me.streetName; 
 +    Street.say(`Hello ${player}!`); 
 +}
 </code> </code>
  


@000 Melon
Land
Forum Art Hub Chat Webring Explore Random Recent Tenement Arcade Want to Login or Join ? Web Craft Guide Graphic Catalogue Wiki Help I'm Lost! Link Land Newsletters Image Stream Minecraft: Online Zap!
Passport Sites tamaNOTchi Asatte Add your site?
Aero Archive Onio Cafe 32 Bit Cafe Status Cafe