This is an old revision of the document!
Table of Contents
Main Street
Main Street is a multiplayer avatar world embedded on many MelonLand pages, particularly on the everyone site. Each page/room on the everyone site is its own street, with its own chat, players and.. stuff!
To access Main Street on a page that supports it, look for the Rout 66 icon, or press the ` key. Some pages will show the street by default, while others will hide it until you first open it. You wont be visible to other players until you first open the street.
Some streets allow guests to walk around (but not chat), while others are for ML members only.
You can use the chat bar to chat with other plays, the arrow keys/mouse to move, and you can also enter some commands via “/help”, all streets offer a few basic commands but rooms can also script their own.
API and Scripting
Everyone Site pages can fully script and modify their local street, this includes moving the player, placing persistent objects and variables, messing with game modes etc. In theory you can script an entire MMO on an everyone site room just using the Main Street API!
You can access the street logic via the window.Street object, its included on every page that offers main street support, the street object gives you full access to the street API and data about players on the street!
Basic Config
The street can be customized on any Everyone Site page using these settings, set them with set with window.STREET_CONFIG = {ur options go here}
| Option | What it does | Default |
avatarSize | The size of avatars in px | 64 |
defaultAvatar | Avatar URL for guests and people with none | Plattyhoop |
moveSpeed | Player movement speed | 170 |
allowGuests | Let non-member guests appear in the room | true |
allowChat | Let members use the chat | true |
autoLoadOthers | Connect on load so the world shows before you enter the street | true |
themeColour | UI accent colour (nametags, chat etc) | #2bbfff |
disableStreet | Turn Main Street off for this page | false |
Functions & Settings
These are function you can call on the Street object to access info or modify things happening in the street, its the bulk of custom street scripting!
| API Function | What it does | Parameters |
Street.room | Get page street/room id | – |
Street.id | Get the players sync id | – |
Street.me | Get the players Avatar object | – |
Street.playerPos | Get the players x,y position | – |
Street.players | Array of every player/avatar in the room | – |
Street.getPlayer(nameOrId) | Find a player/avatar by sync id or name | nameOrId (id or name) |
Street.isPlayerNear(target, range) | True/False if player is with px of a target | target (element/id, player, object, or {x,y}) - range (px) |
Street.streetMode | True if the player has the street active | – |
Street.setMode(on) | Turn street mode on or off for the player | on (true/false) |
Street.enableChat() - Street.disableChat() | Show or hide the chat bar for members | – |
Street.showNametags() - Street.hideNametags() | Show or hide all nametags | – |
Street.teleportPlayer(x, y) | Warp the player to a position | x - y (px) |
Street.say(text) | Make the player say something | text |
Street.objects | List of persistent objects on the street | – |
Street.placeObject(kind, data) | Place a persistent object | kind (string) - data (object; or pos:[x,y]) |
Street.updateObject(id, data) | Update an existing object | id - data (values to merge) |
Street.removeObject(id) | Remove a persistent object | id |
Street.clearRoom() | Remove every persistent object on the street/room | – |
Street.setGlobal(key, value) | Save a variable shared across all streets/rooms | key (unique string) - value (any) |
Street.getGlobal(key) | Get a global variable | key |
Street.registerCommand(name, fn) | Add a custom /command to the street/room | name (word) - fn (receives the args string) |
Street.sendEvent(name, data) | Broadcast an event to all players | name (event) - data (any) |
Street.on(name, fn) | Subscribe to a street event (see below) | name (event) - fn (callback) |
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!
| Event | Fires when | Callback receives |
ready | Player has joined and the world has loaded | (me, world) |
join | Another player enters the room | (player) |
leave | Another player leaves the room | (player) |
chat | A chat message has been recived | (message, player) |
sync | The server has sent a data update | (players) |
move | The local player moved | (pos) - {x, y} |
tick | The streets clock | (dt) - delta time |
object.placed | A persistent object was placed | (object) |
object.updated | A persistent object was updated | (object) |
object.removed | A persistent object was removed | (id, by) |
global.changed | A shared global value was set | (key, value) |
mode | The player toggled street mode | (on) |
event | A generic event has been sent via sendEvent | (name, data, from) |
Scripting tips
To do!
Sample Scripts
To do!
